summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-05-21 19:10:32 +0100
committerGraham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com>2018-05-21 19:10:32 +0100
commitae5f24eb4d8a215cc26ef45ababc6ddec8f28edb (patch)
tree9e64b5e79ad3cc503de5a766b863eeb07ed159ea
parent589e23884f957e00328b7aa04629f47d1f070a4e (diff)
Make rendering of sun / moon work with both in the sky (test visibility independently).
-rw-r--r--indra/newview/lldrawpoolwater.cpp53
-rw-r--r--indra/newview/llenvironment.cpp11
-rw-r--r--indra/newview/llenvironment.h4
-rw-r--r--indra/newview/llvosky.cpp7
4 files changed, 32 insertions, 43 deletions
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 2804ad1f46..bcc0023089 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -493,45 +493,30 @@ void LLDrawPoolWater::shade()
light_dir = voskyp->getLightDirection();
light_dir.normalize();
- if (LLEnvironment::instance().getIsDayTime())
+ bool sun_up = LLEnvironment::instance().getIsSunUp();
+ bool moon_up = LLEnvironment::instance().getIsSunUp();
+
+ if (sun_up)
{
- light_color = voskyp->getSunAmbientColor();
- light_diffuse = voskyp->getSunDiffuseColor();
- light_diffuse.normalize();
- light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
- light_diffuse *= (light_exp + 0.25f);
+ light_color = light_color + voskyp->getSunAmbientColor();
+ light_diffuse += voskyp->getSunDiffuseColor();
}
- else
+
+ light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
+
+ if (moon_up)
{
- light_color = voskyp->getMoonDiffuseColor();
- light_diffuse = voskyp->getMoonDiffuseColor();
- light_diffuse.normalize();
- light_diffuse *= 0.5f;
- light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
+ light_color += voskyp->getMoonDiffuseColor();
+ light_diffuse += voskyp->getMoonDiffuseColor() * 0.5f;
+
+ if (!sun_up)
+ {
+ light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f);
+ }
}
-// if (gSky.getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS)
-// {
-// light_dir = gSky.getSunDirection();
-// light_dir.normVec();
-// light_color = gSky.getSunDiffuseColor();
-// if(gSky.mVOSkyp) {
-// light_diffuse = gSky.mVOSkyp->getSun().getColorCached();
-// light_diffuse.normVec();
-// }
-// light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0);
-// light_diffuse *= light_exp + 0.25f;
-// }
-// else
-// {
-// light_dir = gSky.getMoonDirection();
-// light_dir.normVec();
-// light_color = gSky.getMoonDiffuseColor();
-// light_diffuse = gSky.mVOSkyp->getMoon().getColorCached();
-// light_diffuse.normVec();
-// light_diffuse *= 0.5f;
-// light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0);
-// }
+ light_diffuse.normalize();
+ light_diffuse *= (light_exp + 0.25f);
light_exp *= light_exp;
light_exp *= light_exp;
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index d37cbfc76d..cc3a30d0b1 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -377,9 +377,16 @@ F32 LLEnvironment::getWaterHeight() const
return gAgent.getRegion()->getWaterHeight();
}
-bool LLEnvironment::getIsDayTime() const
+bool LLEnvironment::getIsSunUp() const
{
- return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_SIN;
+ LLVector3 sunDir = mCurrentEnvironment->getSky()->getSunDirection();
+ return sunDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
+}
+
+bool LLEnvironment::getIsMoonUp() const
+{
+ LLVector3 moonDir = mCurrentEnvironment->getSky()->getMoonDirection();
+ return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
}
//-------------------------------------------------------------------------
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index e4f891deca..0de92dc50b 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -183,8 +183,8 @@ public:
F32 getCamHeight() const;
F32 getWaterHeight() const;
- bool getIsDayTime() const; // "Day Time" is defined as the sun above the horizon.
- bool getIsNightTime() const { return !getIsDayTime(); } // "Not Day Time"
+ bool getIsSunUp() const;
+ bool getIsMoonUp() const;
inline F32 getSceneLightStrength() const { return mSceneLightStrength; }
inline void setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; }
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 428493ee14..37c1e4f14e 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -696,11 +696,8 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable)
bool draw_sun = updateHeavenlyBodyGeometry(drawable, FACE_SUN, mSun, up, right);
bool draw_moon = updateHeavenlyBodyGeometry(drawable, FACE_MOON, mMoon, up, right);
- bool daytime = LLEnvironment::getInstance()->getIsDayTime();
-
- // makeshift check until we properly handle moon in daytime
- draw_sun &= daytime;
- draw_moon &= !daytime;
+ draw_sun &= LLEnvironment::getInstance()->getIsSunUp();
+ draw_moon &= LLEnvironment::getInstance()->getIsMoonUp();
mSun.setDraw(draw_sun);
mMoon.setDraw(draw_moon);