summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2022-10-13 16:59:34 -0700
committerCosmic Linden <cosmic@lindenlab.com>2022-10-13 16:59:34 -0700
commit982e2bcbeaa3a56a884ecb168dc655dc6413465c (patch)
tree0556ffbbf12656b99f43bf5fbef8c17d12c39c6e /indra/newview/app_settings/shaders/class2/deferred
parent8a82305068f68ae4075be7ff86b5b4af8a71e5c3 (diff)
SL-18340: Consolidate shared pbr shading into calcDiffuseSpecular, pbrBaseLight
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl49
1 files changed, 24 insertions, 25 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
index d7da50e25e..f5c36be897 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl
@@ -75,8 +75,6 @@ vec3 srgb_to_linear(vec3 c);
vec3 linear_to_srgb(vec3 c);
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);
void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist);
float calcLegacyDistanceAttenuation(float distance, float falloff);
@@ -86,14 +84,23 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
void waterClip(vec3 pos);
-// PBR interface
-vec3 pbrIbl(vec3 diffuseColor,
- vec3 specularColor,
- vec3 radiance, // radiance map sample
- vec3 irradiance, // irradiance map sample
- float ao, // ambient occlusion factor
- float nv, // normal dot view vector
- float perceptualRoughness);
+void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor);
+
+vec3 pbrBaseLight(vec3 diffuseColor,
+ vec3 specularColor,
+ float metallic,
+ vec3 pos,
+ vec3 norm,
+ float perceptualRoughness,
+ vec3 light_dir,
+ vec3 sunlit,
+ float scol,
+ vec3 radiance,
+ vec3 irradiance,
+ vec3 colorEmissive,
+ float ao,
+ vec3 additive,
+ vec3 atten);
vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
float perceptualRoughness,
@@ -201,24 +208,16 @@ void main()
vec3 irradiance = vec3(0);
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 (see pbrBaseLight), do not apply here
+ irradiance = max(amblit,irradiance);
- vec3 f0 = vec3(0.04);
-
- vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
- diffuseColor *= 1.0 - metallic;
-
- vec3 specularColor = mix(f0, baseColor.rgb, metallic);
+ vec3 diffuseColor;
+ vec3 specularColor;
+ calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
- float NdotV = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0);
-
- color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
- color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, v, light_dir) * sunlit * scol;
- color += colorEmissive*0.5;
-
- color = atmosFragLightingLinear(color, additive, atten);
- color = scaleSoftClipFragLinear(color);
+ color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
vec3 light = vec3(0);