diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ae579d7f85..ecb1d599de 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -121,7 +121,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec fa += 1.0f; float dist_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f; dist_atten *= dist_atten; - dist_atten *= 2.0f; + dist_atten *= 2.0; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -140,9 +140,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); -#ifndef NO_AMBIANCE col.rgb += amb_da * 0.5 * light_col * diffuse; -#endif // no spec for alpha shader... } @@ -164,22 +162,26 @@ void main() shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); #endif +#ifdef USE_DIFFUSE_TEX + vec4 diffuse_linear = texture2D(diffuseMap,vary_texcoord0.xy); +#endif + #ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); -#else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy); #endif + vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); + #ifdef FOR_IMPOSTOR vec4 color; - color.rgb = diff.rgb; + color.rgb = diffuse_srgb.rgb; color.a = 1.0; #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diffuse_srgb.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diffuse_srgb.a; #endif // Insure we don't pollute depth with invis pixels in impostor rendering @@ -191,16 +193,12 @@ void main() #else #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diffuse_linear.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diffuse_linear.a; #endif - vec3 gamma_diff = diff.rgb; - - diff.rgb = srgb_to_linear(diff.rgb); - vec3 sunlit; vec3 amblit; vec3 additive; @@ -217,7 +215,7 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); - vec4 color = vec4(0,0,0,0); + vec4 color = vec4(0.0); color.rgb = amblit; color.a = final_alpha; @@ -225,6 +223,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; + ambient = max(getAmbientClamp(), ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; @@ -237,14 +236,12 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diff.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; - color.rgb = mix(diff.rgb, color.rgb, final_alpha); - - //color.rgb = srgb_to_linear(color.rgb); - + //color.rgb = mix(diffuse_srgb.rgb, color.rgb, final_alpha); + color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); @@ -252,7 +249,10 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.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 * 0.5); + // 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 * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -262,15 +262,29 @@ vec3 post_atmo = color.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) + // sum local light contrib in linear colorspace + color.rgb += light.rgb; + + // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); - color.rgb += light.rgb; -#endif + +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = vec3(final_da); +//color.rgb = post_ambient; +//color.rgb = post_sunlight; +//color.rgb = sun_contrib; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = post_diffuse; +//color.rgb = post_atmo; #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); -#endif +#endif // WATER_FOG +#endif frag_color = color; } |