summaryrefslogtreecommitdiff
path: root/indra/newview/lldrawpoolwater.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldrawpoolwater.cpp')
-rw-r--r--indra/newview/lldrawpoolwater.cpp169
1 files changed, 93 insertions, 76 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 514ce41d5a..826aa1cf24 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -477,85 +477,14 @@ void LLDrawPoolWater::renderReflection(LLFace* face)
face->renderIndexed();
}
-void LLDrawPoolWater::shade()
+void LLDrawPoolWater::shade2(bool edge, LLGLSLShader* shader, const LLColor3& light_diffuse, const LLVector3& light_dir, F32 light_exp)
{
- if (!deferred_render)
- {
- gGL.setColorMask(true, true);
- }
-
- LLVOSky *voskyp = gSky.mVOSkyp;
-
- if(voskyp == NULL)
- {
- return;
- }
-
- LLGLDisable blend(GL_BLEND);
-
- LLColor3 light_diffuse(0,0,0);
- F32 light_exp = 0.0f;
- LLVector3 light_dir;
+ F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();
LLEnvironment& environment = LLEnvironment::instance();
LLSettingsWater::ptr_t pwater = environment.getCurrentWater();
LLSettingsSky::ptr_t psky = environment.getCurrentSky();
- light_dir = environment.getLightDirection();
- light_dir.normalize();
-
- bool sun_up = environment.getIsSunUp();
- bool moon_up = environment.getIsMoonUp();
-
- if (sun_up)
- {
- light_diffuse += voskyp->getSun().getColorCached();
- }
- // moonlight is several orders of magnitude less bright than sunlight,
- // so only use this color when the moon alone is showing
- else if (moon_up)
- {
- light_diffuse += psky->getMoonDiffuse();
- }
-
- light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
-
- light_diffuse.normalize();
- light_diffuse *= (light_exp + 0.25f);
-
- light_exp *= light_exp;
- light_exp *= light_exp;
- light_exp *= light_exp;
- light_exp *= light_exp;
- light_exp *= 256.f;
- light_exp = light_exp > 32.f ? light_exp : 32.f;
-
- light_diffuse *= 6.f;
-
- LLGLSLShader* shader;
-
- F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();
-
- if (eyedepth < 0.f && LLPipeline::sWaterReflections)
- {
- if (deferred_render)
- {
- shader = &gDeferredUnderWaterProgram;
- }
- else
- {
- shader = &gUnderWaterProgram;
- }
- }
- else if (deferred_render)
- {
- shader = &gDeferredWaterProgram;
- }
- else
- {
- shader = &gWaterProgram;
- }
-
shader->bind();
if (deferred_render)
@@ -721,9 +650,11 @@ void LLDrawPoolWater::shade()
LLVOWater* water = (LLVOWater*) face->getViewerObject();
gGL.getTexUnit(diffTex)->bind(face->getTexture());
- bool edge = water && water->getIsEdgePatch();
- shader->uniform1i(LLShaderMgr::WATER_EDGE_FACTOR, edge ? 1 : 0);
- face->renderIndexed();
+ bool edge_patch = water && water->getIsEdgePatch();
+ if (edge_patch == edge)
+ {
+ face->renderIndexed();
+ }
}
}
}
@@ -736,6 +667,92 @@ void LLDrawPoolWater::shade()
shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
shader->unbind();
+}
+
+void LLDrawPoolWater::shade()
+{
+ if (!deferred_render)
+ {
+ gGL.setColorMask(true, true);
+ }
+
+ LLVOSky *voskyp = gSky.mVOSkyp;
+
+ if(voskyp == NULL)
+ {
+ return;
+ }
+
+ LLGLDisable blend(GL_BLEND);
+
+ LLColor3 light_diffuse(0,0,0);
+ F32 light_exp = 0.0f;
+ LLVector3 light_dir;
+
+ LLEnvironment& environment = LLEnvironment::instance();
+ LLSettingsWater::ptr_t pwater = environment.getCurrentWater();
+ LLSettingsSky::ptr_t psky = environment.getCurrentSky();
+
+ light_dir = environment.getLightDirection();
+ light_dir.normalize();
+
+ bool sun_up = environment.getIsSunUp();
+ bool moon_up = environment.getIsMoonUp();
+
+ if (sun_up)
+ {
+ light_diffuse += voskyp->getSun().getColorCached();
+ }
+ // moonlight is several orders of magnitude less bright than sunlight,
+ // so only use this color when the moon alone is showing
+ else if (moon_up)
+ {
+ light_diffuse += psky->getMoonDiffuse();
+ }
+
+ light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
+
+ light_diffuse.normalize();
+ light_diffuse *= (light_exp + 0.25f);
+
+ light_exp *= light_exp;
+ light_exp *= light_exp;
+ light_exp *= light_exp;
+ light_exp *= light_exp;
+ light_exp *= 256.f;
+ light_exp = light_exp > 32.f ? light_exp : 32.f;
+
+ light_diffuse *= 6.f;
+
+ LLGLSLShader* shader = nullptr;
+ LLGLSLShader* edge_shader = nullptr;
+
+ F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - LLEnvironment::instance().getWaterHeight();
+
+ if (eyedepth < 0.f && LLPipeline::sWaterReflections)
+ {
+ if (deferred_render)
+ {
+ shader = &gDeferredUnderWaterProgram;
+ }
+ else
+ {
+ shader = &gUnderWaterProgram;
+ }
+ }
+ else if (deferred_render)
+ {
+ shader = &gDeferredWaterProgram;
+ //edge_shader = &gDeferredWaterEdgeProgram;
+ }
+ else
+ {
+ shader = &gWaterProgram;
+ //edge_shader = &gWaterEdgeProgram;
+ }
+
+ shade2(false, shader, light_diffuse, light_dir, light_exp);
+ shade2(true, edge_shader ? edge_shader : shader, light_diffuse, light_dir, light_exp);
gGL.getTexUnit(0)->activate();
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);