diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightMSF.glsl')
-rw-r--r-- | indra/newview/app_settings/shaders/class2/deferred/softenLightMSF.glsl | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightMSF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightMSF.glsl index 0bae10ca7d..3b572320c3 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightMSF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightMSF.glsl @@ -255,7 +255,7 @@ void main() vec2 tc = vary_fragcoord.xy; ivec2 itc = ivec2(tc); - vec3 fcol = vec3(0,0,0); + vec4 fcol = vec4(0,0,0,0); vec2 scol_ambocc = texture2DRect(lightMap, tc).rg; float ambocc = scol_ambocc.g; @@ -270,38 +270,50 @@ void main() float da = max(dot(norm.xyz, vary_light.xyz), 0.0); vec4 diffuse = texelFetch(diffuseRect, itc, i); - vec4 spec = texelFetch(specularRect, itc, i); + vec3 col; + float bloom = 0.0; + if (diffuse.a < 0.9) + { + vec4 spec = texelFetch(specularRect, itc, i); - float amb = 0; + float amb = 0; - float scol = max(scol_ambocc.r, diffuse.a); - amb += ambocc; + float scol = max(scol_ambocc.r, diffuse.a); + amb += ambocc; - calcAtmospherics(pos.xyz, ambocc); + calcAtmospherics(pos.xyz, ambocc); + + col = atmosAmbient(vec3(0)); + col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); - vec3 col = atmosAmbient(vec3(0)); - col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)); + col *= diffuse.rgb; - col *= diffuse.rgb; + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + float sa = dot(refnormpersp, vary_light.xyz); + vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; + + // add the two types of shiny together + vec3 spec_contrib = dumbshiny * spec.rgb; + bloom = dot(spec_contrib, spec_contrib); + col += spec_contrib; + } - if (spec.a > 0.0) // specular reflection + col = atmosLighting(col); + col = scaleSoftClip(col); + + col = mix(col, diffuse.rgb, diffuse.a); + } + else { - // the old infinite-sky shiny reflection - // - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(refnormpersp, vary_light.xyz); - vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; - - // add the two types of shiny together - col += dumbshiny * spec.rgb; + col = diffuse.rgb; } - - col = atmosLighting(col); - col = scaleSoftClip(col); - fcol += col; + fcol += vec4(col, bloom); } - gl_FragColor.rgb = fcol/samples; - gl_FragColor.a = 0.0; + gl_FragColor = fcol/samples; } |