summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-09-30 10:57:01 -0500
committerDave Parks <davep@lindenlab.com>2022-09-30 10:57:01 -0500
commit7d426815019ac5394e5821f1c6ba374e12606aaa (patch)
tree748b74f24b343f19bb1c98503d57b3618799ec80 /indra/newview/app_settings/shaders/class2
parentd001c52c346d957375afc36bd83550a5702d4727 (diff)
SL-18239 Unify PBR and non-PBR treatment of ambient/SSAO/irradiance. Restore SSAO to release version.
Diffstat (limited to 'indra/newview/app_settings/shaders/class2')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl18
3 files changed, 29 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
index 39aec699fe..b4406aabc0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -80,7 +80,7 @@ vec2 encode_normal (vec3 n);
vec3 scaleSoftClipFragLinear(vec3 l);
vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
-void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive, bool use_ao);
+void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
#ifdef HAS_SHADOW
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
@@ -243,12 +243,12 @@ void main()
vec3 additive;
vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false);
+ calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten);
- vec3 ambenv;
+ vec3 irradiance;
vec3 glossenv;
vec3 legacyenv;
- sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, 0.0, 0.0);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, pos.xyz, norm.xyz, 0.0, 0.0);
float da = dot(norm.xyz, light_dir.xyz);
@@ -261,15 +261,9 @@ void main()
color.a = final_alpha;
- float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
- ambient *= 0.5;
- ambient *= ambient;
- ambient = (1.0 - ambient);
-
vec3 sun_contrib = min(final_da, shadow) * sunlit;
- color.rgb = max(amblit, ambenv);
- color.rgb *= ambient;
+ color.rgb = max(amblit, irradiance);
color.rgb += sun_contrib;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index 13544af0b1..9bbc4f87bf 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -74,8 +74,7 @@ uniform vec2 light_deferred_attenuation[8]; // light size and falloff
vec3 srgb_to_linear(vec3 c);
vec3 linear_to_srgb(vec3 c);
-// These are in deferredUtil.glsl but we can't set: mFeatures.isDeferred to include it
-void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao);
+void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive);
vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
vec3 scaleSoftClipFragLinear(vec3 l);
@@ -140,15 +139,6 @@ void main()
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
vec3 pos = vary_position;
- float scol = 1.0;
- float ambocc = 1.0;
-
- vec3 sunlit;
- vec3 amblit;
- vec3 additive;
- vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true);
-
// IF .mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels;
// vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb;
@@ -174,6 +164,13 @@ void main()
norm *= gl_FrontFacing ? 1.0 : -1.0;
+ float scol = 1.0;
+ vec3 sunlit;
+ vec3 amblit;
+ vec3 additive;
+ vec3 atten;
+ calcAtmosphericVarsLinear(pos.xyz, norm, light_dir, sunlit, amblit, additive, atten);
+
#ifdef HAS_SHADOW
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
frag *= screen_res;
diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
index 0093e8a31e..8937488484 100644
--- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl
@@ -146,15 +146,29 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
vec3 srgb_to_linear(vec3 col);
+// provide a touch of lighting in the opposite direction of the sun light
+ // so areas in shadow don't lose all detail
+float ambientLighting(vec3 norm, vec3 light_dir)
+{
+ float ambient = min(abs(dot(norm.xyz, light_dir.xyz)), 1.0);
+ ambient *= 0.56;
+ ambient *= ambient;
+ ambient = (1.0 - ambient);
+ return ambient;
+}
+
+
// return colors in linear space
-void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive,
- out vec3 atten, bool use_ao)
+void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 additive,
+ out vec3 atten)
{
#if 1
calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten, false);
sunlit = srgb_to_linear(sunlit);
additive = srgb_to_linear(additive);
amblit = ambient_linear;
+
+ amblit *= ambientLighting(norm, light_dir);
#else
//EXPERIMENTAL -- attempt to factor out srgb_to_linear conversions above