diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred')
| -rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 25 | 
1 files changed, 17 insertions, 8 deletions
| diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ddd69befc3..e1e035411b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -284,12 +284,13 @@ void main()  	{  		// the old infinite-sky shiny reflection  		// -		vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz)); -		float sa = dot(refnorm, vary_light.xyz); +		vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); +		float sa = dot(refnormpersp, vary_light.xyz);  		vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a;  		// screen-space cheap fakey reflection map  		// +		vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));  		depth -= 0.5; // unbias depth  		// first figure out where we'll make our 2D guess from  		vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; @@ -300,12 +301,16 @@ void main()  		// The goal of the blur is to soften reflections in surfaces  		// with low shinyness, and also to disguise our lameness.  		float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0 -		ref2d += normalize(ref2d)*14.0*(1.0-spec.a)*(checkerboard-0.5); +		float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5); +		ref2d += vec2(checkoffset, checkoffset);  		ref2d += tc.xy; // use as offset from destination -		// get attributes from the 2D guess point +		// Get attributes from the 2D guess point. +		// We average two samples of diffuse (not of anything else) per +		// pixel to try to reduce aliasing some more. +		vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb + +				     texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);  		float refdepth = texture2DRect(depthMap, ref2d).a;  		vec3 refpos = getPosition_d(ref2d, refdepth).xyz; -		vec3 refcol = texture2DRect(diffuseRect, ref2d).rgb;  		float refshad = texture2DRect(lightMap, ref2d).r;  		vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0);  		// figure out how appropriate our guess actually was @@ -313,10 +318,14 @@ void main()  		// darken reflections from points which face away from the reflected ray - our guess was a back-face  		//refapprop *= step(dot(refnorm, refn), 0.0);  		refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant -		// get appropriate light strength for guess-point -		float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad); +		// get appropriate light strength for guess-point. +		// reflect light direction to increase the illusion that +		// these are reflections. +		vec3 reflight = reflect(lightnorm.xyz, norm.xyz); +		float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad);  		// apply sun color to guess-point, dampen according to inappropriateness of guess -		vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop; +		float refmod = min(refapprop, reflit); +		vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;  		vec3 ssshiny = (refprod * spec.a);  		// add the two types of shiny together | 
