summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolalpha.cpp
diff options
context:
space:
mode:
authorCinder Roxley <cinder.roxley@phoenixviewer.com>2013-06-27 21:22:44 -0600
committerCinder Roxley <cinder.roxley@phoenixviewer.com>2013-06-27 21:22:44 -0600
commit7e0bc07e5cd72cfb7c55c964a73d9d8c9e9e5988 (patch)
treee847d23a8642323ef63df22a9426f1524d4da796 /indra/newview/lldrawpoolalpha.cpp
parent4f7b8a7e861ee25f1e0f7b0df2e9c8372254f46d (diff)
parent6060e5e46acbeb20a301070a0fd0efea029d33d0 (diff)
Merged lindenlab/viewer-release into default
Diffstat (limited to 'indra/newview/lldrawpoolalpha.cpp')
-rwxr-xr-xindra/newview/lldrawpoolalpha.cpp164
1 files changed, 83 insertions, 81 deletions
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 313b310e1e..c832e1401d 100755
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -71,33 +71,6 @@ void LLDrawPoolAlpha::prerender()
mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
}
-S32 LLDrawPoolAlpha::getNumDeferredPasses()
-{
- return 1;
-}
-
-void LLDrawPoolAlpha::beginDeferredPass(S32 pass)
-{
-
-}
-
-void LLDrawPoolAlpha::endDeferredPass(S32 pass)
-{
-
-}
-
-void LLDrawPoolAlpha::renderDeferred(S32 pass)
-{
- LLFastTimer t(FTM_RENDER_GRASS);
- gDeferredDiffuseAlphaMaskProgram.bind();
- gDeferredDiffuseAlphaMaskProgram.setMinimumAlpha(0.33f);
-
- //render alpha masked objects
- LLRenderPass::pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
- gDeferredDiffuseAlphaMaskProgram.unbind();
-}
-
-
S32 LLDrawPoolAlpha::getNumPostDeferredPasses()
{
if (LLPipeline::sImpostorRender)
@@ -121,8 +94,10 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass)
if (pass == 0)
{
simple_shader = &gDeferredAlphaProgram;
- fullbright_shader = &gObjectFullbrightAlphaMaskProgram;
-
+ fullbright_shader = &gObjectFullbrightProgram;
+ fullbright_shader->bind();
+ fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f);
+ fullbright_shader->unbind();
//prime simple shader (loads shadow relevant uniforms)
gPipeline.bindDeferredShader(*simple_shader);
}
@@ -133,8 +108,7 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass)
gPipeline.mDeferredDepth.copyContents(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(),
0, 0, gPipeline.mDeferredDepth.getWidth(), gPipeline.mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
gPipeline.mDeferredDepth.bindTarget();
- simple_shader = NULL;
- fullbright_shader = NULL;
+ simple_shader = fullbright_shader = &gObjectFullbrightAlphaMaskProgram;
gObjectFullbrightAlphaMaskProgram.bind();
gObjectFullbrightAlphaMaskProgram.setMinimumAlpha(0.33f);
}
@@ -150,7 +124,6 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass)
void LLDrawPoolAlpha::endPostDeferredPass(S32 pass)
{
-
if (pass == 1)
{
gPipeline.mDeferredDepth.flush();
@@ -173,14 +146,14 @@ void LLDrawPoolAlpha::beginRenderPass(S32 pass)
if (LLPipeline::sUnderWaterRender)
{
- simple_shader = &gObjectSimpleWaterAlphaMaskProgram;
- fullbright_shader = &gObjectFullbrightWaterAlphaMaskProgram;
+ simple_shader = &gObjectSimpleWaterProgram;
+ fullbright_shader = &gObjectFullbrightWaterProgram;
emissive_shader = &gObjectEmissiveWaterProgram;
}
else
{
- simple_shader = &gObjectSimpleAlphaMaskProgram;
- fullbright_shader = &gObjectFullbrightAlphaMaskProgram;
+ simple_shader = &gObjectSimpleProgram;
+ fullbright_shader = &gObjectFullbrightProgram;
emissive_shader = &gObjectEmissiveProgram;
}
@@ -218,43 +191,7 @@ void LLDrawPoolAlpha::render(S32 pass)
{
gGL.setColorMask(true, true);
}
-
- if (LLPipeline::sAutoMaskAlphaNonDeferred)
- {
- mColorSFactor = LLRender::BF_ONE; // }
- mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow
- mAlphaSFactor = LLRender::BF_ZERO;
- mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds
- gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
-
- if (mVertexShaderLevel > 0)
- {
- if (!LLPipeline::sRenderDeferred || !deferred_render)
- {
- simple_shader->bind();
- simple_shader->setMinimumAlpha(0.33f);
-
- pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
- }
- if (fullbright_shader)
- {
- fullbright_shader->bind();
- fullbright_shader->setMinimumAlpha(0.33f);
- }
- pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
- //LLGLSLShader::bindNoShader();
- }
- else
- {
- gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); //OK
- gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
- pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask());
- gPipeline.enableLightsDynamic();
- pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask());
- gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK
- }
- }
-
+
LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ||
(deferred_render && pass == 1) ? GL_TRUE : GL_FALSE);
@@ -302,7 +239,7 @@ void LLDrawPoolAlpha::render(S32 pass)
if (mVertexShaderLevel > 0)
{
- renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX);
+ renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2);
}
else
{
@@ -412,8 +349,14 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
}
LLRenderPass::applyModelMatrix(params);
-
+ LLMaterial* mat = NULL;
+
+ if (deferred_render && !LLPipeline::sUnderWaterRender)
+ {
+ mat = params.mMaterial;
+ }
+
if (params.mFullbright)
{
// Turn off lighting if it hasn't already been so.
@@ -446,11 +389,30 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
light_enabled = TRUE;
}
- // 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))
+ if (deferred_render && mat)
{
- llassert(target_shader != NULL);
+ U32 mask = params.mShaderMask;
+
+ llassert(mask < LLMaterial::SHADER_COUNT);
+ target_shader = &(gDeferredMaterialProgram[mask]);
+
+ if (current_shader != target_shader)
+ {
+ gPipeline.bindDeferredShader(*target_shader);
+ }
+ }
+ else if (!params.mFullbright)
+ {
+ target_shader = simple_shader;
+ }
+ else
+ {
+ target_shader = fullbright_shader;
+ }
+
+ if(use_shaders && (current_shader != target_shader))
+ {// If we need shaders, and we're not ALREADY using the proper shader, then bind it
+ // (this way we won't rebind shaders unnecessarily).
current_shader = target_shader;
current_shader->bind();
}
@@ -459,6 +421,38 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
LLGLSLShader::bindNoShader();
current_shader = NULL;
}
+
+ if (use_shaders && mat)
+ {
+ // We have a material. Supply the appropriate data here.
+ if (LLPipeline::sRenderDeferred)
+ {
+ current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, params.mSpecColor.mV[0], params.mSpecColor.mV[1], params.mSpecColor.mV[2], params.mSpecColor.mV[3]);
+ current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, params.mEnvIntensity);
+ current_shader->uniform1f(LLShaderMgr::EMISSIVE_BRIGHTNESS, params.mFullbright ? 1.f : 0.f);
+
+ if (params.mNormalMap)
+ {
+ params.mNormalMap->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::BUMP_MAP, params.mNormalMap);
+ }
+
+ if (params.mSpecularMap)
+ {
+ params.mSpecularMap->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, params.mSpecularMap);
+ }
+ }
+
+ } else if (LLPipeline::sRenderDeferred && current_shader && (current_shader == simple_shader))
+ {
+ current_shader->uniform4f(LLShaderMgr::SPECULAR_COLOR, 1.0f, 1.0f, 1.0f, 1.0f);
+ current_shader->uniform1f(LLShaderMgr::ENVIRONMENT_INTENSITY, 0.0f);
+ LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::BUMP_MAP, LLViewerFetchedTexture::sFlatNormalImagep);
+ LLViewerFetchedTexture::sWhiteImagep->addTextureStats(params.mVSize);
+ current_shader->bindTexture(LLShaderMgr::SPECULAR_MAP, LLViewerFetchedTexture::sWhiteImagep);
+ }
if (params.mGroup)
{
@@ -477,12 +471,20 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
}
}
}
- else
+ 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 (use_shaders && mat)
+ {
+ current_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, params.mTexture);
+ }
+ else
+ {
+ gGL.getTexUnit(0)->bind(params.mTexture, TRUE);
+ }
+
if (params.mTextureMatrix)
{
tex_setup = true;