summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolalpha.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolalpha.cpp')
-rw-r--r--indra/newview/lldrawpoolalpha.cpp173
1 files changed, 86 insertions, 87 deletions
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 8b5a2ce781..ad7e3ad593 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -124,7 +124,10 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass)
if (pass == 0)
{
simple_shader = &gDeferredAlphaProgram;
- fullbright_shader = &gDeferredFullbrightProgram;
+ fullbright_shader = &gObjectFullbrightProgram;
+
+ //prime simple shader (loads shadow relevant uniforms)
+ gPipeline.bindDeferredShader(*simple_shader);
}
else
{
@@ -228,13 +231,13 @@ void LLDrawPoolAlpha::render(S32 pass)
if (!LLPipeline::sRenderDeferred)
{
simple_shader->bind();
- pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask());
+ pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
}
if (fullbright_shader)
{
fullbright_shader->bind();
}
- pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask());
+ pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
LLGLSLShader::bindNoShader();
}
else
@@ -273,7 +276,14 @@ void LLDrawPoolAlpha::render(S32 pass)
}
}
- renderAlpha(getVertexDataMask());
+ if (mVertexShaderLevel > 0)
+ {
+ renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX);
+ }
+ else
+ {
+ renderAlpha(getVertexDataMask());
+ }
gGL.setColorMask(true, false);
@@ -283,23 +293,26 @@ void LLDrawPoolAlpha::render(S32 pass)
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
- if (deferred_render && current_shader != NULL)
- {
- gPipeline.unbindDeferredShader(*current_shader);
- }
-
if (sShowDebugAlpha)
{
- if(gPipeline.canUseWindLightShaders())
+ BOOL shaders = gPipeline.canUseVertexShaders();
+ if(shaders)
{
- LLGLSLShader::bindNoShader();
+ gObjectFullbrightNonIndexedProgram.bind();
+ }
+ else
+ {
+ gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
}
- gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
glColor4f(1,0,0,1);
LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f);
gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ;
renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX |
LLVertexBuffer::MAP_TEXCOORD0);
+ if(shaders)
+ {
+ gObjectFullbrightNonIndexedProgram.unbind();
+ }
}
}
@@ -339,12 +352,9 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
{
BOOL initialized_lighting = FALSE;
BOOL light_enabled = TRUE;
- S32 diffuse_channel = 0;
-
- BOOL use_shaders = (LLPipeline::sUnderWaterRender && gPipeline.canUseVertexShaders())
- || gPipeline.canUseWindLightShadersOnObjects();
-
+ BOOL use_shaders = gPipeline.canUseVertexShaders();
+
for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
{
LLSpatialGroup* group = *i;
@@ -357,7 +367,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow.
// All particle systems seem to come off the wire with texture entries which claim that they glow. This is probably a bug in the data. Suppress.
group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE &&
- group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_CLOUD &&
group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE;
LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];
@@ -368,92 +377,89 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
LLRenderPass::applyModelMatrix(params);
+
+ if (params.mFullbright)
{
- if (params.mFullbright)
- {
- // Turn off lighting if it hasn't already been so.
- if (light_enabled || !initialized_lighting)
- {
- initialized_lighting = TRUE;
- if (use_shaders)
- {
- target_shader = fullbright_shader;
- }
- else
- {
- gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
- }
- light_enabled = FALSE;
- }
- }
- // Turn on lighting if it isn't already.
- else if (!light_enabled || !initialized_lighting)
+ // Turn off lighting if it hasn't already been so.
+ if (light_enabled || !initialized_lighting)
{
initialized_lighting = TRUE;
if (use_shaders)
{
- target_shader = simple_shader;
+ target_shader = fullbright_shader;
}
else
{
- gPipeline.enableLightsDynamic();
+ gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
}
- light_enabled = TRUE;
+ light_enabled = FALSE;
}
-
- // If we need shaders, and we're not ALREADY using the proper shader, then bind it
- // (this way we won't rebind shaders unnecessarily).
- if(use_shaders && (current_shader != target_shader))
+ }
+ // Turn on lighting if it isn't already.
+ else if (!light_enabled || !initialized_lighting)
+ {
+ initialized_lighting = TRUE;
+ if (use_shaders)
{
- llassert(target_shader != NULL);
- if (deferred_render && current_shader != NULL)
- {
- gPipeline.unbindDeferredShader(*current_shader);
- diffuse_channel = 0;
- }
- current_shader = target_shader;
- if (deferred_render)
- {
- gPipeline.bindDeferredShader(*current_shader);
- diffuse_channel = current_shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
- }
- else
- {
- current_shader->bind();
- }
+ target_shader = simple_shader;
}
- else if (!use_shaders && current_shader != NULL)
+ else
{
- if (deferred_render)
- {
- gPipeline.unbindDeferredShader(*current_shader);
- diffuse_channel = 0;
- }
- LLGLSLShader::bindNoShader();
- current_shader = NULL;
+ gPipeline.enableLightsDynamic();
}
+ light_enabled = TRUE;
+ }
- if (params.mGroup)
- {
- params.mGroup->rebuildMesh();
- }
+ // If we need shaders, and we're not ALREADY using the proper shader, then bind it
+ // (this way we won't rebind shaders unnecessarily).
+ if(use_shaders && (current_shader != target_shader))
+ {
+ llassert(target_shader != NULL);
+ current_shader = target_shader;
+ current_shader->bind();
+ }
+ else if (!use_shaders && current_shader != NULL)
+ {
+ LLGLSLShader::bindNoShader();
+ current_shader = NULL;
+ }
-
- if (params.mTexture.notNull())
+ if (params.mGroup)
+ {
+ params.mGroup->rebuildMesh();
+ }
+
+ bool tex_setup = false;
+
+ if (use_shaders && params.mTextureList.size() > 1)
+ {
+ for (U32 i = 0; i < params.mTextureList.size(); ++i)
{
- gGL.getTexUnit(diffuse_channel)->bind(params.mTexture.get());
- if(params.mTexture.notNull())
+ if (params.mTextureList[i].notNull())
{
- params.mTexture->addTextureStats(params.mVSize);
+ gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE);
}
+ }
+ }
+ else
+ { //not batching textures or batch has only 1 texture -- might need a texture matrix
+ if (params.mTexture.notNull())
+ {
+ params.mTexture->addTextureStats(params.mVSize);
+ gGL.getTexUnit(0)->bind(params.mTexture, TRUE) ;
if (params.mTextureMatrix)
{
+ tex_setup = true;
gGL.getTexUnit(0)->activate();
glMatrixMode(GL_TEXTURE);
glLoadMatrixf((GLfloat*) params.mTextureMatrix->mMatrix);
gPipeline.mTextureMatrixOps++;
}
}
+ else
+ {
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+ }
}
params.mVertexBuffer->setBuffer(mask);
@@ -480,7 +486,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
}
- if (params.mTextureMatrix && params.mTexture.notNull())
+ if (tex_setup)
{
gGL.getTexUnit(0)->activate();
glLoadIdentity();
@@ -490,15 +496,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
}
}
- if (deferred_render && current_shader != NULL)
- {
- gPipeline.unbindDeferredShader(*current_shader);
- LLVertexBuffer::unbind();
- LLGLState::checkStates();
- LLGLState::checkTextureChannels();
- LLGLState::checkClientArrays();
- }
-
+ LLVertexBuffer::unbind();
+
if (!light_enabled)
{
gPipeline.enableLightsDynamic();