summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolterrain.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-10-19 17:41:02 -0500
committerDave Parks <davep@lindenlab.com>2011-10-19 17:41:02 -0500
commit250ab43e4e70ccd9218d32c5dcbde35599c9735b (patch)
tree7556da6f559475774d630f4266de00f602e43f21 /indra/newview/lldrawpoolterrain.cpp
parentf19f43c74606e1f158cdabe9e783f9c82386b7b7 (diff)
SH-2571 Add shader driven render for low detail terrain.
Diffstat (limited to 'indra/newview/lldrawpoolterrain.cpp')
-rw-r--r--indra/newview/lldrawpoolterrain.cpp69
1 files changed, 48 insertions, 21 deletions
diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp
index d503d935d0..e14d0c5f9d 100644
--- a/indra/newview/lldrawpoolterrain.cpp
+++ b/indra/newview/lldrawpoolterrain.cpp
@@ -122,14 +122,7 @@ U32 LLDrawPoolTerrain::getVertexDataMask()
void LLDrawPoolTerrain::prerender()
{
mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT);
- if (mVertexShaderLevel > 0)
- {
- sDetailMode = 1;
- }
- else
- {
- sDetailMode = gSavedSettings.getS32("RenderTerrainDetail");
- }
+ sDetailMode = gSavedSettings.getS32("RenderTerrainDetail");
}
void LLDrawPoolTerrain::beginRenderPass( S32 pass )
@@ -137,9 +130,24 @@ void LLDrawPoolTerrain::beginRenderPass( S32 pass )
LLFastTimer t(FTM_RENDER_TERRAIN);
LLFacePool::beginRenderPass(pass);
- sShader = LLPipeline::sUnderWaterRender ?
- &gTerrainWaterProgram :
- &gTerrainProgram;
+ if (sDetailMode > 0)
+ {
+ sShader = LLPipeline::sUnderWaterRender ?
+ &gTerrainWaterProgram :
+ &gTerrainProgram;
+ }
+ else
+ {
+ if (LLPipeline::sUnderWaterRender)
+ {
+ sShader = &gObjectSimpleNonIndexedTexGenWaterProgram;
+ }
+ else
+ {
+ sShader = &gObjectSimpleNonIndexedTexGenProgram;
+ }
+ }
+
if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0)
{
@@ -200,7 +208,15 @@ void LLDrawPoolTerrain::render(S32 pass)
if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0)
{
gPipeline.enableLightsDynamic();
- renderFullShader();
+
+ if (sDetailMode > 0)
+ {
+ renderFullShader();
+ }
+ else
+ {
+ renderSimple();
+ }
}
else
{
@@ -827,13 +843,21 @@ void LLDrawPoolTerrain::renderSimple()
tp0.setVec(tscale, 0.f, 0.0f, -1.f*(origin_agent.mV[0]/256.f));
tp1.setVec(0.f, tscale, 0.0f, -1.f*(origin_agent.mV[1]/256.f));
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
- glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
-
+ if (LLGLSLShader::sNoFixedFunction)
+ {
+ sShader->uniform4fv("object_plane_s", 1, tp0.mV);
+ sShader->uniform4fv("object_plane_t", 1, tp1.mV);
+ }
+ else
+ {
+ glEnable(GL_TEXTURE_GEN_S);
+ glEnable(GL_TEXTURE_GEN_T);
+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0.mV);
+ glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1.mV);
+ }
+
gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_VERT_COLOR);
drawLoop();
@@ -843,8 +867,11 @@ void LLDrawPoolTerrain::renderSimple()
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- glDisable(GL_TEXTURE_GEN_S);
- glDisable(GL_TEXTURE_GEN_T);
+ if (!LLGLSLShader::sNoFixedFunction)
+ {
+ glDisable(GL_TEXTURE_GEN_S);
+ glDisable(GL_TEXTURE_GEN_T);
+ }
gGL.matrixMode(LLRender::MM_TEXTURE);
gGL.loadIdentity();
gGL.matrixMode(LLRender::MM_MODELVIEW);