From b9714ba85ebabdc39191565a26d732a82fd9a4a0 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Thu, 18 Oct 2012 15:00:05 -0400 Subject: Setting alpha rejection settings properly for texture bakes without basic shaders enabled --- indra/llappearance/lltexlayer.cpp | 90 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 4 deletions(-) (limited to 'indra/llappearance') diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp index 6e2623b860..b8c8228f85 100644 --- a/indra/llappearance/lltexlayer.cpp +++ b/indra/llappearance/lltexlayer.cpp @@ -153,6 +153,10 @@ BOOL LLTexLayerSetBuffer::renderTexLayerSet() gAlphaMaskProgram.bind(); gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } LLVertexBuffer::unbind(); @@ -400,6 +404,11 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) { gAlphaMaskProgram.setMinimumAlpha(0.0f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 1.f ); @@ -410,6 +419,10 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } } if (mIsVisible) @@ -440,6 +453,10 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) { gAlphaMaskProgram.setMinimumAlpha(0.f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 0.f ); @@ -452,6 +469,11 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } + } return success; @@ -568,6 +590,11 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, { gAlphaMaskProgram.setMinimumAlpha(0.f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4f( 0.f, 0.f, 0.f, 1.f ); @@ -578,6 +605,11 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } + } // (Optional) Mask out part of the baked texture with alpha masks @@ -1171,9 +1203,16 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) { bool no_alpha_test = getInfo()->mWriteAllChannels; LLGLDisable alpha_test(no_alpha_test ? GL_ALPHA_TEST : 0); - if (use_shaders && no_alpha_test) + if (no_alpha_test) { - gAlphaMaskProgram.setMinimumAlpha(0.f); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.f); + } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } } LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode(); @@ -1185,9 +1224,16 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) gGL.getTexUnit(0)->setTextureAddressMode(old_mode); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - if (use_shaders && no_alpha_test) + if (no_alpha_test) { - gAlphaMaskProgram.setMinimumAlpha(0.004f); + if (use_shaders) + { + gAlphaMaskProgram.setMinimumAlpha(0.004f); + } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } } } @@ -1226,6 +1272,11 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) { gAlphaMaskProgram.setMinimumAlpha(0.f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.color4fv( net_color.mV ); gl_rect_2d_simple( width, height ); @@ -1233,6 +1284,10 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } } if( alpha_mask_specified || getInfo()->mWriteAllChannels ) @@ -1332,6 +1387,11 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) { gAlphaMaskProgram.setMinimumAlpha(0.f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } + gGL.getTexUnit(0)->bind(tex, TRUE); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -1339,6 +1399,10 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } } else { @@ -1357,6 +1421,11 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) { gAlphaMaskProgram.setMinimumAlpha(0.f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } + gGL.getTexUnit(0)->bind(tex); gl_rect_2d_simple_tex( width, height ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -1365,6 +1434,10 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } } } } @@ -1391,6 +1464,11 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC { gAlphaMaskProgram.setMinimumAlpha(0.f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.0f); + } + gGL.setColorMask(false, true); @@ -1471,6 +1549,10 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC { gAlphaMaskProgram.setMinimumAlpha(0.004f); } + else + { + glAlphaFunc(GL_GEQUAL, 0.004f); + } LLGLSUIDefault gls_ui; -- cgit v1.2.3 From 3ac3f76fc36332e02551ed68c361c9808a8459e1 Mon Sep 17 00:00:00 2001 From: Nyx Linden Date: Fri, 19 Oct 2012 21:49:26 +0000 Subject: FIX: fixed broken baked texture rendering in lltexlayer, by enforcing correct gl state in lltexlayer.cpp FIX: updated appearance utility source package --- indra/llappearance/lltexlayer.cpp | 41 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'indra/llappearance') diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp index b8c8228f85..c44799f40d 100644 --- a/indra/llappearance/lltexlayer.cpp +++ b/indra/llappearance/lltexlayer.cpp @@ -148,6 +148,8 @@ BOOL LLTexLayerSetBuffer::renderTexLayerSet() bool use_shaders = LLGLSLShader::sNoFixedFunction; + LLGLEnable(GL_ALPHA_TEST); + if (use_shaders) { gAlphaMaskProgram.bind(); @@ -155,7 +157,7 @@ BOOL LLTexLayerSetBuffer::renderTexLayerSet() } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } LLVertexBuffer::unbind(); @@ -395,6 +397,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) LLGLSUIDefault gls_ui; LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE); gGL.setColorMask(true, true); + LLGLEnable(GL_ALPHA_TEST); // clear buffer area to ensure we don't pick up UI elements { @@ -406,7 +409,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -421,7 +424,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } } @@ -455,7 +458,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -471,7 +474,7 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height ) } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } } @@ -564,6 +567,7 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, gGL.setColorMask(false, true); gGL.setSceneBlendType(LLRender::BT_REPLACE); + LLGLEnable(GL_ALPHA_TEST); // (Optionally) replace alpha with a single component image from a tga file. if (!info->mStaticAlphaFileName.empty()) @@ -592,7 +596,7 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -607,7 +611,7 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height, } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } } @@ -1117,6 +1121,7 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) //gPipeline.disableLights(); stop_glerror(); glDisable(GL_LIGHTING); + glEnable(GL_ALPHA_TEST); stop_glerror(); bool use_shaders = LLGLSLShader::sNoFixedFunction; @@ -1211,7 +1216,7 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } } @@ -1232,7 +1237,7 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } } @@ -1274,7 +1279,7 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -1286,7 +1291,7 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } } @@ -1376,6 +1381,7 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) gGL.flush(); bool use_shaders = LLGLSLShader::sNoFixedFunction; + LLGLEnable(GL_ALPHA_TEST); if( !getInfo()->mStaticImageFileName.empty() ) { @@ -1389,7 +1395,7 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } gGL.getTexUnit(0)->bind(tex, TRUE); @@ -1401,7 +1407,7 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } } else @@ -1423,7 +1429,7 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } gGL.getTexUnit(0)->bind(tex); @@ -1436,7 +1442,7 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height) } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } } } @@ -1459,6 +1465,7 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC llassert( !mParamAlphaList.empty() ); bool use_shaders = LLGLSLShader::sNoFixedFunction; + LLGLEnable(GL_ALPHA_TEST); if (use_shaders) { @@ -1466,7 +1473,7 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC } else { - glAlphaFunc(GL_GEQUAL, 0.0f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.0f); } @@ -1551,7 +1558,7 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC } else { - glAlphaFunc(GL_GEQUAL, 0.004f); + gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.004f); } LLGLSUIDefault gls_ui; -- cgit v1.2.3