diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
4 files changed, 50 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 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 eebb0a5fe5..c6ba489d52 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 @@ -180,7 +184,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; @@ -218,14 +222,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) @@ -234,9 +240,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; @@ -298,10 +301,10 @@ void main() if (emissive_brightness >= 1.0) { -#ifdef HAS_SPECULAR_MAP +/*#ifdef HAS_SPECULAR_MAP // Note: We actually need to adjust all 4 channels not just .rgb final_color *= 0.666666; -#endif +#endif*/ color.rgb = final_color.rgb; al = vertex_color.a; } @@ -320,11 +323,12 @@ void main() if (emissive_brightness >= 1.0) { // fullbright = diffuse texture pass-through, no lighting - frag_color = diffuse_srgb; + color = diffuse_linear.rgb; + al = diffuse_linear.a; } else { - //forward rendering, output just lit RGBA + //forward rendering, output just lit sRGBA vec3 pos = vary_position; float shadow = 1.0f; @@ -349,13 +353,14 @@ 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 = additive + (min(da, shadow) * sunlit); + vec3 sun_contrib = da * sunlit; #if !defined(AMBIENT_KILL) color.rgb = amblit; @@ -367,11 +372,7 @@ void main() #endif color.rgb *= diffuse_linear.rgb; // SL-12006 - - // ad-hoc brighten and de-saturate (normal-mapped only), to match windlight - SL-12638 - color.rgb = desat(color.rgb, 0.33 * (eep_bump_gain - 1.0)); - color.rgb *= eep_bump_gain; - + float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -391,9 +392,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 @@ -418,9 +419,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); @@ -444,23 +442,23 @@ void main() color = scaleSoftClipFrag(color); - // (only) post-deferred needs inline gamma correction - color.rgb = linear_to_srgb(color.rgb); - -#ifdef WATER_FOG +/*#ifdef WATER_FOG vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); color.rgb = temp.rgb; al = temp.a; -#endif - - frag_color.rgb = color.rgb; - frag_color.a = al; +#endif*/ } -#else // if DIFFUSE_ALPHA_MODE_BLEND ... + // (only) post-deferred needs inline gamma correction + color.rgb = linear_to_srgb(color.rgb); + + frag_color = vec4(color, al); + +#else // if DIFFUSE_ALPHA_MODE_BLEND ... + // 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/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; } |