From 28618d0d3bf93790cc70da247c2a723df0778b05 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Mon, 22 Mar 2010 16:10:34 +0000 Subject: screen-space reflections mk4. generally subtle. very cheap. --- .../shaders/class3/deferred/softenLightF.glsl | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 96a083b522..265fb437ec 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -56,9 +56,8 @@ vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; uniform float gi_ambiance; -vec4 getPosition(vec2 pos_screen) -{ //get position in screen space (world units) given window coordinate and depth map - float depth = texture2DRect(depthMap, pos_screen.xy).a; +vec4 getPosition_d(vec2 pos_screen, float depth) +{ vec2 sc = pos_screen.xy*2.0; sc /= screen_res; sc -= vec2(1.0,1.0); @@ -69,6 +68,12 @@ vec4 getPosition(vec2 pos_screen) return pos; } +vec4 getPosition(vec2 pos_screen) +{ //get position in screen space (world units) given window coordinate and depth map + float depth = texture2DRect(depthMap, pos_screen.xy).a; + return getPosition_d(pos_screen, depth); +} + vec3 getPositionEye() { return vary_PositionEye; @@ -252,7 +257,8 @@ vec3 scaleSoftClip(vec3 light) void main() { vec2 tc = vary_fragcoord.xy; - vec3 pos = getPosition(tc).xyz; + float depth = texture2DRect(depthMap, tc.xy).a; + vec3 pos = getPosition_d(tc, depth).xyz; vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0; //vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz; @@ -274,11 +280,37 @@ void main() col *= diffuse.rgb; - if (spec.a > 0.0) + if (spec.a > 0.0) // specular reflection { - vec3 ref = normalize(reflect(pos.xyz, norm.xyz)); - float sa = dot(ref, vary_light.xyz); - col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a; + // the old infinite-sky shiny reflection + // + vec3 refnorm = normalize(reflect(pos.xyz, norm.xyz)); + float sa = dot(refnorm, vary_light.xyz); + vec3 dumbshiny = vary_SunlitColor*scol*texture2D(lightFunc, vec2(sa, spec.a)).a; + + // screen-space cheap fakey reflection map + // + // first figure out where we'll make our 2D guess from + vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; + // get attributes from the 2D guess point + 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 + float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos))); + // 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, vary_light.xyz), 0.0), refshad); + // apply sun color to guess-point, dampen according to inappropriateness of guess + vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop; + vec3 ssshiny = (refprod * spec.a); + + // add the two types of shiny together + col += (ssshiny + dumbshiny) * spec.rgb; } col = atmosLighting(col); -- cgit v1.2.3 From 783b0a72204f10b6d9e554bf17134e14ff90e756 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 26 Mar 2010 09:07:08 +0000 Subject: screen-space reflections: remember to unbias the value from the depth map. don't use varying version of lightnorm for lighting the reflection-guess-point. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 265fb437ec..262b34ede7 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -290,6 +290,7 @@ void main() // screen-space cheap fakey reflection map // + depth -= 0.5; // unbias depth // first figure out where we'll make our 2D guess from vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; // get attributes from the 2D guess point @@ -304,7 +305,7 @@ void main() //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, vary_light.xyz), 0.0), refshad); + float reflit = min(max(dot(refn, lightnorm.xyz), 0.0), refshad); // apply sun color to guess-point, dampen according to inappropriateness of guess vec3 refprod = (vary_SunlitColor*reflit) * refcol.rgb * refapprop; vec3 ssshiny = (refprod * spec.a); -- cgit v1.2.3 From d5c07e58c23a4c40507e4c033d502e7a5e9656a4 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Sun, 28 Mar 2010 21:45:32 +0100 Subject: ss reflections: make the guess less far from the source. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 262b34ede7..9ecb0a40ff 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -292,7 +292,7 @@ void main() // depth -= 0.5; // unbias depth // first figure out where we'll make our 2D guess from - vec2 ref2d = tc.xy + (0.5 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; + vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; // get attributes from the 2D guess point float refdepth = texture2DRect(depthMap, ref2d).a; vec3 refpos = getPosition_d(ref2d, refdepth).xyz; -- cgit v1.2.3 From e889511a0e3569620897f6ecae7727162dda5701 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Mon, 29 Mar 2010 11:30:08 +0100 Subject: ss reflections tweakage: + // Offset the guess source a little according to a trivial + // checkerboard dither function and spec.a. + // This is meant to be similar to sampling a blurred version + // of the diffuse map. LOD would be better in that regard. + // The goal of the blur is to soften reflections in surfaces + // with low shinyness, and also to disguise our lameness. --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 9ecb0a40ff..70a1c53456 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -293,6 +293,14 @@ void main() depth -= 0.5; // unbias depth // first figure out where we'll make our 2D guess from vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; + // Offset the guess source a little according to a trivial + // checkerboard dither function and spec.a. + // This is meant to be similar to sampling a blurred version + // of the diffuse map. LOD would be better in that regard. + // 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); // get attributes from the 2D guess point float refdepth = texture2DRect(depthMap, ref2d).a; vec3 refpos = getPosition_d(ref2d, refdepth).xyz; -- cgit v1.2.3 From 7ee4c5e6ffef66df30c44fd9eb662632f1b4f709 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 31 Mar 2010 18:27:50 +0100 Subject: debug ssreflection blur direction. minor. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 70a1c53456..ddd69befc3 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -292,7 +292,7 @@ void main() // depth -= 0.5; // unbias depth // first figure out where we'll make our 2D guess from - vec2 ref2d = tc.xy + (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; + vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth; // Offset the guess source a little according to a trivial // checkerboard dither function and spec.a. // This is meant to be similar to sampling a blurred version @@ -301,6 +301,7 @@ void main() // 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); + ref2d += tc.xy; // use as offset from destination // get attributes from the 2D guess point float refdepth = texture2DRect(depthMap, ref2d).a; vec3 refpos = getPosition_d(ref2d, refdepth).xyz; -- cgit v1.2.3 From ac2db4d1db16a425231ee7788c172da3b8700eaf Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 2 Apr 2010 16:03:20 +0100 Subject: apply ssreflection changes to class2 and class3 too. --- .../shaders/class3/deferred/softenLightF.glsl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ddd69befc3..ecfd9bef52 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; @@ -313,10 +314,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 = max(dot(refn, reflight.xyz), 0.0); // 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 -- cgit v1.2.3 From 286572ec90558015bfec8a7f738502b63465be3e Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 2 Apr 2010 16:09:31 +0100 Subject: ssreflection: restore the shadow factor I accidentally removed with the last update. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ecfd9bef52..aaa74eb7df 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -318,7 +318,7 @@ void main() // reflect light direction to increase the illusion that // these are reflections. vec3 reflight = reflect(lightnorm.xyz, norm.xyz); - float reflit = max(dot(refn, reflight.xyz), 0.0); + float reflit = min(max(dot(refn, reflight.xyz), 0.0), refshad); // apply sun color to guess-point, dampen according to inappropriateness of guess float refmod = min(refapprop, reflit); vec3 refprod = vary_SunlitColor * refcol.rgb * refmod; -- cgit v1.2.3 From 51ab9ae63c3c2a1d7f188fb73af1b7074331eae4 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 7 Apr 2010 10:31:56 +0100 Subject: apply latest ssreflections tweaks to class2 and class3. --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index aaa74eb7df..ef81ed1308 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -301,12 +301,19 @@ 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); + vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5); + ref2d += 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. + // --------------------- + // ^ ^ ^ ^ ^ + // a . b o c . d check=0:avg(a,b) check=1:avg(c,d) + vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb + + texture2DRect(diffuseRect, ref2d + checkoffset*2.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 -- cgit v1.2.3 From 186224ab91e53c712537887f3d08293520338250 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 16 Apr 2010 12:19:30 +0100 Subject: strengthen the fakey blur in the fakey ssreflections. (transplanted from 940e02cbe4fa2f996d11500392e71f3a00e1cfed) (transplanted from 1ee9eaf155ed897a5a7b86369c1f5160455094f0) --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ef81ed1308..45d921d861 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -301,7 +301,7 @@ 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 - vec2 checkoffset = normalize(ref2d)*5.0*(1.0-spec.a)*(checkerboard-0.5); + vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5); ref2d += checkoffset; ref2d += tc.xy; // use as offset from destination // Get attributes from the 2D guess point. -- cgit v1.2.3 From aff0a1bf84db8d77b06c5ab4e44e9d461bc77b7a Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Wed, 21 Apr 2010 14:27:54 +0100 Subject: port class1 ssreflections tweaks to class2 and class3 (transplanted from 19036fc277d88c364e957019a66b4cdf4cce8b53) --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 45d921d861..e1e035411b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -301,17 +301,14 @@ 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 - vec2 checkoffset = normalize(ref2d)*9.0*(1.0-spec.a)*(checkerboard-0.5); - ref2d += checkoffset; + 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. // We average two samples of diffuse (not of anything else) per // pixel to try to reduce aliasing some more. - // --------------------- - // ^ ^ ^ ^ ^ - // a . b o c . d check=0:avg(a,b) check=1:avg(c,d) - vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d).rgb + - texture2DRect(diffuseRect, ref2d + checkoffset*2.0).rgb); + 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; float refshad = texture2DRect(lightMap, ref2d).r; -- cgit v1.2.3 From 473df1559015de6d72a18cb12958e68fb438f2ac Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 22 Apr 2010 21:33:10 +0100 Subject: ssreflections: dampen/blur ssreflections rather more. (transplanted from 4c4ae8d8f0795244fda258c157177e2778bfc444) --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index e1e035411b..9f94b9e8ea 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -301,7 +301,8 @@ 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 - float checkoffset = 1.0 + (7.0*(1.0-spec.a))*(checkerboard-0.5); + float checkoffset = (3.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. @@ -327,6 +328,7 @@ void main() float refmod = min(refapprop, reflit); vec3 refprod = vary_SunlitColor * refcol.rgb * refmod; vec3 ssshiny = (refprod * spec.a); + ssshiny *= 0.3; // dampen it even more // add the two types of shiny together col += (ssshiny + dumbshiny) * spec.rgb; -- cgit v1.2.3 From 77155500ede52d09ef69dbf6c8d3e505d02485f7 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 23 Apr 2010 13:37:03 +0100 Subject: Restore a bit of the non-deferred renderer's sun/moon waterglow in deferred rendering. This also adds a slight pinch of glow to shiny sun-spots. So be it. (transplanted from 5a0d9e5b5cfb2ecd96685f0275ab8e999ab86263) (transplanted from 90f0ce75b2d7bb9fc03e84245db27a16508cde63) --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 9f94b9e8ea..b5c6693d3b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -272,6 +272,7 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float scol = max(scol_ambocc.r, diffuse.a); float ambocc = scol_ambocc.g; + float glowresult = 0.0; calcAtmospherics(pos.xyz, ambocc); @@ -287,6 +288,7 @@ void main() 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; + glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb); // screen-space cheap fakey reflection map // @@ -340,7 +342,7 @@ void main() gl_FragColor.rgb = col; //gl_FragColor.rgb = gi_col.rgb; - gl_FragColor.a = 0.0; + gl_FragColor.a = glowresult; //gl_FragColor.rg = scol_ambocc.rg; //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb; -- cgit v1.2.3 From ef925261ae69b71189b0df759e6f155a38a3a8f7 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Fri, 23 Apr 2010 17:35:26 +0100 Subject: Backed out changeset b379d162769e --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index b5c6693d3b..9f94b9e8ea 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -272,7 +272,6 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float scol = max(scol_ambocc.r, diffuse.a); float ambocc = scol_ambocc.g; - float glowresult = 0.0; calcAtmospherics(pos.xyz, ambocc); @@ -288,7 +287,6 @@ void main() 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; - glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb); // screen-space cheap fakey reflection map // @@ -342,7 +340,7 @@ void main() gl_FragColor.rgb = col; //gl_FragColor.rgb = gi_col.rgb; - gl_FragColor.a = glowresult; + gl_FragColor.a = 0.0; //gl_FragColor.rg = scol_ambocc.rg; //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb; -- cgit v1.2.3 From b92e0c516d31d17965e0349ff436d6db4a9a3f9e Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Thu, 6 May 2010 13:53:52 +0100 Subject: EXT-6912 FIXED Deferred Rendering - shiny objects look like a projection instead of a reflection Disable screen-space shiny while I chew on it some more. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 9f94b9e8ea..5298079af7 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -288,6 +288,7 @@ void main() 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)); @@ -329,6 +330,8 @@ void main() vec3 refprod = vary_SunlitColor * refcol.rgb * refmod; vec3 ssshiny = (refprod * spec.a); ssshiny *= 0.3; // dampen it even more + */ + vec3 ssshiny = vec3(0,0,0); // add the two types of shiny together col += (ssshiny + dumbshiny) * spec.rgb; -- cgit v1.2.3 From 940bca8ebc03d963d8384f07b4bea7c5484691a3 Mon Sep 17 00:00:00 2001 From: Tofu Linden Date: Sun, 9 May 2010 15:02:10 +0100 Subject: Rejig deferred normal-map packing a little, to double its accuracy for free. --- .../newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 5298079af7..c88edd0a60 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -259,7 +259,8 @@ void main() vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).a; vec3 pos = getPosition_d(tc, depth).xyz; - vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0; + vec3 norm = texture2DRect(normalMap, tc).xyz; + norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm //vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz; float da = max(dot(norm.xyz, vary_light.xyz), 0.0); @@ -314,7 +315,9 @@ void main() float refdepth = texture2DRect(depthMap, ref2d).a; vec3 refpos = getPosition_d(ref2d, refdepth).xyz; float refshad = texture2DRect(lightMap, ref2d).r; - vec3 refn = normalize(texture2DRect(normalMap, ref2d).rgb * 2.0 - 1.0); + vec3 refn = texture2DRect(normalMap, ref2d).rgb; + refn = vec3((refn.xy-0.5)*2.0,refn.z); // unpack norm + refn = normalize(refn); // figure out how appropriate our guess actually was float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos))); // darken reflections from points which face away from the reflected ray - our guess was a back-face -- cgit v1.2.3 From 21b1b91c448b7d148a840c06d74deabc45af1819 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 6 Oct 2010 12:53:26 -0500 Subject: ATI compatibility pass --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index a2db247331..ce32f66000 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -4,6 +4,8 @@ * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * $/LicenseInfo$ */ + +#version 120 #extension GL_ARB_texture_rectangle : enable -- cgit v1.2.3