diff options
author | Sabrina Shanman <cosmic@lindenlab.com> | 2022-10-17 23:45:05 +0000 |
---|---|---|
committer | Sabrina Shanman <cosmic@lindenlab.com> | 2022-10-17 23:45:05 +0000 |
commit | 547fc1e6f548dbde3ba8e4d9b61d7504447afa27 (patch) | |
tree | b823291fd507240abab503cd6a51872521b0b27f /indra/newview/app_settings/shaders/class1/deferred | |
parent | 44687a78625d6ed21a82356b07e9927f8d45f629 (diff) | |
parent | 239dc764e66b3cfeb165a304e64f3f5ad756c3e5 (diff) |
Merged in SL-18340 (pull request #1158)
SL-18340: Fix PBR alpha materials treating spotlight as point light
Approved-by: Dave Parks
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl | 27 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl | 4 |
2 files changed, 29 insertions, 2 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; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index b3880ab178..d0d76fd0cb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -46,7 +46,7 @@ uniform mat4 modelview_projection_matrix; uniform mat4 texture_matrix0; -#ifdef HAS_SHADOW +#ifdef HAS_SUN_SHADOW VARYING vec3 vary_fragcoord; uniform float near_clip; #endif @@ -85,7 +85,7 @@ void main() #endif gl_Position = vert; -#ifdef HAS_SHADOW +#ifdef HAS_SUN_SHADOW vary_fragcoord.xyz = vert.xyz + vec3(0,0,near_clip); #endif |