diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2022-08-10 14:44:22 -0700 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2022-08-10 14:44:22 -0700 |
commit | 0ea71a2db2cddb2447a483d926e0cf6be84b344d (patch) | |
tree | a779b795a7d789227b399b9ead3174fde38e41b4 /indra/newview/app_settings/shaders/class3 | |
parent | a6d6652ff34953c83436643c9dec7f83e9e4142f (diff) |
SL-17763: PBR: Add spotlight ambiance to spotlight
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 3b028d9fae..308d045a9b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -84,6 +84,7 @@ void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc ); vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v); vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); +vec3 getProjectedLightAmbiance(float amb_da, float attenuation, float lit, float nl, float noise, vec2 projected_uv); vec3 getProjectedLightDiffuseColor(float light_distance, vec2 projected_uv ); vec3 getProjectedLightSpecularColor(vec3 pos, vec3 n); vec2 getScreenXY(vec4 clip_point); @@ -156,31 +157,43 @@ void main() vec3 packedORM = texture2DRect(emissiveRect, tc).rgb; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl float metal = packedORM.b; -// if (proj_tc.x > 0.0 && proj_tc.x < 1.0 -// && proj_tc.y > 0.0 && proj_tc.y < 1.0) - if (nl > 0.0) + // We need this additional test inside a light's frustum since a spotlight's ambiance can be applied + if (proj_tc.x > 0.0 && proj_tc.x < 1.0 + && proj_tc.y > 0.0 && proj_tc.y < 1.0) { - vec3 c_diff, reflect0, reflect90; - float alphaRough, specWeight; - initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight ); + float lit = 0.0; + float amb_da = 0.0; + + if (nl > 0.0) + { + amb_da += (nl*0.5 + 0.5) * proj_ambiance; + lit = nl * dist_atten; - dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); - slit = getProjectedLightSpecularColor( pos, n ); + vec3 c_diff, reflect0, reflect90; + float alphaRough, specWeight; + initMaterial( diffuse, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight ); - colorDiffuse = shadow * dist_atten * nl * (dlit*0.5 + BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh )); - colorSpec = shadow * dist_atten * nl * (slit + BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh )); + dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); + slit = getProjectedLightSpecularColor( pos, n ); + + colorDiffuse = shadow * dist_atten * nl * (dlit*0.5 + BRDFLambertian ( reflect0, reflect90, c_diff , specWeight, vh )); + colorSpec = shadow * dist_atten * nl * (slit + BRDFSpecularGGX( reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh )); #if DEBUG_PBR_SPOT_DIFFUSE - colorDiffuse = dlit.rgb; colorSpec = vec3(0); + colorDiffuse = dlit.rgb; colorSpec = vec3(0); #endif #if DEBUG_PBR_SPOT_SPECULAR - colorDiffuse = vec3(0); colorSpec = slit.rgb; + colorDiffuse = vec3(0); colorSpec = slit.rgb; #endif #if DEBUG_PBR_SPOT - colorDiffuse = dlit; colorSpec = vec3(0); - colorDiffuse *= nl; - colorDiffuse *= shadow; + colorDiffuse = dlit; colorSpec = vec3(0); + colorDiffuse *= nl; + colorDiffuse *= shadow; #endif + } + + vec3 amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy ); + colorDiffuse += diffuse.rgb * amb_rgb; } |