summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
authorCallum Prentice <callum@lindenlab.com>2021-06-07 18:55:00 -0700
committerCallum Prentice <callum@lindenlab.com>2021-06-07 18:55:00 -0700
commitad9ed0a94dfd37878b35b70e0a365017a1e548bf (patch)
treea86bee1eba9cd8c40c1408abf067e3f8f673a33f /indra/newview/app_settings/shaders/class3
parentac8640d338997020ca0650001ff004e1103ac5cb (diff)
parent4623b822386accfae5907c88099c2a88377a0271 (diff)
Merge with tip of Master after Viewer release
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl117
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/skyF.glsl19
2 files changed, 17 insertions, 119 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl b/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl
deleted file mode 100644
index 8bb3f07fc6..0000000000
--- a/indra/newview/app_settings/shaders/class3/deferred/lightUtil.glsl
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * @file lightInfo.glsl
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2007, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-struct DirectionalLightInfo
-{
- vec4 pos;
- float depth;
- vec4 normal;
- vec3 normalizedLightDirection;
- vec3 normalizedToLight;
- float lightIntensity;
- vec3 lightDiffuseColor;
- float specExponent;
- float shadow;
-};
-
-struct SpotLightInfo
-{
- vec4 pos;
- float depth;
- vec4 normal;
- vec3 normalizedLightDirection;
- vec3 normalizedToLight;
- float lightIntensity;
- float attenuation;
- float distanceToLight;
- vec3 lightDiffuseColor;
- float innerHalfAngleCos;
- float outerHalfAngleCos;
- float spotExponent;
- float specExponent;
- float shadow;
-};
-
-struct PointLightInfo
-{
- vec4 pos;
- float depth;
- vec4 normal;
- vec3 normalizedToLight;
- float lightIntensity;
- float attenuation;
- float distanceToLight;
- vec3 lightDiffuseColor;
- float lightRadius;
- float specExponent;
- vec3 worldspaceLightDirection;
- float shadow;
-};
-
-float attenuate(float attenuationSelection, float distanceToLight)
-{
-// LLRENDER_REVIEW
-// sh/could eventually consume attenuation func defined in texture
- return (attenuationSelection == 0.0f) ? 1.0f : // none
- (attenuationSelection < 1.0f) ? (1.0f / distanceToLight) : // linear atten
- (attenuationSelection < 2.0f) ? (1.0f / (distanceToLight*distanceToLight)) // quadratic atten
- : (1.0f / (distanceToLight*distanceToLight*distanceToLight)); // cubic atten
-}
-
-
-vec3 lightDirectional(struct DirectionalLightInfo dli)
-{
- float lightIntensity = dli.lightIntensity;
- lightIntensity *= dot(dli.normal.xyz, dli.normalizedLightDirection);
- //lightIntensity *= directionalShadowSample(vec4(dli.pos.xyz, 1.0f), dli.depth, dli.directionalShadowMap, dli.directionalShadowMatrix);
- return lightIntensity * dli.lightDiffuseColor;
-}
-
-
-vec3 lightSpot(struct SpotLightInfo sli)
-{
- float penumbraRange = (sli.outerHalfAngleCos - sli.innerHalfAngleCos);
- float coneAngleCos = max(dot(sli.normalizedLightDirection, sli.normalizedToLight), 0.0);
- float coneAttenFactor = (coneAngleCos <= sli.outerHalfAngleCos) ? 1.0f : pow(smoothstep(1,0, sli.outerHalfAngleCos / penumbraRange), sli.spotExponent);
- float distanceAttenuation = attenuate(sli.attenuation, sli.distanceToLight);
- float lightIntensity = sli.lightIntensity;
- lightIntensity *= distanceAttenuation;
- lightIntensity *= max(dot(sli.normal.xyz, sli.normalizedLightDirection), 0.0);
- lightIntensity *= coneAttenFactor;
- lightIntensity *= sli.shadow;
- return lightIntensity * sli.lightDiffuseColor;
-}
-
-vec3 lightPoint(struct PointLightInfo pli)
-{
- float padRadius = pli.lightRadius * 0.1; // distance for which to perform smoothed dropoff past light radius
- float distanceAttenuation = attenuate(pli.attenuation, pli.distanceToLight);
- float lightIntensity = pli.lightIntensity;
- lightIntensity*= distanceAttenuation;
- lightIntensity *= clamp((padRadius - pli.distanceToLight + pli.lightRadius) / padRadius, 0.0, 1.0);
- lightIntensity *= pli.shadow;
- lightIntensity *= max(dot(pli.normal.xyz, pli.normalizedToLight), 0.0);
- return lightIntensity * pli.lightDiffuseColor;
-}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl
index 6de01cb667..a0b082ed7c 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl
@@ -56,8 +56,23 @@ vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir
vec3 ColorFromRadiance(vec3 radiance);
vec3 rainbow(float d)
{
- float rad = (droplet_radius - 5.0f) / 1024.0f;
- return pow(texture2D(rainbow_map, vec2(rad, d)).rgb, vec3(1.8)) * moisture_level;
+ // 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;
}
vec3 halo22(float d)