SL-13281, add missing srgb->linear conversion for specular

master
Dave Houlton 2020-06-08 15:47:41 -06:00 committed by Andrey Lihatskiy
parent e1ea8eb773
commit 84d3065596
4 changed files with 69 additions and 44 deletions

View File

@ -985,38 +985,56 @@ BOOL LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image)
return FALSE;
}
if( !mHasExplicitFormat )
{
switch (mComponents)
{
case 1:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8;
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8_ALPHA8;
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 3:
mFormatInternal = GL_RGB8;
mFormatPrimary = GL_RGB;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 4:
mFormatInternal = GL_RGBA8;
mFormatPrimary = GL_RGBA;
mFormatType = GL_UNSIGNED_BYTE;
break;
default:
LL_ERRS() << "Bad number of components for texture: " << (U32)getComponents() << LL_ENDL;
}
}
if (!mHasExplicitFormat)
{
switch (mComponents)
{
case 1:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8;
mFormatPrimary = GL_LUMINANCE;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 2:
// Use luminance alpha (for fonts)
mFormatInternal = GL_LUMINANCE8_ALPHA8;
mFormatPrimary = GL_LUMINANCE_ALPHA;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 3:
#if USE_SRGB_DECODE
if (gGLManager.mHasTexturesRGBDecode)
{
mFormatInternal = GL_SRGB8;
}
else
#endif
{
mFormatInternal = GL_RGB8;
}
mFormatPrimary = GL_RGB;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 4:
#if USE_SRGB_DECODE
if (gGLManager.mHasTexturesRGBDecode)
{
mFormatInternal = GL_SRGB8_ALPHA8;
}
else
#endif
{
mFormatInternal = GL_RGBA8;
}
mFormatPrimary = GL_RGBA;
mFormatType = GL_UNSIGNED_BYTE;
break;
default:
LL_ERRS() << "Bad number of components for texture: " << (U32) getComponents() << LL_ENDL;
}
}
mCurrentDiscardLevel = discard_level;
mCurrentDiscardLevel = discard_level;
mDiscardLevelInAtlas = discard_level;
mTexelsInAtlas = raw_image->getWidth() * raw_image->getHeight() ;
mLastBindTime = sLastFrameTime;

View File

@ -849,26 +849,32 @@ void LLTexUnit::debugTextureUnit(void)
}
}
void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) {
void LLTexUnit::setTextureColorSpace(eTextureColorSpace space)
{
mTexColorSpace = space;
#if USE_SRGB_DECODE
if (gGLManager.mHasTexturesRGBDecode) {
if (space == TCS_SRGB) {
if (gGLManager.mHasTexturesRGBDecode)
{
if (space == TCS_SRGB)
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT);
}
else {
else
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
}
if (gDebugGL) {
if (gDebugGL)
{
assert_glerror();
}
}
else
#endif
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
{
glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);
}
}
LLLightState::LLLightState(S32 index)

View File

@ -501,23 +501,23 @@ U32 LLRenderTarget::getNumTextures() const
return mTex.size();
}
void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilterOptions filter_options)
{
gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index));
gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index));
bool isSRGB = false;
llassert(mInternalFormat.size() > index);
switch (mInternalFormat[index])
{
case GL_SRGB_ALPHA:
case GL_SRGB:
case GL_SRGB8:
case GL_SRGB_ALPHA:
case GL_SRGB8_ALPHA8:
isSRGB = true;
break;
break;
default:
break;
break;
}
gGL.getTexUnit(channel)->setTextureFilteringOption(filter_options);

View File

@ -77,6 +77,7 @@ void main()
vec3 norm = getNorm(frag.xy);
vec4 spec = texture2DRect(specularRect, frag.xy);
spec.rgb = srgb_to_linear(spec.rgb);
vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
diff.rgb = srgb_to_linear(diff.rgb);