summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2018-08-30 21:37:10 +0100
committerGraham Linden <graham@lindenlab.com>2018-08-30 21:37:10 +0100
commitd452fd77eff53c031c74301dd44a35edce6da95b (patch)
tree936fd9d063b898b4081f95a4db11be6c7df5cb0b
parent6dd9dd3ab63cb0daa7682a400ff0408fd894ba77 (diff)
MAINT-9007
fix management of water plane and fog Ks shader uniforms
-rw-r--r--indra/llinventory/llsettingswater.h16
-rw-r--r--indra/newview/lldrawpoolwater.cpp14
-rw-r--r--indra/newview/llsettingsvo.cpp46
3 files changed, 24 insertions, 52 deletions
diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h
index 11d7150ba9..06ee8e68bc 100644
--- a/indra/llinventory/llsettingswater.h
+++ b/indra/llinventory/llsettingswater.h
@@ -200,19 +200,6 @@ public:
}
//-------------------------------------------
- LLVector4 getWaterPlane() const
- {
- update();
- return mWaterPlane;
- }
-
- F32 getWaterFogKS() const
- {
- update();
- return mWaterFogKS;
- }
-
- //-------------------------------------------
LLUUID getNextNormalMapID() const
{
return mNextNormalMapID;
@@ -251,9 +238,6 @@ protected:
LLSettingsWater();
- LLVector4 mWaterPlane;
- F32 mWaterFogKS;
-
private:
LLUUID mNextTransparentTextureID;
LLUUID mNextNormalMapID;
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 913a85affd..7f1601e604 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -619,17 +619,11 @@ void LLDrawPoolWater::shade()
}
}
- S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
-
- if (screentex > -1)
- {
- shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getWaterFogColor().mV);
- shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, pwater->getWaterFogDensity());
- gPipeline.mWaterDis.bindTexture(0, screentex);
- }
-
- stop_glerror();
+ shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR, 1, pwater->getWaterFogColor().mV);
+ shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, pwater->getWaterFogDensity());
+ // bind reflection texture from RenderTarget
+ S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);
if (mVertexShaderLevel == 1)
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index 719d682118..12f487398f 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -793,30 +793,6 @@ void LLSettingsVOWater::applySpecial(void *ptarget)
if (shader->mShaderGroup == LLGLSLShader::SG_WATER)
{
- shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, getWaterPlane().mV);
- shader->uniform1f(LLShaderMgr::WATER_FOGKS, getWaterFogKS());
-
- F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor();
- shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
-
- LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm();
- shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV);
- shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
- shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0);
- }
-}
-
-void LLSettingsVOWater::updateSettings()
-{
- // LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES);
- // LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty. Reticulating Splines..." << LL_ENDL;
-
- // base class clears dirty flag so as to not trigger recursive update
- LLSettingsBase::updateSettings();
-
- // only do this if we're dealing with shaders
- if (gPipeline.canUseVertexShaders())
- {
//transform water plane to eye space
glh::vec3f norm(0.f, 0.f, 1.f);
glh::vec3f p(0.f, 0.f, LLEnvironment::instance().getWaterHeight() + 0.1f);
@@ -835,12 +811,30 @@ void LLSettingsVOWater::updateSettings()
enorm.normalize();
mat.mult_matrix_vec(p, ep);
- mWaterPlane = LLVector4(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm));
+ LLVector4 waterPlane(enorm.v[0], enorm.v[1], enorm.v[2], -ep.dot(enorm));
+
+ shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, waterPlane.mV);
LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm();
- mWaterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP);
+ F32 waterFogKS = 1.f / llmax(light_direction.mV[2], WATER_FOG_LIGHT_CLAMP);
+
+ shader->uniform1f(LLShaderMgr::WATER_FOGKS, waterFogKS);
+
+ F32 blend_factor = LLEnvironment::instance().getCurrentWater()->getBlendFactor();
+ shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor);
+
+ LLVector4 rotated_light_direction = LLEnvironment::instance().getRotatedLightNorm();
+ shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, rotated_light_direction.mV);
+ shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
+ shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0);
}
+}
+
+void LLSettingsVOWater::updateSettings()
+{
+ // base class clears dirty flag so as to not trigger recursive update
+ LLSettingsBase::updateSettings();
LLDrawPoolWater* pwaterpool = (LLDrawPoolWater*)gPipeline.getPool(LLDrawPool::POOL_WATER);
if (pwaterpool)