summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Houlton <euclid@lindenlab.com>2020-09-01 13:45:11 -0600
committerDave Houlton <euclid@lindenlab.com>2020-09-02 15:45:57 -0600
commit912afc940bc2e9680630ce2e9b282ecfc9b84050 (patch)
tree5f954026124b04da1f64996129462d41306e884f
parent282498061f2a15b695520001a1095162df8b47e8 (diff)
SL-12978 refactor sunlight intensity calculation
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl11
1 files changed, 3 insertions, 8 deletions
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index 140d788fff..bc6b006afa 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -80,14 +80,9 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
blue_weight = blue_density / temp1;
haze_weight = vec4(haze_density) / temp1;
- //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
- temp2.y = max(0.0, tmpLightnorm.y);
- if (abs(temp2.y) > 0.000001f)
- {
- temp2.y = 1. / abs(temp2.y);
- }
- temp2.y = max(0.0000001f, temp2.y);
- sunlight *= exp(-light_atten * temp2.y);
+ //(TERRAIN) compute sunlight from lightnorm z component, roughly cosine(sun elevation) (for short rays like terrain)
+ float above_horizon_angle = abs(tmpLightnorm.z);
+ sunlight *= exp(-light_atten * above_horizon_angle); // for atten and angle in [0..1], this maps to something like [0.3..1]
// main atmospheric scattering line integral
temp2.z = Plen * dens_mul;