summaryrefslogtreecommitdiff
path: root/indra/newview/lltexlayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexlayer.cpp')
-rw-r--r--indra/newview/lltexlayer.cpp117
1 files changed, 105 insertions, 12 deletions
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index bd41aa64f0..6f6d5dbf12 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -45,6 +45,7 @@
#include "llagentwearables.h"
#include "llwearable.h"
#include "llviewercontrol.h"
+#include "llviewershadermgr.h"
#include "llviewervisualparam.h"
//#include "../tools/imdebug/imdebug.h"
@@ -215,22 +216,22 @@ void LLTexLayerSetBuffer::cancelUpload()
void LLTexLayerSetBuffer::pushProjection() const
{
- glMatrixMode(GL_PROJECTION);
+ gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
- glLoadIdentity();
- glOrtho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f);
+ gGL.loadIdentity();
+ gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f);
- glMatrixMode(GL_MODELVIEW);
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix();
- glLoadIdentity();
+ gGL.loadIdentity();
}
void LLTexLayerSetBuffer::popProjection() const
{
- glMatrixMode(GL_PROJECTION);
+ gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();
- glMatrixMode(GL_MODELVIEW);
+ gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.popMatrix();
}
@@ -293,6 +294,16 @@ BOOL LLTexLayerSetBuffer::render()
const BOOL update_now = mNeedsUpdate && isReadyToUpdate();
BOOL success = TRUE;
+
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.bind();
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
+
+ LLVertexBuffer::unbind();
// Composite the color data
LLGLSUIDefault gls_ui;
@@ -328,6 +339,13 @@ BOOL LLTexLayerSetBuffer::render()
doUpdate();
}
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.unbind();
+ }
+
+ LLVertexBuffer::unbind();
+
// reset GL state
gGL.setColorMask(true, true);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -917,6 +935,8 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
}
}
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
LLGLSUIDefault gls_ui;
LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE);
gGL.setColorMask(true, true);
@@ -925,12 +945,20 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
{
gGL.flush();
LLGLDisable no_alpha(GL_ALPHA_TEST);
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.0f);
+ }
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.color4f( 0.f, 0.f, 0.f, 1.f );
gl_rect_2d_simple( width, height );
gGL.flush();
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
}
if (mIsVisible)
@@ -957,6 +985,11 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
gGL.setSceneBlendType(LLRender::BT_REPLACE);
LLGLDisable no_alpha(GL_ALPHA_TEST);
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
+
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.color4f( 0.f, 0.f, 0.f, 0.f );
@@ -964,7 +997,10 @@ BOOL LLTexLayerSet::render( S32 x, S32 y, S32 width, S32 height )
gGL.setSceneBlendType(LLRender::BT_ALPHA);
gGL.flush();
-
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
}
return success;
@@ -1071,13 +1107,14 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height,
{
const LLTexLayerSetInfo *info = getInfo();
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
gGL.setColorMask(false, true);
gGL.setSceneBlendType(LLRender::BT_REPLACE);
// (Optionally) replace alpha with a single component image from a tga file.
if (!info->mStaticAlphaFileName.empty())
{
- LLGLSNoAlphaTest gls_no_alpha_test;
gGL.flush();
{
LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture(info->mStaticAlphaFileName, TRUE);
@@ -1096,12 +1133,20 @@ void LLTexLayerSet::renderAlphaMaskTextures(S32 x, S32 y, S32 width, S32 height,
// Set the alpha channel to one (clean up after previous blending)
gGL.flush();
LLGLDisable no_alpha(GL_ALPHA_TEST);
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.color4f( 0.f, 0.f, 0.f, 1.f );
gl_rect_2d_simple( width, height );
gGL.flush();
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
}
// (Optional) Mask out part of the baked texture with alpha masks
@@ -1586,6 +1631,8 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height)
LLGLEnable color_mat(GL_COLOR_MATERIAL);
gPipeline.disableLights();
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
LLColor4 net_color;
BOOL color_specified = findNetColor(&net_color);
@@ -1666,8 +1713,13 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height)
{
if( tex )
{
- LLGLDisable alpha_test(getInfo()->mWriteAllChannels ? GL_ALPHA_TEST : 0);
-
+ bool no_alpha_test = getInfo()->mWriteAllChannels;
+ LLGLDisable alpha_test(no_alpha_test ? GL_ALPHA_TEST : 0);
+ if (use_shaders && no_alpha_test)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
+
LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode();
gGL.getTexUnit(0)->bind(tex, TRUE);
@@ -1677,6 +1729,11 @@ 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)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
+
}
}
// else
@@ -1709,9 +1766,17 @@ BOOL LLTexLayer::render(S32 x, S32 y, S32 width, S32 height)
color_specified )
{
LLGLDisable no_alpha(GL_ALPHA_TEST);
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.color4fv( net_color.mV );
gl_rect_2d_simple( width, height );
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
}
if( alpha_mask_specified || getInfo()->mWriteAllChannels )
@@ -1799,15 +1864,25 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height)
gGL.flush();
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
if( !getInfo()->mStaticImageFileName.empty() )
{
LLViewerTexture* tex = LLTexLayerStaticImageList::getInstance()->getTexture( getInfo()->mStaticImageFileName, getInfo()->mStaticImageIsMask );
if( tex )
{
LLGLSNoAlphaTest gls_no_alpha_test;
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
gGL.getTexUnit(0)->bind(tex, TRUE);
gl_rect_2d_simple_tex( width, height );
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
}
else
{
@@ -1822,10 +1897,18 @@ BOOL LLTexLayer::blendAlphaTexture(S32 x, S32 y, S32 width, S32 height)
if (tex)
{
LLGLSNoAlphaTest gls_no_alpha_test;
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
gGL.getTexUnit(0)->bind(tex);
gl_rect_2d_simple_tex( width, height );
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
success = TRUE;
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
}
}
}
@@ -1844,6 +1927,13 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC
llassert( !mParamAlphaList.empty() );
+ bool use_shaders = LLGLSLShader::sNoFixedFunction;
+
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.f);
+ }
+
gGL.setColorMask(false, true);
LLTexLayerParamAlpha* first_param = *mParamAlphaList.begin();
@@ -1881,7 +1971,6 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC
if( tex && (tex->getComponents() == 4) )
{
LLGLSNoAlphaTest gls_no_alpha_test;
-
LLTexUnit::eTextureAddressMode old_mode = tex->getAddressMode();
gGL.getTexUnit(0)->bind(tex, TRUE);
@@ -1920,6 +2009,10 @@ BOOL LLTexLayer::renderMorphMasks(S32 x, S32 y, S32 width, S32 height, const LLC
gl_rect_2d_simple( width, height );
}
+ if (use_shaders)
+ {
+ gAlphaMaskProgram.setMinimumAlpha(0.004f);
+ }
LLGLSUIDefault gls_ui;