summaryrefslogtreecommitdiff
path: root/indra/llinventory
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llinventory')
-rw-r--r--indra/llinventory/llsettingssky.cpp55
-rw-r--r--indra/llinventory/llsettingssky.h1
2 files changed, 32 insertions, 24 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index a0d81e6d99..41e8882181 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -1180,29 +1180,34 @@ void LLSettingsSky::setHazeHorizon(F32 val)
setDirtyFlag(true);
}
+// Get total from rayleigh and mie density values for normalization
+LLColor3 LLSettingsSky::getTotalDensity() const
+{
+ LLColor3 blue_density = getBlueDensity();
+ F32 haze_density = getHazeDensity();
+ LLColor3 total_density = blue_density + smear(haze_density);
+ return total_density;
+}
+
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
LLColor3 LLSettingsSky::getLightAttenuation(F32 distance) const
{
-// LEGACY_ATMOSPHERICS
- LLColor3 blue_density = getBlueDensity();
- F32 haze_density = getHazeDensity();
F32 density_multiplier = getDensityMultiplier();
- LLColor3 density = (blue_density * 1.0 + smear(haze_density * 0.25f));
- LLColor3 light_atten = density * density_multiplier * distance;
+ LLColor3 blue_density = getBlueDensity();
+ F32 haze_density = getHazeDensity();
+ // Approximate line integral over requested distance
+ LLColor3 light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * density_multiplier * distance;
return light_atten;
}
LLColor3 LLSettingsSky::getLightTransmittance() const
{
-// LEGACY_ATMOSPHERICS
- LLColor3 blue_density = getBlueDensity();
- F32 haze_density = getHazeDensity();
- F32 density_multiplier = getDensityMultiplier();
- LLColor3 temp1 = blue_density + smear(haze_density);
- // Transparency (-> temp1)
- temp1 = componentExp((temp1 * -1.f) * density_multiplier);
- return temp1;
+ LLColor3 total_density = getTotalDensity();
+ F32 density_multiplier = getDensityMultiplier();
+ // Transparency (-> density) from Beer's law
+ LLColor3 transmittance = componentExp(total_density * -density_multiplier);
+ return transmittance;
}
LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const
@@ -1262,18 +1267,19 @@ void LLSettingsSky::calculateLightSettings() const
{
// Initialize temp variables
LLColor3 sunlight = getSunlightColor();
- LLColor3 ambient = getAmbientColor();
+ LLColor3 ambient = getAmbientColor();
+
F32 cloud_shadow = getCloudShadow();
LLVector3 lightnorm = getLightDirection();
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
- F32 max_y = getMaxY();
- LLColor3 light_atten = getLightAttenuation(max_y);
- LLColor3 light_transmittance = getLightTransmittance();
+ F32 max_y = getMaxY();
+ LLColor3 light_atten = getLightAttenuation(max_y);
+ LLColor3 light_transmittance = getLightTransmittance();
// and vary_sunlight will work properly with moon light
- F32 lighty = lightnorm[1];
+ F32 lighty = lightnorm[2];
if(lighty > 0.001f)
{
lighty = 1.f / lighty;
@@ -1282,22 +1288,23 @@ void LLSettingsSky::calculateLightSettings() const
componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty));
//increase ambient when there are more clouds
- LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f;
+ LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow;
//brightness of surface both sunlight and ambient
- mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance));
- mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5);
+ mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance));
+ mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance));
F32 moon_brightness = getMoonBrightness();
LLColor3 moonlight_a(0.66, 0.66, 0.66);
LLColor3 moonlight_b(0.66, 0.66, 1.0);
- LLColor3 moonlight = lerp(moonlight_b, moonlight_a, moon_brightness);
-
+ LLColor3 moonlight = lerp(moonlight_b, moonlight_a, moon_brightness);
+ componentMultBy(moonlight, componentExp((light_atten * -1.f) * lighty));
+
mMoonDiffuse = gammaCorrect(componentMult(moonlight, light_transmittance) * moon_brightness * 0.25f);
mMoonAmbient = gammaCorrect(componentMult(moonlight_b, light_transmittance) * 0.0125f);
- mTotalAmbient = mSunAmbient;
+ mTotalAmbient = mSunAmbient + mMoonAmbient;
}
LLUUID LLSettingsSky::GetDefaultAssetId()
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index d585eeddfa..ef2a6740f0 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -252,6 +252,7 @@ public:
LLColor3 getLightAttenuation(F32 distance) const;
LLColor3 getLightTransmittance() const;
+ LLColor3 getTotalDensity() const;
LLColor3 gammaCorrect(const LLColor3& in) const;
LLColor3 getBlueDensity() const;