summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-04-22 10:21:10 -0700
committerGraham Linden <graham@lindenlab.com>2019-04-22 10:21:10 -0700
commit4d76ba2d23c22e9a507a0eb7687b3750091b356f (patch)
tree3a39e4c40664561bc27891f56f2e8cd63cd8f063
parentdd1cc2f3b1df472be405f4b95107972be1ea1a62 (diff)
Fix mismatch between release and EEP in sunlight and ambient color from settings.
-rw-r--r--indra/llinventory/llsettingssky.cpp55
-rw-r--r--indra/llinventory/llsettingssky.h1
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/skyF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/skyV.glsl2
8 files changed, 40 insertions, 32 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;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
index 6cc436c837..61fd43f1ee 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
@@ -103,7 +103,7 @@ void main()
vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
- float dens_mul = density_multiplier * 0.5;
+ float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
index 7d56742d6f..bee8e2dab5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -87,7 +87,7 @@ void main()
vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
- float dens_mul = density_multiplier * 0.5;
+ float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index 3d05912f49..fc49562235 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -62,8 +62,8 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o
vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
- float dens_mul = density_multiplier * 0.5; // get back to original pre-EEP range...
- float dist_mul = distance_multiplier * 0.1; // get back to original pre-EEP range...
+ float dens_mul = density_multiplier;
+ float dist_mul = distance_multiplier * 0.1;
//sunlight attenuation effect (hue and brightness) due to atmosphere
//this is used later for sunlight modulation at various altitudes
@@ -76,7 +76,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o
haze_weight = vec4(haze_density) / temp1;
//(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
- temp2.y = max(0.0, tmpLightnorm.y);
+ temp2.y = max(0.0, tmpLightnorm.z);
if (temp2.y > 0.001f)
{
temp2.y = 1. / temp2.y;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
index ea926ab5f1..a8eb7102ed 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
@@ -117,7 +117,7 @@ void main()
vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
- float dens_mul = density_multiplier * 0.5;
+ float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
index fcfe5bbba0..64156bd3bf 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl
@@ -103,7 +103,7 @@ void main()
vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
- float dens_mul = density_multiplier * 0.5;
+ float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
index a253bb72d5..6d6b3dafa7 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl
@@ -87,7 +87,7 @@ void main()
vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color;
vec4 light_atten;
- float dens_mul = density_multiplier * 0.5;
+ float dens_mul = density_multiplier;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes