summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
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/class3
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/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl53
3 files changed, 26 insertions, 38 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index c1f60da7ee..1150d40007 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -43,7 +43,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color);
vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten);
vec3 scaleSoftClipFragLinear(vec3 l);
-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 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten);
vec3 srgb_to_linear(vec3 cs);
@@ -301,7 +301,7 @@ void main()
vec3 amblit;
vec3 additive;
vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false);
+ calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
vec3 ambenv;
vec3 glossenv;
@@ -311,12 +311,6 @@ void main()
// use sky settings ambient or irradiance map sample, whichever is brighter
color = max(amblit, ambenv);
- float ambient = min(abs(dot(norm.xyz, light_dir.xyz)), 1.0);
- ambient *= 0.5;
- ambient *= ambient;
- ambient = (1.0 - ambient);
- color.rgb *= ambient;
-
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
vec3 sun_contrib = min(da, shadow) * sunlit;
color.rgb += sun_contrib;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index a1125cc1dd..80f9e29123 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -529,7 +529,6 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
ambenv = sampleProbeAmbient(pos, norm);
- ambenv /= 1.725;
if (glossiness > 0.0)
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 3e44e87f1e..e5ffe55163 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -69,7 +69,7 @@ uniform vec2 screen_res;
vec3 getNorm(vec2 pos_screen);
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
-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 l, vec3 additive, vec3 atten);
vec3 scaleSoftClipFragLinear(vec3 l);
vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten);
@@ -112,9 +112,11 @@ void main()
float depth = texture2DRect(depthMap, tc.xy).r;
vec4 pos = getPositionWithDepth(tc, depth);
vec4 norm = texture2DRect(normalMap, tc);
+ float envIntensity = norm.z;
+ norm.xyz = getNorm(tc);
vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir;
- vec4 diffuse = texture2DRect(diffuseRect, tc);
+ vec4 baseColor = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); // NOTE: PBR linear Emissive
#if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO)
@@ -122,7 +124,7 @@ void main()
#endif
#if defined(HAS_SUN_SHADOW)
- float scol = max(scol_ambocc.r, diffuse.a);
+ float scol = max(scol_ambocc.r, baseColor.a);
#else
float scol = 1.0;
#endif
@@ -140,15 +142,10 @@ void main()
vec3 additive;
vec3 atten;
- calcAtmosphericVarsLinear(pos.xyz, light_dir, 1.0, sunlit, amblit, additive, atten, false);
-
- vec3 ambenv;
- vec3 glossenv;
- vec3 legacyenv;
+ calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- norm.xyz = getNorm(tc);
vec3 orm = texture2DRect(specularRect, tc).rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
@@ -162,11 +159,11 @@ void main()
vec3 radiance = vec3(0);
sampleReflectionProbes(irradiance, radiance, pos.xyz, norm.xyz, gloss);
- irradiance = max(amblit*0.75,irradiance);
+ // Take maximium of legacy ambient vs irradiance sample as irradiance
+ // NOTE: ao is applied in pbrIbl, do not apply here
+ irradiance = max(amblit,irradiance);
vec3 f0 = vec3(0.04);
- vec3 baseColor = diffuse.rgb;
-
vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
diffuseColor *= 1.0 - metallic;
@@ -185,35 +182,33 @@ void main()
}
else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
{
- //should only be true of WL sky, just port over diffuse value
- color = srgb_to_linear(diffuse.rgb);
+ //should only be true of WL sky, just port over base color value
+ color = srgb_to_linear(baseColor.rgb);
}
else
{
// legacy shaders are still writng sRGB to gbuffer
- diffuse.rgb = srgb_to_linear(diffuse.rgb);
+ baseColor.rgb = srgb_to_linear(baseColor.rgb);
spec.rgb = srgb_to_linear(spec.rgb);
- float envIntensity = norm.z;
- norm.xyz = getNorm(tc);
-
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
- sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity);
+ vec3 irradiance = vec3(0);
+ vec3 glossenv = vec3(0);
+ vec3 legacyenv = vec3(0);
+ sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity);
+
// use sky settings ambient or irradiance map sample, whichever is brighter
- color = max(amblit, ambenv*ambocc);
+ irradiance = max(amblit, irradiance);
- float ambient = min(abs(dot(norm.xyz, light_dir.xyz)), 1.0);
- ambient *= 0.5;
- ambient *= ambient;
- ambient = (1.0 - ambient);
- color.rgb *= ambient;
+ // apply lambertian IBL only (see pbrIbl)
+ color.rgb = irradiance * ambocc;
vec3 sun_contrib = min(da, scol) * sunlit;
color.rgb += sun_contrib;
- color.rgb *= diffuse.rgb;
-
+ color.rgb *= baseColor.rgb;
+
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
if (spec.a > 0.0) // specular reflection
@@ -229,14 +224,14 @@ void main()
applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
}
- color.rgb = mix(color.rgb, diffuse.rgb, diffuse.a);
+ color.rgb = mix(color.rgb, baseColor.rgb, baseColor.a);
if (envIntensity > 0.0)
{ // add environment map
applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
}
- color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), diffuse.a);
+ color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), baseColor.a);
color = scaleSoftClipFragLinear(color);
}