From 446afe2d1a081a0e10a34749bbe1e4475075dae0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 26 Mar 2019 08:21:53 -0700 Subject: 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. --- indra/llrender/llrender.cpp | 20 ++++++++++++++++++-- indra/llrender/llrender.h | 2 ++ 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'indra/llrender') 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; -- cgit v1.2.3