summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2022-07-15 17:29:39 -0700
committerPtolemy <ptolemy@lindenlab.com>2022-07-15 17:29:39 -0700
commit314f27d1b1701e0fdc4bb983d0f9fd4d4ed6573a (patch)
tree15b929fd434273187aa0dcc1456058dd3a418661 /indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
parent9b8751a6e425f60cf8cf661b40fec6af1e11ecf8 (diff)
SL-17702: PBR: Cleanup light shaders to use calcHalfVectors, remove da alias, and unused sa
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl36
1 files changed, 17 insertions, 19 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index e70a545a7b..680fcbfab3 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -72,9 +72,13 @@ uniform vec2 screen_res;
uniform mat4 inv_proj;
-void calcHalfVectors(vec3 h, vec3 n, vec3 v, out float nh, out float nv, out float vh);
-vec2 getScreenXY(vec4 clip_point);
+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);
+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);
+void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight );
vec3 srgb_to_linear(vec3 c);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
@@ -144,7 +148,7 @@ void main()
vec4 shd = texture2DRect(lightMap, tc);
shadow = (proj_shadow_idx == 0) ? shd.b : shd.a;
shadow += shadow_fade;
- shadow = clamp(shadow, 0.0, 1.0);
+ shadow = clamp(shadow, 0.0, 1.0);
}
float envIntensity;
@@ -172,8 +176,9 @@ void main()
}
lv = proj_origin-pos.xyz;
- lv = normalize(lv);
- float da = dot(n, lv);
+ vec3 h, l, v = -normalize(pos);
+ float nh, nl, nv, vh, lightDist;
+ calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist);
vec3 diffuse = texture2DRect(diffuseRect, tc).rgb;
vec4 spec = texture2DRect(specularRect, tc);
@@ -200,9 +205,9 @@ void main()
float amb_da = proj_ambiance;
float lit = 0.0;
- if (da > 0.0)
+ if (nl > 0.0)
{
- lit = da * dist_atten * noise;
+ lit = nl * dist_atten * noise;
float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
float lod = diff * proj_lod;
@@ -213,13 +218,13 @@ void main()
final_color = dlit*lit*diffuse*shadow;
- amb_da += (da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance;
+ amb_da += (nl*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance;
}
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
- amb_da += (da*da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance;
+ amb_da += (nl*nl*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance;
amb_da *= dist_atten * noise;
amb_da = min(amb_da, 1.0-lit);
@@ -228,22 +233,15 @@ void main()
if (spec.a > 0.0)
{
- dlit *= min(da*6.0, 1.0) * dist_atten;
- vec3 v = -normalize(pos);
-
- //vec3 ref = dot(pos+lv, n);
- vec3 h = normalize(lv + v);
- float nh, nv, vh;
- calcHalfVectors(h, n, v, nh, nv, vh);
- float sa = nh;
+ dlit *= min(nl*6.0, 1.0) * dist_atten;
float fres = pow(1 - dot(h, v), 5)*0.4+0.5;
float gtdenom = 2 * nh;
- float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
+ float gt = max(0, min(gtdenom * nv / vh, gtdenom * nl / vh));
if (nh > 0.0)
{
- float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
+ float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*nl);
vec3 speccol = dlit*scol*spec.rgb*shadow;
speccol = clamp(speccol, vec3(0), vec3(1));
final_color += speccol;