summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llinventory/llsettingssky.cpp2
-rw-r--r--indra/llrender/llrender.cpp20
-rw-r--r--indra/llrender/llrender.h2
-rw-r--r--indra/newview/pipeline.cpp3
4 files changed, 23 insertions, 4 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index f1bea326c1..0e597aabb0 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -1281,7 +1281,7 @@ void LLSettingsSky::calculateLightSettings() const
// and vary_sunlight will work properly with moon light
F32 lighty = lightnorm[1];
- if(fabs(lighty) > 0.001f)
+ if(lighty > 0.001f)
{
lighty = 1.f / lighty;
}
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);
}
}
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index 3f2d5eb35d..ad9cd11283 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -239,6 +239,7 @@ public:
void setSpotExponent(const F32& exponent);
void setSpotCutoff(const F32& cutoff);
void setSpotDirection(const LLVector3& direction);
+ void setSunPrimary(bool v);
protected:
friend class LLRender;
@@ -247,6 +248,7 @@ protected:
bool mEnabled;
LLColor4 mDiffuse;
LLColor4 mDiffuseB;
+ bool mSunIsPrimary;
LLColor4 mAmbient;
LLColor4 mSpecular;
LLVector4 mPosition;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c4a644c7b6..4c93d16fb1 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6240,6 +6240,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
LLLightState* light = gGL.getLight(0);
light->setPosition(light_dir);
+ light->setSunPrimary(sun_up);
light->setDiffuse(mSunDiffuse);
light->setDiffuseB(mMoonDiffuse);
light->setAmbient(LLColor4::black);
@@ -6361,7 +6362,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
{
mHWLightColors[cur_light] = LLColor4::black;
LLLightState* light = gGL.getLight(cur_light);
-
+ light->setSunPrimary(true);
light->setDiffuse(LLColor4::black);
light->setAmbient(LLColor4::black);
light->setSpecular(LLColor4::black);