From 3a8cdb5d46cd12a5aad001e4bcec5b26f6f748ce Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 20 Jun 2013 15:27:22 -0700 Subject: NORSPEC-277 WIP backout old-school normal permutation --- .../shaders/class2/deferred/softenLightF.glsl | 17 ----------------- 1 file changed, 17 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 67bac1f7c2..6e05091b57 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,22 +78,6 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -#ifdef SINGLE_FP_ONLY -vec2 encode_normal(vec3 n) -{ - vec2 sn; - sn.xy = (n.xy * vec2(0.5f,0.5f)) + vec2(0.5f,0.5f); - return sn; -} - -vec3 decode_normal (vec2 enc) -{ - vec3 n; - n.xy = (enc.xy * vec2(2.0f,2.0f)) - vec2(1.0f,1.0f); - n.z = sqrt(1.0f - dot(n.xy,n.xy)); - return n; -} -#else vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -110,7 +94,6 @@ vec3 decode_normal (vec2 enc) n.z = 1-f/2; return n; } -#endif vec4 getPosition_d(vec2 pos_screen, float depth) { -- cgit v1.2.3 From 930de04f51212195a2c7a877d235d4106f4d37e2 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Jul 2013 18:02:28 -0500 Subject: NORSPEC-287 Make alpha sRGB correction curves match OpenGL spec. --- .../shaders/class2/deferred/softenLightF.glsl | 24 ++++++++++++++++++++-- 1 file changed, 22 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 6e05091b57..06447261b4 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,6 +78,26 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; +vec3 srgb_to_linear(vec3 cs) +{ + +/* { cs / 12.92, cs <= 0.04045 + cl = { + { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); +} + +vec3 linear_to_srgb(vec3 cl) +{ + /*{ 0.0, 0 <= cl + { 12.92 * c, 0 < cl < 0.0031308 + cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 + { 1.0, cl >= 1*/ + + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; +} + vec2 encode_normal(vec3 n) { float f = sqrt(8 * n.z + 8); @@ -326,7 +346,7 @@ void main() vec4 diffuse = texture2DRect(diffuseRect, tc); //convert to gamma space - diffuse.rgb = pow(diffuse.rgb, vec3(1.0/2.2)); + diffuse.rgb = linear_to_srgb(diffuse.rgb); vec3 col; float bloom = 0.0; @@ -392,7 +412,7 @@ void main() col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } - col = pow(col, vec3(2.2)); + col = srgb_to_linear(col); //col = vec3(1,0,1); //col.g = envIntensity; -- cgit v1.2.3 From fbf3d8b78137a5229ccfabd1e42a0712d92b061f Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 11 Jul 2013 16:21:23 -0700 Subject: NORSPEC-291 WIP materials underwater with haze, reflection broken, water dist broken --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 9 +++++++++ 1 file changed, 9 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 06447261b4..4464358b1e 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -133,6 +133,13 @@ vec4 getPosition(vec2 pos_screen) return getPosition_d(pos_screen, depth); } +#ifdef WATER_FOG +vec3 getPositionEye(); +vec3 getSunlitColor(); +vec3 getAmblitColor(); +vec3 getAdditiveColor(); +vec3 getAtmosAttenuation(); +#else vec3 getPositionEye() { return vary_PositionEye; @@ -153,6 +160,7 @@ vec3 getAtmosAttenuation() { return vary_AtmosAttenuation; } +#endif void setPositionEye(vec3 v) { @@ -421,3 +429,4 @@ void main() frag_color.rgb = col; frag_color.a = bloom; } + -- cgit v1.2.3 From e9cdd0bfe8fe7f3bec0e6db7fba43e11f729af8a Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham)" Date: Thu, 11 Jul 2013 16:39:39 -0700 Subject: NORSPEC-291 WIP fix avatar disappearing --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 8 -------- 1 file changed, 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 4464358b1e..08aaa2237d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -133,13 +133,6 @@ vec4 getPosition(vec2 pos_screen) return getPosition_d(pos_screen, depth); } -#ifdef WATER_FOG -vec3 getPositionEye(); -vec3 getSunlitColor(); -vec3 getAmblitColor(); -vec3 getAdditiveColor(); -vec3 getAtmosAttenuation(); -#else vec3 getPositionEye() { return vary_PositionEye; @@ -160,7 +153,6 @@ vec3 getAtmosAttenuation() { return vary_AtmosAttenuation; } -#endif void setPositionEye(vec3 v) { -- cgit v1.2.3 From a8c9d81a376244a372de60b8c2af44c577ee51e0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 12 Jul 2013 06:45:49 -0700 Subject: NORSPEC-291 WIP fix materials underwater with shadows on --- .../shaders/class2/deferred/softenLightF.glsl | 53 ++++++++++++++++++++++ 1 file changed, 53 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 08aaa2237d..9b72c5b57d 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -266,6 +266,52 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) { setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); } +#ifdef WATER_FOG +uniform vec4 waterPlane; +uniform vec4 waterFogColor; +uniform float waterFogDensity; +uniform float waterFogKS; + +vec4 applyWaterFogDeferred(vec3 pos, vec4 color) +{ + //normalize view vector + vec3 view = normalize(pos); + float es = -(dot(view, waterPlane.xyz)); + + //find intersection point with water plane and eye vector + + //get eye depth + float e0 = max(-waterPlane.w, 0.0); + + vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0); + + //get object depth + float depth = length(pos - int_v); + + //get "thickness" of water + float l = max(depth, 0.1); + + float kd = waterFogDensity; + float ks = waterFogKS; + vec4 kc = waterFogColor; + + float F = 0.98; + + float t1 = -kd * pow(F, ks * e0); + float t2 = kd + ks * es; + float t3 = pow(F, t2*l) - 1.0; + + float L = min(t1/t2*t3, 1.0); + + float D = pow(0.98, l*kd); + + color.rgb = color.rgb * D + kc.rgb * L; + color.a = kc.a + color.a; + + return color; +} +#endif + vec3 atmosLighting(vec3 light) { light *= getAtmosAttenuation().r; @@ -409,6 +455,13 @@ void main() if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } -- cgit v1.2.3 From 94abe75dea90ee91dd044161d8587279b0bfae13 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Sun, 21 Jul 2013 08:15:21 -0700 Subject: NORSPEC-315 NORSPEC-316 NORSPEC-312 fix various haze and gamma correction issues, alpha-blend objects still missing haze underwater --- .../shaders/class2/deferred/softenLightF.glsl | 16 +++++++--------- 1 file changed, 7 insertions(+), 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 9b72c5b57d..0c71b4f554 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -455,23 +455,21 @@ void main() if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); - - #ifdef WATER_FOG - vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); - col = fogged.rgb; - bloom = fogged.a; - #endif - col = mix(scaleSoftClip(col), fullbrightScaleSoftClip(col), diffuse.a); } + #ifdef WATER_FOG + vec4 fogged = applyWaterFogDeferred(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + col = srgb_to_linear(col); //col = vec3(1,0,1); //col.g = envIntensity; } - + frag_color.rgb = col; frag_color.a = bloom; } - -- cgit v1.2.3 From 96869baaefae1f322bff5114429e7fa73b6d4bf9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 14:28:52 -0700 Subject: NORSPEC-285 NORSPEC-298 alpha vs diff color differences --- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 8 +++----- 1 file changed, 3 insertions(+), 5 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 0c71b4f554..233985631b 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -385,8 +385,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - float light_gamma = 1.0/1.3; - da = pow(da, light_gamma); + //float light_gamma = 1.0/1.3; + //da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -400,12 +400,10 @@ void main() vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + //scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); float scol = max(scol_ambocc.r, diffuse.a); - - float ambocc = scol_ambocc.g; calcAtmospherics(pos.xyz, ambocc); -- cgit v1.2.3 From 72a0ae58e909b017c07e543bc99adc1db5e89180 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 23 Jul 2013 16:09:58 -0700 Subject: NORSPEC-293 fix sRGB to linear conversion to not scrooge the darks --- .../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 233985631b..dbb32c40f4 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -85,6 +85,11 @@ vec3 srgb_to_linear(vec3 cs) cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ + vec3 low_range = cs / vec3(12.92); + + if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) + return low_range; + return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); } @@ -420,6 +425,7 @@ void main() col *= diffuse.rgb; + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection @@ -445,11 +451,10 @@ void main() vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, - envIntensity); + col = mix(col.rgb, refcol, envIntensity); } - + if (norm.w < 0.5) { col = mix(atmosLighting(col), fullbrightAtmosTransport(col), diffuse.a); @@ -462,6 +467,8 @@ void main() bloom = fogged.a; #endif + + col = srgb_to_linear(col); //col = vec3(1,0,1); -- cgit v1.2.3 From e290dd3fa175c2a891cc4f4e0c401edb10cedfb4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 24 Jul 2013 04:03:27 -0700 Subject: NORSPEC-311 make post deferred (alpha objects) respect same gamma ramp as deferred (opaque objects) --- .../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 dbb32c40f4..fa67c4ecea 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -100,6 +100,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -467,8 +472,6 @@ void main() bloom = fogged.a; #endif - - col = srgb_to_linear(col); //col = vec3(1,0,1); -- cgit v1.2.3 From f357269c38a8627aeb67c82c5ee34b49336e0d8b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 25 Jul 2013 09:36:13 -0700 Subject: NORSPEC-325 WIP restore gamma (uncorrected) attenuation and unify sRGB conversion in one place --- .../shaders/class2/deferred/softenLightF.glsl | 43 +++++----------------- 1 file changed, 9 insertions(+), 34 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 fa67c4ecea..db2faa65d7 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,35 +78,8 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs) -{ - -/* { cs / 12.92, cs <= 0.04045 - cl = { - { ((cs + 0.055)/1.055)^2.4, cs > 0.04045*/ - - vec3 low_range = cs / vec3(12.92); - - if (((cs.r + cs.g + cs.b) / 3) <= 0.04045) - return low_range; - - return pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); -} - -vec3 linear_to_srgb(vec3 cl) -{ - /*{ 0.0, 0 <= cl - { 12.92 * c, 0 < cl < 0.0031308 - cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 - { 1.0, cl >= 1*/ - - cl = clamp(cl, vec3(0), vec3(1)); - - if ((cl.r+cl.g+cl.b) < 0.0031308) - return 12.92 * cl; - - return 1.055 * pow(cl, vec3(0.41666)) - 0.055; -} +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); vec2 encode_normal(vec3 n) { @@ -395,8 +368,8 @@ void main() float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); - //float light_gamma = 1.0/1.3; - //da = pow(da, light_gamma); + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -410,10 +383,12 @@ void main() vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; - //scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); float scol = max(scol_ambocc.r, diffuse.a); + + float ambocc = scol_ambocc.g; calcAtmospherics(pos.xyz, ambocc); @@ -430,7 +405,6 @@ void main() col *= diffuse.rgb; - vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection @@ -456,7 +430,8 @@ void main() vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, envIntensity); + col = mix(col.rgb, refcol, + envIntensity); } -- cgit v1.2.3 From f86a7c04d3c265f4d61d99d1d7fdb7e35c4bc3f6 Mon Sep 17 00:00:00 2001 From: "Graham Madarasz (Graham Linden)" Date: Tue, 30 Jul 2013 11:33:58 -0700 Subject: NORSPEC-314 rollback unified srgb shader code to see if we can get past Mac 10.6.8 nV driver issues --- .../shaders/class2/deferred/softenLightF.glsl | 38 ++++++++++++++++++++-- 1 file changed, 36 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 db2faa65d7..cc34285d65 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -78,8 +78,42 @@ vec3 vary_AtmosAttenuation; uniform mat4 inv_proj; uniform vec2 screen_res; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); +vec3 srgb_to_linear(vec3 cs) +{ + vec3 low_range = cs / vec3(12.92); + vec3 high_range = pow((cs+vec3(0.055))/vec3(1.055), vec3(2.4)); + bvec3 lte = lessThanEqual(cs,vec3(0.04045)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lte.r ? low_range.r : high_range.r; + result.g = lte.g ? low_range.g : high_range.g; + result.b = lte.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lte); +#endif + +} + +vec3 linear_to_srgb(vec3 cl) +{ + cl = clamp(cl, vec3(0), vec3(1)); + vec3 low_range = cl * 12.92; + vec3 high_range = 1.055 * pow(cl, vec3(0.41666)) - 0.055; + bvec3 lt = lessThan(cl,vec3(0.0031308)); + +#ifdef OLD_SELECT + vec3 result; + result.r = lt.r ? low_range.r : high_range.r; + result.g = lt.g ? low_range.g : high_range.g; + result.b = lt.b ? low_range.b : high_range.b; + return result; +#else + return mix(high_range, low_range, lt); +#endif + +} vec2 encode_normal(vec3 n) { -- cgit v1.2.3