summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2021-06-29 10:48:02 -0400
committerNat Goodspeed <nat@lindenlab.com>2021-06-29 10:48:02 -0400
commit2e790e9b7250d5f79751fa5287c1993f3fa5c776 (patch)
tree60dd4f9462ba11a4cb7503c64fa1dd2a23373a67 /indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
parent1eeb4c85a120b23b853aabb8e6cf984b03dbc17f (diff)
parent467d8339c970c253dada2cf0e1eed45be66593ac (diff)
DRTVWR-538: Merge branch 'master' into c++17
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/skyF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/skyF.glsl16
1 files changed, 15 insertions, 1 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
index 1485c515a4..6841a8194f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl
@@ -73,7 +73,21 @@ uniform float ice_level;
vec3 rainbow(float d)
{
- d = clamp(d, -1.0, 0.0);
+ // d is the dot product of view and sun directions, so ranging -1.0..1.0
+ // 'interesting' values of d are the range -0.75..-0.825, when view is nearly opposite of sun vec
+ // Rainbox texture mode is GL_REPEAT, so tc of -.75 is equiv to 0.25, -0.825 equiv to 0.175.
+
+ // SL-13629 Rainbow texture has colors within the correct .175...250 range, but order is inverted.
+ // Rather than replace the texture, we mirror and translate the y tc to keep the colors within the
+ // interesting range, but in reversed order: i.e. d = (1 - d) - 1.575
+ d = clamp(-0.575 - d, 0.0, 1.0);
+
+ // With the colors in the lower 1/4 of the texture, inverting the coords leaves most of it inaccessible.
+ // So, we can stretch the texcoord above the colors (ie > 0.25) to fill the entire remaining coordinate
+ // space. This improves gradation, reduces banding within the rainbow interior. (1-0.25) / (0.425/0.25) = 4.2857
+ float interior_coord = max(0.0, d - 0.25) * 4.2857;
+ d = clamp(d, 0.0, 0.25) + interior_coord;
+
float rad = (droplet_radius - 5.0f) / 1024.0f;
return pow(texture2D(rainbow_map, vec2(rad, d)).rgb, vec3(1.8)) * moisture_level;
}