summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
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/deferred/alphaF.glsl
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/deferred/alphaF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl57
1 files changed, 42 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index cd0494dc67..2b5509400e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -88,45 +88,71 @@ float getAmbientClamp();
vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance)
{
+ vec3 col = vec3(0);
+
//get light vector
vec3 lv = lp.xyz-v;
//get distance
- float d = length(lv);
-
+ float dist = length(lv);
float da = 1.0;
- vec3 col = vec3(0);
+ if (dist > la)
+ {
+ return col;
+ }
+
+ dist /= la;
- if (d > 0.0 && la > 0.0 && fa > 0.0)
+ /* clip to projector bounds
+ vec4 proj_tc = proj_mat * lp;
+
+ if (proj_tc.z < 0
+ || proj_tc.z > 1
+ || proj_tc.x < 0
+ || proj_tc.x > 1
+ || proj_tc.y < 0
+ || proj_tc.y > 1)
+ {
+ return col;
+ }*/
+
+ fa += 1.0;
+ if (dist > 0.0 && la > 0.0 && fa > 0.0)
{
//normalize light vector
lv = normalize(lv);
//distance attenuation
- float dist = d/la;
float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
dist_atten *= dist_atten;
- //dist_atten *= 2.0f;
+ dist_atten *= 2.0f;
+
+ if (dist_atten <= 0.0)
+ {
+ return col;
+ }
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
- da *= max(dot(n, lv), 0.0);
+ da *= dot(n, lv);
- float lit = max(da * dist_atten,0.0);
+ float lit = 0.0f;
float amb_da = ambiance;
- if (lit > 0)
+ if (da > 0)
{
+ lit = max(da * dist_atten,0.0);
col = lit * light_col * diffuse;
amb_da += (da*0.5+0.5) * ambiance;
}
amb_da += (da*da*0.5 + 0.5) * ambiance;
amb_da *= dist_atten;
amb_da = min(amb_da, 1.0f - lit);
+
col.rgb += amb_da * light_col * diffuse;
// no spec for alpha shader...
@@ -150,14 +176,14 @@ void main()
#endif
#ifdef USE_DIFFUSE_TEX
- vec4 diffuse_linear = texture2D(diffuseMap,vary_texcoord0.xy);
+ vec4 diffuse_srgb = texture2D(diffuseMap,vary_texcoord0.xy);
+ vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
#endif
#ifdef USE_INDEXED_TEX
vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy);
-#endif
-
vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a);
+#endif
#ifdef FOR_IMPOSTOR
vec4 color;
@@ -229,12 +255,11 @@ vec3 post_ambient = color.rgb;
vec3 post_sunlight = color.rgb;
- color.rgb *= diffuse_linear.rgb;
+ color.rgb *= diffuse_srgb.rgb;
vec3 post_diffuse = color.rgb;
color.rgb = atmosFragLighting(color.rgb, additive, atten);
- color.rgb = scaleSoftClipFrag(color.rgb);
vec3 post_atmo = color.rgb;
@@ -243,7 +268,7 @@ vec3 post_atmo = color.rgb;
// to linear!
color.rgb = srgb_to_linear(color.rgb);
- #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
+ #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_srgb.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w);
LIGHT_LOOP(1)
LIGHT_LOOP(2)
@@ -258,6 +283,8 @@ vec3 post_atmo = color.rgb;
color.rgb += light.rgb;
#endif
+ color.rgb = scaleSoftClipFrag(color.rgb);
+
// back to sRGB as we're going directly to the final RT post-deferred gamma correction
color.rgb = linear_to_srgb(color.rgb);