From 69befdfb34db1a18170de5e75f3076e4cbe5dc53 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 5 Mar 2010 10:49:52 -0600 Subject: Fix for sun specular highlights showing up in shadow when diffuse ambiance greater than 0. --- indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 531f7376a3..249ac7ef9b 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -275,7 +275,7 @@ void main() { 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; + col.rgb += vary_SunlitColor*scol_ambocc.r*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a; } col = atmosLighting(col); -- cgit v1.2.3 From 32d0d01e864409d966430d005e62869564902b12 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 19 Mar 2010 18:14:17 -0500 Subject: RenderDeferredSSAO works as an independent setting -- decoupled shadows from SSAO. --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 249ac7ef9b..589a292751 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -11,6 +11,7 @@ uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; +uniform sampler2DRect depthMap; uniform sampler2D noiseMap; uniform samplerCube environmentMap; uniform sampler2D lightFunc; @@ -41,7 +42,6 @@ uniform vec3 env_mat[3]; uniform vec4 shadow_clip; uniform mat3 ssao_effect_mat; -uniform sampler2DRect depthMap; uniform mat4 inv_proj; uniform vec2 screen_res; @@ -282,13 +282,5 @@ void main() col = scaleSoftClip(col); gl_FragColor.rgb = col; - - //gl_FragColor.rgb = gi_col.rgb; gl_FragColor.a = 0.0; - - //gl_FragColor.rg = scol_ambocc.rg; - //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb; - //gl_FragColor.rgb = norm.rgb*0.5+0.5; - //gl_FragColor.rgb = vec3(ambocc); - //gl_FragColor.rgb = vec3(scol); } -- cgit v1.2.3 From 61a47a0f626830cef6c430780f69b5c9ed2d321e 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/class2/deferred/softenLightF.glsl | 48 ++++++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 589a292751..c5530c5f59 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -55,9 +55,8 @@ vec3 vary_AmblitColor; vec3 vary_AdditiveColor; vec3 vary_AtmosAttenuation; -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); @@ -68,6 +67,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; @@ -251,7 +256,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; @@ -271,11 +277,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_ambocc.r*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_ambocc.r*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 42b7edb0f1d7e18fae87aa67cbcbca06e8ee1969 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/class2/deferred/softenLightF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index c5530c5f59..9305d77ddb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -287,6 +287,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 @@ -301,7 +302,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 d6cc8b9226d78addd85ef5f2095b230a3a426ad3 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/class2/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9305d77ddb..78e4c179d7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -289,7 +289,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 a6d45be78af9e5ef547fa594c284a878bdf19ffb 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/class2/deferred/softenLightF.glsl | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 78e4c179d7..5769288a36 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -290,6 +290,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 8294a543625e24ffa239e0d838b4f5a86e527efe 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/class2/deferred/softenLightF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 5769288a36..922a07c306 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -289,7 +289,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 @@ -298,6 +298,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 e9d8427d0542ebd147ad9680deba61e283f032ac 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. --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 922a07c306..d6fbae7b22 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -281,12 +281,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_ambocc.r*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; @@ -311,9 +312,13 @@ 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, lightnorm.xyz), 0.0), refshad); + // 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 45a99b8d0d061e5c703141e51f19579b0de00f02 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/class2/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index d6fbae7b22..00a6a9dcb5 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -315,7 +315,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 429beb3049dd0bac811de2faf4501f2fab597d2f 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/class2/deferred/softenLightF.glsl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 00a6a9dcb5..dbccb7fb8b 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -298,12 +298,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 f3d4648ef5c670d519945ca72958e161d5aa12f4 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/class2/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index dbccb7fb8b..1fd54b5607 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -298,7 +298,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 bcf60463c90f65caf13bcb94e2d4a77bee07fe8e 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/class2/deferred/softenLightF.glsl | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 1fd54b5607..2982cd3e09 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -298,17 +298,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 31f8565e35b1759a6f0d82141ca2538a40fc39c4 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/class2/deferred/softenLightF.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 2982cd3e09..28cfc6322e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -298,7 +298,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 - 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. @@ -324,6 +324,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 a8e51a64d21f34710eb7de8f06d1e0dc4bf4951a 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/class2/deferred/softenLightF.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 28cfc6322e..67ef3d5280 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -269,6 +269,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); @@ -284,6 +285,7 @@ void main() 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; + glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb); // screen-space cheap fakey reflection map // @@ -334,5 +336,5 @@ void main() col = scaleSoftClip(col); gl_FragColor.rgb = col; - gl_FragColor.a = 0.0; + gl_FragColor.a = glowresult; } -- cgit v1.2.3 From 2101531e7f04662ad23f33bad1e4642b6e47bb2c 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/class2/deferred/softenLightF.glsl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 67ef3d5280..28cfc6322e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -269,7 +269,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); @@ -285,7 +284,6 @@ void main() 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; - glowresult = 0.08 * dot(dumbshiny.rgb, spec.rgb); // screen-space cheap fakey reflection map // @@ -336,5 +334,5 @@ void main() col = scaleSoftClip(col); gl_FragColor.rgb = col; - gl_FragColor.a = glowresult; + gl_FragColor.a = 0.0; } -- cgit v1.2.3 From e996eab27850d635461e919549060da569e9dc6b 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/class2/deferred/softenLightF.glsl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 28cfc6322e..bc84720b86 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -285,6 +285,7 @@ void main() float sa = dot(refnormpersp, vary_light.xyz); vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a; + /* // screen-space cheap fakey reflection map // vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz)); @@ -325,6 +326,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 12d3ba4baee93bcb024fbeee0d6f05df6d02935f 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/class2/deferred/softenLightF.glsl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index bc84720b86..fd6ae2b960 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -258,7 +258,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); @@ -310,7 +311,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