summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl48
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl10
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl13
6 files changed, 49 insertions, 47 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 546a502ee1..814d5036db 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -22,7 +22,9 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+
+//class1/deferred/alphaF.glsl
+
#extension GL_ARB_texture_rectangle : enable
/*[EXTRA_CODE_HERE]*/
@@ -51,7 +53,7 @@ VARYING vec2 vary_texcoord0;
VARYING vec3 vary_norm;
#ifdef USE_VERTEX_COLOR
-VARYING vec4 vertex_color;
+VARYING vec4 vertex_color; //vertex color should be treated as sRGB
#endif
uniform mat4 proj_mat;
@@ -190,7 +192,7 @@ void main()
float final_alpha = diffuse_srgb.a * vertex_color.a;
diffuse_srgb.rgb *= vertex_color.rgb;
- diffuse_linear.rgb *= vertex_color.rgb;
+ diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb);
// Insure we don't pollute depth with invis pixels in impostor rendering
//
@@ -207,7 +209,7 @@ void main()
#ifdef USE_VERTEX_COLOR
final_alpha *= vertex_color.a;
diffuse_srgb.rgb *= vertex_color.rgb;
- diffuse_linear.rgb *= vertex_color.rgb;
+ diffuse_linear.rgb = srgb_to_linear(diffuse_srgb.rgb);
#endif
vec3 sunlit;
@@ -249,7 +251,7 @@ vec3 post_ambient = color.rgb;
vec3 post_sunlight = color.rgb;
- color.rgb *= diffuse_srgb.rgb;
+ color.rgb *= diffuse_linear.rgb;
vec3 post_diffuse = color.rgb;
@@ -258,10 +260,7 @@ vec3 post_diffuse = color.rgb;
vec3 post_atmo = color.rgb;
vec4 light = vec4(0,0,0,0);
-
- // 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);
LIGHT_LOOP(1)
@@ -298,7 +297,7 @@ vec3 post_atmo = color.rgb;
#endif // WATER_FOG
#endif
-
+
frag_color = color;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index 0829968dd1..18293f4c11 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -25,6 +25,10 @@
/*[EXTRA_CODE_HERE]*/
+//class1/deferred/materialF.glsl
+
+// This shader is used for both writing opaque/masked content to the gbuffer and writing blended content to the framebuffer during the alpha pass.
+
#define DIFFUSE_ALPHA_MODE_NONE 0
#define DIFFUSE_ALPHA_MODE_BLEND 1
#define DIFFUSE_ALPHA_MODE_MASK 2
@@ -172,7 +176,7 @@ out vec4 frag_data[3];
#endif
#endif
-uniform sampler2D diffuseMap;
+uniform sampler2D diffuseMap; //always in sRGB space
#ifdef HAS_NORMAL_MAP
uniform sampler2D bumpMap;
@@ -210,14 +214,16 @@ void main()
vec2 pos_screen = vary_texcoord0.xy;
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)
+//#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);
-#else
+/*#else
vec4 diffuse_linear = diffuse_tap;
vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a);
-#endif
+#endif*/
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK)
if (diffuse_linear.a < minimum_alpha)
@@ -226,9 +232,6 @@ void main()
}
#endif
- diffuse_linear.rgb *= vertex_color.rgb;
- diffuse_srgb.rgb *= linear_to_srgb(vertex_color.rgb);
-
#ifdef HAS_SPECULAR_MAP
vec4 spec = texture2D(specularMap, vary_texcoord2.xy);
spec.rgb *= specular_color.rgb;
@@ -303,7 +306,7 @@ void main()
#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND)
{
- //forward rendering, output just lit RGBA
+ //forward rendering, output just lit sRGBA
vec3 pos = vary_position;
float shadow = 1.0f;
@@ -328,11 +331,12 @@ void main()
vec3 refnormpersp = normalize(reflect(pos.xyz, norm));
- float da = dot(norm, normalize(light_dir));
- da = clamp(da, 0.0, 1.0); // No negative light contributions
+ float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0);
- // ambient weight varies from 0.75 at max direct light to 1.0 with sun at grazing angle
- float ambient = 1.0 - (0.25 * da * da);
+ float ambient = da;
+ ambient *= 0.5;
+ ambient *= ambient;
+ ambient = (1.0 - ambient);
vec3 sun_contrib = min(da, shadow) * sunlit;
@@ -345,7 +349,7 @@ void main()
color.rgb += sun_contrib;
#endif
- color.rgb *= diffuse_srgb.rgb;
+ color.rgb *= diffuse_linear.rgb;
float glare = 0.0;
@@ -367,9 +371,9 @@ void main()
if (nh > 0.0)
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
- vec3 sp = sun_contrib*scol / 16.0f;
+ vec3 sp = sun_contrib*scol / 6.0f;
sp = clamp(sp, vec3(0), vec3(1));
- bloom = dot(sp, sp) / 6.0;
+ bloom = dot(sp, sp) / 4.0;
#if !defined(SUNLIGHT_KILL)
color += sp * spec.rgb;
#endif
@@ -394,9 +398,6 @@ void main()
color = atmosFragLighting(color, additive, atten);
- //convert to linear space before adding local lights
- color = srgb_to_linear(color);
-
vec3 npos = normalize(-pos.xyz);
vec3 light = vec3(0,0,0);
@@ -420,9 +421,6 @@ void main()
color = scaleSoftClipFrag(color);
- // (only) post-deferred needs inline gamma correction
- color.rgb = linear_to_srgb(color.rgb);
-
#ifdef WATER_FOG
vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al));
color.rgb = temp.rgb;
@@ -430,13 +428,15 @@ void main()
#endif
}
- frag_color.rgb = color.rgb;
- frag_color.a = al;
+
+ color.rgb = linear_to_srgb(color.rgb);
+
+ frag_color = vec4(color, al);
#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer
// deferred path
- frag_data[0] = final_color;
+ frag_data[0] = vec4(linear_to_srgb(final_color.rgb), final_color.a); //gbuffer is sRGB
frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent.
frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity.
#endif
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index dcc3750a8f..0d1cc81786 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -102,7 +102,8 @@ void main()
dist_atten *= dist_atten;
// Tweak falloff slightly to match pre-EEP attenuation
- dist_atten *= 2.2;
+ // NOTE: this magic number also shows up in a great many other places, search for dist_atten *= to audit
+ dist_atten *= 2.0;
dist_atten *= noise;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
index 9f519708a2..966c73ef24 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl
@@ -44,7 +44,8 @@ vec3 linear_to_srgb(vec3 cl);
void main()
{
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord);
- diff.rgb = pow(diff.rgb, vec3(display_gamma));
+ //diff.rgb = pow(diff.rgb, vec3(display_gamma));
+ diff.rgb = linear_to_srgb(diff.rgb);
frag_color = diff;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 705cc2f04e..da2eb47e3b 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_srgb.rgb;
+ color.rgb *= diffuse_linear.rgb;
vec3 post_diffuse = color.rgb;
@@ -157,7 +157,7 @@ vec3 post_diffuse = color.rgb;
#ifdef WATER_FOG
color.rgb += diffuse_srgb.rgb * diffuse_srgb.a * 0.25;
#else
- color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
+ color.rgb = mix(color.rgb, diffuse_linear.rgb, diffuse_linear.a);
#endif
if (envIntensity > 0.0)
@@ -201,7 +201,7 @@ vec3 post_atmo = color.rgb;
// 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);
+ //color.rgb = srgb_to_linear(color.rgb);
}
// linear debuggables
@@ -209,7 +209,7 @@ vec3 post_atmo = color.rgb;
//color.rgb = vec3(ambient);
//color.rgb = vec3(scol);
//color.rgb = diffuse_linear.rgb;
-
+
frag_color.rgb = color.rgb;
- frag_color.a = bloom;
+ frag_color.a = 0.0; //bloom;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 593706867d..bacdb6f70f 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -127,7 +127,7 @@ vec3 post_ambient = color.rgb;
vec3 post_sunlight = color.rgb;
- color.rgb *= diffuse_srgb.rgb;
+ color.rgb *= diffuse_linear.rgb;
vec3 post_diffuse = color.rgb;
@@ -162,8 +162,10 @@ vec3 post_diffuse = color.rgb;
vec3 post_spec = color.rgb;
-#ifndef WATER_FOG
- color.rgb = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a);
+#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)
@@ -206,9 +208,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
@@ -217,6 +216,8 @@ vec3 post_atmo = color.rgb;
//color.rgb = vec3(scol);
//color.rgb = diffuse_linear.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.a = bloom;
}