summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl18
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl2
13 files changed, 54 insertions, 52 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 814d5036db..e38eeab370 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -251,7 +251,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;
@@ -261,6 +261,11 @@ vec3 post_atmo = color.rgb;
vec4 light = vec4(0,0,0,0);
+ color.rgb = scaleSoftClipFrag(color.rgb);
+
+ //convert to linear before applying local lights
+ 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);
LIGHT_LOOP(1)
@@ -275,9 +280,6 @@ vec3 post_atmo = color.rgb;
#if !defined(LOCAL_LIGHT_KILL)
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/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 18293f4c11..e4ebf0edee 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -117,7 +117,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
-
+
//angular attenuation
da *= dot(n, lv);
@@ -215,8 +215,7 @@ void main()
vec4 diffuse_tap = texture2D(diffuseMap, vary_texcoord0.xy);
diffuse_tap.rgb *= vertex_color.rgb;
- //diffuse_tap = vec4(1,1,1,1);
-
+
//#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
vec4 diffuse_srgb = diffuse_tap;
vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a);
@@ -349,7 +348,7 @@ void main()
color.rgb += sun_contrib;
#endif
- color.rgb *= diffuse_linear.rgb;
+ color.rgb *= diffuse_srgb.rgb;
float glare = 0.0;
@@ -397,11 +396,15 @@ void main()
}
color = atmosFragLighting(color, additive, atten);
+ color = scaleSoftClipFrag(color);
vec3 npos = normalize(-pos.xyz);
vec3 light = vec3(0,0,0);
+ //convert to linear before adding local lights
+ color.rgb = srgb_to_linear(color.rgb);
+
#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w );
LIGHT_LOOP(1)
@@ -419,8 +422,9 @@ void main()
color.rgb += light.rgb;
#endif
- color = scaleSoftClipFrag(color);
-
+//convert to srgb as this color is being written post gamma correction
+ color.rgb = linear_to_srgb(color.rgb);
+
#ifdef WATER_FOG
vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al));
color.rgb = temp.rgb;
@@ -429,8 +433,6 @@ void main()
}
- color.rgb = linear_to_srgb(color.rgb);
-
frag_color = vec4(color, al);
#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index a690cc45a8..9bba45bc4e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -163,15 +163,19 @@ void main()
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);
+ float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
dist_atten *= dist_atten;
dist_atten *= 2.0;
+
if (dist_atten <= 0.0)
{
discard;
}
+ float noise = texture2D(noiseMap, frag.xy/128.0).b;
+ dist_atten *= noise;
+
lv = proj_origin-pos.xyz;
lv = normalize(lv);
float da = dot(norm, lv);
@@ -179,12 +183,13 @@ void main()
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
// SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space.
- // We can't switch to linear here unless we do it everywhere
- //diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
+ // We can't switch to linear here unless we do it everywhere*
+ // *gbuffer is sRGB, convert to linear whenever sampling from it
+ diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec3 dlit = vec3(0, 0, 0);
- float noise = texture2D(noiseMap, frag.xy/128.0).b;
+
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&
@@ -203,7 +208,7 @@ void main()
dlit = color.rgb * plcol.rgb * plcol.a;
- lit = da * dist_atten * noise;
+ lit = da * dist_atten;
col = dlit*lit*diff_tex;
amb_da += (da*0.5)*proj_ambiance;
@@ -245,7 +250,7 @@ void main()
col += dlit*scol*spec.rgb;
//col += spec.rgb;
}
- }
+ }
if (envIntensity > 0.0)
{
@@ -277,6 +282,7 @@ void main()
}
#endif
+ //output linear, sum of lights will be gamma corrected later
frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
index 966c73ef24..cd37a34e0d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
@@ -43,6 +43,7 @@ vec3 linear_to_srgb(vec3 cl);
void main()
{
+ //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB)
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
//diff.rgb = pow(diff.rgb, vec3(display_gamma));
diff.rgb = linear_to_srgb(diff.rgb);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index da2eb47e3b..54abd56625 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -119,7 +119,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;
@@ -154,11 +154,7 @@ vec3 post_diffuse = color.rgb;
vec3 post_spec = color.rgb;
-#ifdef WATER_FOG
- color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25;
-#else
color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a);
-#endif
if (envIntensity > 0.0)
{ //add environmentmap
@@ -199,9 +195,6 @@ vec3 post_atmo = color.rgb;
//color.rgb = post_env;
//color.rgb = post_atmo;
-// convert to linear as fullscreen lights need to sum in linear colorspace
-// and will be gamma (re)corrected downstream...
- //color.rgb = srgb_to_linear(color.rgb);
}
// linear debuggables
@@ -209,7 +202,10 @@ vec3 post_atmo = color.rgb;
//color.rgb = vec3(ambient);
//color.rgb = vec3(scol);
//color.rgb = diffuse_linear.rgb;
+
+ // convert to linear as fullscreen lights need to sum in linear colorspace
+ // and will be gamma (re)corrected downstream...
- frag_color.rgb = color.rgb;
- frag_color.a = 0.0; //bloom;
+ frag_color.rgb = srgb_to_linear(color.rgb);
+ frag_color.a = bloom;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index b7bc92c460..6b6eed9db8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -44,10 +44,6 @@ VARYING vec4 vary_texcoord1;
vec2 encode_normal(vec3 n);
-#ifdef WATER_FOG
-vec4 applyWaterFogView(vec3 pos, vec4 c);
-#endif
-
void main()
{
/// Note: This should duplicate the blending functionality currently used for the terrain rendering.
@@ -63,10 +59,6 @@ void main()
vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
outColor.a = 0.0; // yes, downstream atmospherics
-#ifdef WATER_FOG
- outColor = applyWaterFogView(pos.xyz, outColor);
- outColor.a = 1.0; // no downstream atmo
-#endif
frag_data[0] = outColor;
frag_data[1] = vec4(0.0,0.0,0.0,-1.0);
diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
index e5f1e11180..dcb02bd1c1 100644
--- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
+++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl
@@ -46,6 +46,7 @@ float getAmbientClamp()
return 1.0f;
}
+
void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao) {
vec3 P = inPositionEye;
@@ -123,7 +124,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
temp2.x *= sun_moon_glow_factor;
vec4 amb_color = ambient_color;
-
+
//increase ambient when there are more clouds
vec4 tmpAmbient = amb_color + (vec4(1.) - amb_color) * cloud_shadow * 0.5;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 7cde67d11b..5d7a28c359 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -192,8 +192,9 @@ void main()
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
// SL-12005 Projector light pops as we get closer, more objectionable than being in wrong color space.
- // We can't switch to linear here unless we do it everywhere
- //diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
+ // We can't switch to linear here unless we do it everywhere*
+ // *gbuffer IS sRGB, convert to linear since this shader outputs linear
+ diff_tex.rgb = srgb_to_linear(diff_tex.rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);
@@ -296,6 +297,7 @@ void main()
//not sure why, but this line prevents MATBUG-194
col = max(col, vec3(0.0));
- frag_color.rgb = col;
+ //output linear
+ frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index bacdb6f70f..9ebacd59c7 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -106,7 +106,7 @@ void main()
vec3 atten;
calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true);
-
+
float ambient = da;
ambient *= 0.5;
ambient *= ambient;
@@ -127,7 +127,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;
@@ -162,11 +162,7 @@ vec3 post_diffuse = color.rgb;
vec3 post_spec = color.rgb;
-#ifdef WATER_FOG
- color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25;
-#else
color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a);
-#endif
if (envIntensity > 0.0)
{ //add environmentmap
@@ -218,6 +214,6 @@ vec3 post_atmo = color.rgb;
//output linear RGB as lights are summed up in linear space and then gamma corrected prior to the
//post deferred passes
- frag_color.rgb = color.rgb;
+ frag_color.rgb = srgb_to_linear(color.rgb);
frag_color.a = bloom;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 77f6e6f7ac..5ab0b5c5b4 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -189,7 +189,7 @@ void main()
lv = normalize(lv);
float da = dot(norm, lv);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);
vec3 dlit = vec3(0, 0, 0);
@@ -287,6 +287,7 @@ void main()
//not sure why, but this line prevents MATBUG-194
col = max(col, vec3(0.0));
+ //output linear colors as gamma correction happens down stream
frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index 52de7ceaad..9d62b9d180 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -183,7 +183,7 @@ void main()
vec3 col = vec3(0,0,0);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);
@@ -285,6 +285,7 @@ void main()
col = scaleDownLight(col);
+ //output linear space color as gamma correction happens down stream
frag_color.rgb = col;
frag_color.a = 0.0;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 978c25b86a..7ed9e7b4fc 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -94,7 +94,8 @@ void main()
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
- vec4 diffuse = texture2DRect(diffuseRect, tc); // linear
+ vec4 diffuse = texture2DRect(diffuseRect, tc); // sRGB
+ diffuse.rgb = srgb_to_linear(diffuse.rgb);
vec3 col;
float bloom = 0.0;
@@ -169,7 +170,8 @@ void main()
bloom = fogged.a;
#endif
}
-
+
+ //output linear since gamma correction happens down stream
frag_color.rgb = col;
frag_color.a = bloom;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index bccd819a43..56b0f4e5ce 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -182,7 +182,7 @@ void main()
vec3 col = vec3(0,0,0);
- vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
+ vec3 diff_tex = srgb_to_linear(texture2DRect(diffuseRect, frag.xy).rgb);
vec4 spec = texture2DRect(specularRect, frag.xy);