summaryrefslogtreecommitdiff
path: root/indra/llrender/llrender.cpp
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-03-26 08:21:53 -0700
committerGraham Linden <graham@lindenlab.com>2019-03-26 08:21:53 -0700
commit446afe2d1a081a0e10a34749bbe1e4475075dae0 (patch)
treed8d54398d764eaa59c564896c8ff74e71e1f4f63 /indra/llrender/llrender.cpp
parentd99e2e119f08370b2003bad23617b7fdd435d19e (diff)
Make whether the sun or moon is primary part of llrender light state so we can set uniforms for shaders along with other light params.
Fix atten calcs to not use abs val.
Diffstat (limited to 'indra/llrender/llrender.cpp')
-rw-r--r--indra/llrender/llrender.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index dc662bf898..2bf7ad9902 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -850,9 +850,12 @@ LLLightState::LLLightState(S32 index)
if (mIndex == 0)
{
mDiffuse.set(1,1,1,1);
+ mDiffuseB.set(0,0,0,0);
mSpecular.set(1,1,1,1);
}
+ mSunIsPrimary = true;
+
mAmbient.set(0,0,0,1);
mPosition.set(0,0,1,0);
mSpotDirection.set(0,0,-1);
@@ -904,6 +907,15 @@ void LLLightState::setDiffuseB(const LLColor4& diffuse)
}
}
+void LLLightState::setSunPrimary(bool v)
+{
+ if (mSunIsPrimary != v)
+ {
+ ++gGL.mLightHash;
+ mSunIsPrimary = v;
+ }
+}
+
void LLLightState::setAmbient(const LLColor4& ambient)
{
if (mAmbient != ambient)
@@ -1162,7 +1174,8 @@ void LLRender::syncLightState()
LLVector3 direction[8];
LLVector4 attenuation[8];
LLVector3 diffuse[8];
- LLVector3 diffuseB[8];
+ LLVector3 diffuse_b[8];
+ bool sun_primary[8];
for (U32 i = 0; i < 8; i++)
{
@@ -1172,7 +1185,8 @@ void LLRender::syncLightState()
direction[i] = light->mSpotDirection;
attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]);
diffuse[i].set(light->mDiffuse.mV);
- diffuseB[i].set(light->mDiffuseB.mV);
+ diffuse_b[i].set(light->mDiffuseB.mV);
+ sun_primary[i] = light->mSunIsPrimary;
}
shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV);
@@ -1180,6 +1194,8 @@ void LLRender::syncLightState()
shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV);
shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV);
shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV);
+ shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0);
+ shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV);
}
}