summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl57
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl30
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl66
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/lighting/lightFuncV.glsl28
-rw-r--r--indra/newview/app_settings/shaders/class1/objects/previewV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl14
8 files changed, 123 insertions, 91 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);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
index e4d96a0028..bbdc8fdd1c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaNoColorV.glsl
@@ -55,35 +55,7 @@ uniform vec3 light_direction[8];
uniform vec3 light_attenuation[8];
uniform vec3 light_diffuse[8];
-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 = dot(lv,lv);
-
- float da = 0.0;
-
- if (d > 0.0 && la > 0.0 && fa > 0.0)
- {
- //normalize light vector
- lv = normalize(lv);
-
- //distance attenuation
- float dist2 = d/la;
- da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
-
- // 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);
- }
-
- return da;
-}
+float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight);
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index b599b6d2fc..c3ca9a6904 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -88,17 +88,19 @@ float getAmbientClamp();
vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance)
{
- vec3 col = vec3(0);
+ 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;
- /*vec4 proj_tc = proj_mat * lp;
+ dist /= la;
+
+ /* clip to projector bounds
+ vec4 proj_tc = proj_mat * lp;
if (proj_tc.z < 0
|| proj_tc.z > 1
@@ -110,35 +112,42 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
return col;
}*/
- if (d > 0.0 && la > 0.0 && fa > 0.0)
+ 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);
-
- float lit = max(da * dist_atten, 0.0);
+ da *= dot(n, lv);
+
+ float lit = 0.0f;
float amb_da = ambiance;
- if (lit > 0)
- {
- col = light_col*lit*diffuse;
- amb_da += (da*0.5 + 0.5) * ambiance;
+ 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 += (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;
if (spec.a > 0.0)
@@ -217,8 +226,15 @@ void main()
{
vec2 pos_screen = vary_texcoord0.xy;
- vec4 diffuse_linear = texture2D(diffuseMap, vary_texcoord0.xy);
- vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a);
+ vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy);
+
+#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
+ vec4 diffuse_srgb = diffuse_tap;
+ vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_tap.a);
+#else
+ vec4 diffuse_linear = diffuse_tap;
+ vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_tap.a);
+#endif
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK)
if (diffuse_linear.a < minimum_alpha)
@@ -331,7 +347,7 @@ 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;
@@ -358,7 +374,9 @@ vec3 post_diffuse = color.rgb;
vec3 sp = sun_contrib*scol / 16.0f;
sp = clamp(sp, vec3(0), vec3(1));
bloom = dot(sp, sp) / 6.0;
+#if !defined(SUNLIGHT_KILL)
color += sp * spec.rgb;
+#endif
}
}
@@ -371,8 +389,9 @@ vec3 post_spec = color.rgb;
vec3 reflected_color = textureCube(environmentMap, env_vec).rgb;
+#if !defined(SUNLIGHT_KILL)
color = mix(color.rgb, reflected_color, envIntensity);
-
+#endif
float cur_glare = max(reflected_color.r, reflected_color.g);
cur_glare = max(cur_glare, reflected_color.b);
cur_glare *= envIntensity*4.0;
@@ -382,13 +401,12 @@ vec3 post_spec = color.rgb;
vec3 post_env = color.rgb;
color = atmosFragLighting(color, additive, atten);
- color = scaleSoftClipFrag(color);
-
-vec3 post_atmo = color.rgb;
//convert to linear space before adding local lights
color = srgb_to_linear(color);
+vec3 post_atmo = color.rgb;
+
vec3 npos = normalize(-pos.xyz);
vec3 light = vec3(0,0,0);
@@ -410,6 +428,8 @@ vec3 post_atmo = color.rgb;
color.rgb += light.rgb;
#endif
+ color = scaleSoftClipFrag(color);
+
// (only) post-deferred needs inline gamma correction
color.rgb = linear_to_srgb(color.rgb);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index c7426788c4..39d14314cc 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -153,7 +153,9 @@ vec3 post_diffuse = color.rgb;
vec3 sp = sun_contrib*scontrib / 16.0;
sp = clamp(sp, vec3(0), vec3(1));
bloom += dot(sp, sp) / 6.0;
+#if !defined(SUNLIGHT_KILL)
color += sp * spec.rgb;
+#endif
}
}
@@ -167,15 +169,19 @@ vec3 post_diffuse = color.rgb;
{ //add environmentmap
vec3 env_vec = env_mat * refnormpersp;
vec3 reflected_color = textureCube(environmentMap, env_vec).rgb;
+#if !defined(SUNLIGHT_KILL)
color = mix(color.rgb, reflected_color, envIntensity);
+#endif
}
vec3 post_env = color.rgb;
if (norm.w < 1)
{
+#if !defined(SUNLIGHT_KILL)
color = atmosFragLighting(color, additive, atten);
color = scaleSoftClipFrag(color);
+#endif
}
vec3 post_atmo = color.rgb;
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;
}
diff --git a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
index 7f3f84398b..88959266c8 100644
--- a/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
+++ b/indra/newview/app_settings/shaders/class1/objects/previewV.glsl
@@ -52,7 +52,7 @@ float calcDirectionalLight(vec3 n, vec3 l)
}
-float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
+float calcLocalLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight)
{
//get light vector
vec3 lv = lp.xyz-v;
@@ -91,8 +91,8 @@ void main()
// Collect normal lights (need to be divided by two, as we later multiply by 2)
col.rgb += light_diffuse[1].rgb * calcDirectionalLight(norm, light_position[1].xyz);
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].z);
+ col.rgb += light_diffuse[2].rgb*calcLocalLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].z);
+ col.rgb += light_diffuse[3].rgb*calcLocalLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].z);
vertex_color = col*color;
}
diff --git a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
index 8795d69a3a..30ca88afd2 100644
--- a/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class2/lighting/sumLightsV.glsl
@@ -24,7 +24,7 @@
*/
float calcDirectionalLight(vec3 n, vec3 l);
-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);
vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
@@ -40,8 +40,8 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color)
// Collect normal lights (need to be divided by two, as we later multiply by 2)
col.rgb += light_diffuse[1].rgb * calcDirectionalLight(norm, light_position[1].xyz);
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].z);
+ col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
+ col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
col.rgb = scaleDownLight(col.rgb);
#if defined(LOCAL_LIGHT_KILL)
@@ -50,6 +50,7 @@ i#endif
// Add windlight lights
col.rgb += atmosAffectDirectionalLight(calcDirectionalLight(norm, light_position[0].xyz));
+
#if !defined(SUNLIGHT_KILL)
col.rgb = min(col.rgb*color.rgb, 1.0);
#endif
diff --git a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
index 38dd850296..4b663dd5b2 100644
--- a/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
+++ b/indra/newview/app_settings/shaders/class3/lighting/sumLightsV.glsl
@@ -25,7 +25,7 @@
float calcDirectionalLight(vec3 n, vec3 l);
-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);
vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
@@ -42,12 +42,12 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color)
// Collect normal lights (need to be divided by two, as we later multiply by 2)
// Collect normal lights
- col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].z);
- col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].z);
- col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].z);
- col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].z);
- col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].z);
- col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].z);
+ col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
+ col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
+ col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
+ col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
+ col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
+ col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
col.rgb += light_diffuse[1].rgb*calcDirectionalLight(norm, light_position[1].xyz);
col.rgb = scaleDownLight(col.rgb);