summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/lighting
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-05-28 14:36:00 -0700
committerGraham Linden <graham@lindenlab.com>2019-05-28 14:36:00 -0700
commit3d9bd0fb8291ad3de4aaa20100149bd45680538b (patch)
tree48e7e9ea75a8d98d4e79bf49f0c7cf961a9afb76 /indra/newview/app_settings/shaders/class1/lighting
parent63ecb7325e77bf3ca568788a4557045054a4520b (diff)
SL-10969, SL-11073
Modify forward projector lighting to use falloff like the deferred lights. Make tex cache not evaluate evictions for size during validation passes.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/lighting')
-rw-r--r--indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl28
1 files changed, 17 insertions, 11 deletions
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
index d5448a1d31..2762a35403 100644
--- a/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl
@@ -28,32 +28,38 @@
float calcDirectionalLight(vec3 n, vec3 l)
{
- float a = max(dot(n,normalize(l)),0.0);
+ float a = max(dot(n,l),0.0);
return a;
}
-
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
{
//get light vector
vec3 lv = lp.xyz-v;
//get distance
- float d = length(lv);
+ float dist = length(lv);
+
+ if (dist > la)
+ {
+ return 0;
+ }
//normalize light vector
- lv *= 1.0/d;
-
- //distance attenuation
- float da = clamp(1.0/(la * d), 0.0, 1.0);
-
+ lv = normalize(lv);
+
+ fa += 1.0;
+ float dist_atten = min(1.0 - (dist-1.0*(1.0 - fa))/fa, 1.0);
+
+ float da = max(dot(n, lv), 0.0);
+
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
- da *= calcDirectionalLight(n, lv);
+ da *= dist_atten;
- return da;
+ return da;
}