summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
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/class1/deferred/deferredUtil.glsl
parent8a82305068f68ae4075be7ff86b5b4af8a71e5c3 (diff)
SL-18340: Consolidate shared pbr shading into calcDiffuseSpecular, pbrBaseLight
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl27
1 files changed, 27 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
index 9405a125fd..1a96ee0736 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl
@@ -73,6 +73,8 @@ const float M_PI = 3.14159265;
const float ONE_OVER_PI = 0.3183098861;
vec3 srgb_to_linear(vec3 cs);
+vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten);
+vec3 scaleSoftClipFragLinear(vec3 light);
float calcLegacyDistanceAttenuation(float distance, float falloff)
{
@@ -506,6 +508,31 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor,
return color;
}
+void calcDiffuseSpecular(vec3 baseColor, float metallic, inout vec3 diffuseColor, inout vec3 specularColor)
+{
+ vec3 f0 = vec3(0.04);
+ diffuseColor = baseColor*(vec3(1.0)-f0);
+ diffuseColor *= 1.0 - metallic;
+ specularColor = mix(f0, baseColor, metallic);
+}
+
+vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, vec3 norm, float perceptualRoughness, vec3 light_dir, vec3 sunlit, float scol, vec3 radiance, vec3 irradiance, vec3 colorEmissive, float ao, vec3 additive, vec3 atten)
+{
+ vec3 color = vec3(0);
+
+ float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0);
+
+ color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness);
+
+ color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir)) * sunlit * 2.75 * scol;
+ color += colorEmissive*0.5;
+
+ color = atmosFragLightingLinear(color, additive, atten);
+ color = scaleSoftClipFragLinear(color);
+
+ return color;
+}
+
uniform vec4 waterPlane;
uniform float waterSign;