diff options
author | Ptolemy <ptolemy@lindenlab.com> | 2022-07-21 19:55:11 -0700 |
---|---|---|
committer | Ptolemy <ptolemy@lindenlab.com> | 2022-08-02 09:44:44 -0700 |
commit | fb29b66fcf029342959d9403964f5e3b3be89a23 (patch) | |
tree | acf1e0cb5ef6b463fea4ec08973ff579d00f3577 /indra/newview/app_settings/shaders/class3 | |
parent | 2bdb97613b1c1ac76c6c1eed7038e390d80594bd (diff) |
SL-17762: PBR: Cleanup code, add clipProjectedLightVars()
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl | 20 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl | 19 |
2 files changed, 10 insertions, 29 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index 332cf28fb8..31544cf212 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -78,6 +78,7 @@ uniform mat4 inv_proj; vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh ); vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh ); 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); +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); vec2 getScreenXY(vec4 clip); @@ -146,14 +147,13 @@ void main() vec2 tc = getScreenXY(vary_fragcoord); vec3 pos = getPosition(tc).xyz; - vec3 lv = center.xyz-pos.xyz; - float dist = length(lv); - - if (dist >= size) + vec3 lv; + vec4 proj_tc; + float dist, l_dist; + if (clipProjectedLightVars(center, pos, dist, l_dist, lv, proj_tc)) { discard; } - dist /= size; float shadow = 1.0; @@ -169,16 +169,6 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); - float l_dist = -dot(lv, proj_n); - - vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); - if (proj_tc.z < 0.0) - { - discard; - } - - proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index b94db1b4cb..7a2cb84f6e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -77,6 +77,7 @@ uniform mat4 inv_proj; vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh ); vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh ); 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); +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); vec2 getScreenXY(vec4 clip_point); @@ -135,13 +136,13 @@ void main() vec2 tc = getScreenXY(vary_fragcoord); vec3 pos = getPosition(tc).xyz; - vec3 lv = trans_center.xyz-pos.xyz; - float dist = length(lv); - if (dist >= size) + vec3 lv; + vec4 proj_tc; + float dist, l_dist; + if (clipProjectedLightVars(trans_center, pos, dist, l_dist, lv, proj_tc)) { discard; } - dist /= size; float shadow = 1.0; @@ -157,16 +158,6 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() - float l_dist = -dot(lv, proj_n); - - vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); - if (proj_tc.z < 0.0) - { - discard; - } - - proj_tc.xyz /= proj_tc.w; - float fa = falloff+1.0; float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); dist_atten *= dist_atten; |