summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolwater.cpp
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-01-31 09:56:37 -0800
committerGraham Linden <graham@lindenlab.com>2019-01-31 09:56:37 -0800
commit767fb53aeb1ac92a141586b1c0b5d1e5d327b281 (patch)
tree969fe889ad0eed03676030e7a9a13965b077d20a /indra/newview/lldrawpoolwater.cpp
parent695490d41b5be60570806ec0179b0334d032a531 (diff)
9996 partial fix (works for non-ALM rendering only)
Use a new edge water shader to allow forcing frag depth to avoid z-fighting at back edge of water edge pieces. This will not work for ALM because forcing the depth breaks the use of the depth to backproject gbuffer position which breaks lighting calcs.
Diffstat (limited to 'indra/newview/lldrawpoolwater.cpp')
-rw-r--r--indra/newview/lldrawpoolwater.cpp99
1 files changed, 60 insertions, 39 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 826aa1cf24..c674d9a576 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -534,30 +534,6 @@ void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& li
gGL.getTexUnit(bumpTex2)->bind(tex_b);
}
- if (mWaterNormp[0])
- {
- if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
- {
- mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
- }
- else
- {
- mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_POINT);
- }
- }
-
- if (mWaterNormp[1])
- {
- if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
- {
- mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
- }
- else
- {
- mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_POINT);
- }
- }
-
shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getWaterFogColor().mV);
@@ -642,21 +618,42 @@ void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& li
sNeedsReflectionUpdate = TRUE;
sNeedsDistortionUpdate = TRUE;
- for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++)
- {
- LLFace *face = *iter;
- if (face)
- {
- LLVOWater* water = (LLVOWater*) face->getViewerObject();
- gGL.getTexUnit(diffTex)->bind(face->getTexture());
-
- bool edge_patch = water && water->getIsEdgePatch();
- if (edge_patch == edge)
+ if (edge)
+ {
+ for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++)
+ {
+ LLFace *face = *iter;
+ if (face)
{
- face->renderIndexed();
+ LLVOWater* water = (LLVOWater*) face->getViewerObject();
+ gGL.getTexUnit(diffTex)->bind(face->getTexture());
+
+ bool edge_patch = water && water->getIsEdgePatch();
+ if (edge_patch)
+ {
+ face->renderIndexed();
+ }
}
- }
- }
+ }
+ }
+ else
+ {
+ for (std::vector<LLFace*>::iterator iter = mDrawFace.begin(); iter != mDrawFace.end(); iter++)
+ {
+ LLFace *face = *iter;
+ if (face)
+ {
+ LLVOWater* water = (LLVOWater*) face->getViewerObject();
+ gGL.getTexUnit(diffTex)->bind(face->getTexture());
+
+ bool edge_patch = water && water->getIsEdgePatch();
+ if (!edge_patch)
+ {
+ face->renderIndexed();
+ }
+ }
+ }
+ }
}
shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
@@ -743,12 +740,36 @@ void LLDrawPoolWater::shade()
else if (deferred_render)
{
shader = &gDeferredWaterProgram;
- //edge_shader = &gDeferredWaterEdgeProgram;
+ edge_shader = nullptr;
}
else
{
shader = &gWaterProgram;
- //edge_shader = &gWaterEdgeProgram;
+ edge_shader = &gWaterEdgeProgram;
+ }
+
+ if (mWaterNormp[0])
+ {
+ if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
+ {
+ mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
+ }
+ else
+ {
+ mWaterNormp[0]->setFilteringOption(LLTexUnit::TFO_POINT);
+ }
+ }
+
+ if (mWaterNormp[1])
+ {
+ if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
+ {
+ mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
+ }
+ else
+ {
+ mWaterNormp[1]->setFilteringOption(LLTexUnit::TFO_POINT);
+ }
}
shade2(false, shader, light_diffuse, light_dir, light_exp);