From cf460b13bee894684d0ca1bcb5bbc9eb38df719c Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 12 Mar 2018 16:24:16 +0100 Subject: De-duplicate sRGB conversion funcs from many shaders and unify on using the version that works on OSX. Add more logging to shader loading about fallbacks and loading succcess. Add frag shaders for sharing sRGB and normal encode/decode via GL shader linkage. --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 6 ------ 1 file changed, 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index aba4a01754..4f02365f45 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -56,12 +56,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; uniform vec4 viewport; -vec2 encode_normal(vec3 n) -{ - float f = sqrt(8 * n.z + 8); - return n.xy / f + 0.5; -} - vec3 decode_normal (vec2 enc) { vec2 fenc = enc*4-2; -- cgit v1.2.3 From 98b2fed85fd459012ed2b859ea40a3f56d27c0e8 Mon Sep 17 00:00:00 2001 From: "Graham Linden graham@lindenlab.com" Date: Mon, 12 Mar 2018 17:52:04 +0100 Subject: De-duplicate shader code for encoding and decoding normals to/from gbuffer format. --- .../app_settings/shaders/class1/deferred/pointLightF.glsl | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 4f02365f45..13b803e03e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -56,16 +56,7 @@ uniform vec2 screen_res; uniform mat4 inv_proj; uniform vec4 viewport; -vec3 decode_normal (vec2 enc) -{ - vec2 fenc = enc*4-2; - float f = dot(fenc,fenc); - float g = sqrt(1-f/4); - vec3 n; - n.xy = fenc*g; - n.z = 1-f/2; - return n; -} +vec3 decode_normal (vec2 enc); vec4 getPosition(vec2 pos_screen) { -- cgit v1.2.3 From 2929998982f37221a58b9fa8037748a2e905f4b1 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 6 Nov 2018 19:33:04 +0000 Subject: Move to using a shared deferredUtil object for getting pos/norm from gbuffer. Eliminate 20+ callsites with copy-paste of getPosition and/or getNorm code. Make pipeline use getShadowTarget/releaseShadowTarget consistently. --- .../app_settings/shaders/class1/deferred/pointLightF.glsl | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 13b803e03e..df48a66fab 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -57,19 +57,7 @@ uniform mat4 inv_proj; uniform vec4 viewport; vec3 decode_normal (vec2 enc); - -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = (pos_screen.xy-viewport.xy)*2.0; - sc /= viewport.zw; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { -- cgit v1.2.3 From db270df7cc00c1e2519749831e7e98c2c10e3ee6 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 9 Nov 2018 18:31:29 +0000 Subject: Back out changes causing broken shadows and other render shenanigans. --- .../app_settings/shaders/class1/deferred/pointLightF.glsl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index df48a66fab..13b803e03e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -57,7 +57,19 @@ uniform mat4 inv_proj; uniform vec4 viewport; vec3 decode_normal (vec2 enc); -vec4 getPosition(vec2 pos_screen); + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).r; + vec2 sc = (pos_screen.xy-viewport.xy)*2.0; + sc /= viewport.zw; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} void main() { -- cgit v1.2.3 From 7e9033821a96a9d6e80b58fafb4c7da63807b9d4 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 6 Dec 2018 10:59:11 -0800 Subject: De-duplicate deferred gbuffer access for getPosition/getNorm. De-duplicate ambient occlusion shader code and move to new aoUtil.glsl Split shared shadow tap funcs into shadowUtil.glsl --- .../app_settings/shaders/class1/deferred/pointLightF.glsl | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 13b803e03e..8e756c37bf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -58,18 +58,7 @@ uniform vec4 viewport; vec3 decode_normal (vec2 enc); -vec4 getPosition(vec2 pos_screen) -{ - float depth = texture2DRect(depthMap, pos_screen.xy).r; - vec2 sc = (pos_screen.xy-viewport.xy)*2.0; - sc /= viewport.zw; - sc -= vec2(1.0,1.0); - vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); - vec4 pos = inv_proj * ndc; - pos /= pos.w; - pos.w = 1.0; - return pos; -} +vec4 getPosition(vec2 pos_screen); void main() { -- cgit v1.2.3 From c007e1197c521a1b48736cbba29e7c7dadf39c20 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 4 Jan 2019 13:26:47 -0800 Subject: Convert to using shared shadow sampling function (reduce duplicated code blocks in several shaders). --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 8e756c37bf..df48a66fab 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -57,7 +57,6 @@ uniform mat4 inv_proj; uniform vec4 viewport; vec3 decode_normal (vec2 enc); - vec4 getPosition(vec2 pos_screen); void main() -- cgit v1.2.3 From acbc7f4cddd6ad999c2bc7690c10b85a414a8102 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 30 Jan 2019 08:37:07 -0800 Subject: SL-10415, SL-10434 Further tweaking of directional shadow sampling to balance between peter-panning and shadow acne. Move stars to just this side of the sky some to reduce parallax. Remove decodeNormF and uses of decode_normal in favor of unified use of getNorm (try to help the Intel HD x000 compiler learn to link correctly). --- .../shaders/class1/deferred/pointLightF.glsl | 127 ++++++++++----------- 1 file changed, 63 insertions(+), 64 deletions(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index df48a66fab..f8264d971c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -56,76 +56,75 @@ uniform vec2 screen_res; uniform mat4 inv_proj; uniform vec4 viewport; -vec3 decode_normal (vec2 enc); +vec3 getNorm(vec2 pos_screen); vec4 getPosition(vec2 pos_screen); void main() { - vec4 frag = vary_fragcoord; - frag.xyz /= frag.w; - frag.xyz = frag.xyz*0.5+0.5; - frag.xy *= screen_res; - - vec3 pos = getPosition(frag.xy).xyz; - vec3 lv = trans_center.xyz-pos; - float dist = length(lv); - dist /= size; - if (dist > 1.0) - { - discard; - } - - vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = decode_normal(norm.xy); // unpack norm - float da = dot(norm, lv); - if (da < 0.0) - { - discard; - } - - norm = normalize(norm); - lv = normalize(lv); - da = dot(norm, lv); - - float noise = texture2D(noiseMap, frag.xy/128.0).b; - - vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff+1.0; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; - - float lit = da * dist_atten * noise; + vec4 frag = vary_fragcoord; + frag.xyz /= frag.w; + frag.xyz = frag.xyz*0.5+0.5; + frag.xy *= screen_res; + + vec3 pos = getPosition(frag.xy).xyz; + vec3 lv = trans_center.xyz-pos; + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } + + vec3 norm = getNorm(frag.xy); - col = color.rgb*lit*col; + float da = dot(norm, lv); + if (da < 0.0) + { + discard; + } + + lv = normalize(lv); + da = dot(norm, lv); + + float noise = texture2D(noiseMap, frag.xy/128.0).b; + + vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; + float fa = falloff+1.0; + float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; + + float lit = da * dist_atten * noise; - vec4 spec = texture2DRect(specularRect, frag.xy); - if (spec.a > 0.0) - { - lit = min(da*6.0, 1.0) * dist_atten; + col = color.rgb*lit*col; - vec3 npos = -normalize(pos); - vec3 h = normalize(lv+npos); - float nh = dot(norm, h); - float nv = dot(norm, npos); - float vh = dot(npos, h); - float sa = nh; - float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; - float gtdenom = 2 * nh; - float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + vec4 spec = texture2DRect(specularRect, frag.xy); + if (spec.a > 0.0) + { + lit = min(da*6.0, 1.0) * dist_atten; - if (nh > 0.0) - { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += lit*scol*color.rgb*spec.rgb; - } - } - - if (dot(col, col) <= 0.0) - { - discard; - } - - frag_color.rgb = col; - frag_color.a = 0.0; + vec3 npos = -normalize(pos); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5) * 0.4+0.5; + float gtdenom = 2 * nh; + float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh))); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + col += lit*scol*color.rgb*spec.rgb; + } + } + + if (dot(col, col) <= 0.0) + { + discard; + } + + frag_color.rgb = col; + frag_color.a = 0.0; } -- cgit v1.2.3 From 09981714c306b9bf89a8e65c49318ccc6c30580f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 27 Mar 2019 09:38:26 -0700 Subject: Fix projector falloff and attenuation handling. --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index f8264d971c..55410c1ed7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -89,7 +89,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff+1.0; + float fa = (falloff * 0.5)+1.0; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; -- cgit v1.2.3 From 03426a7ddbf1b3bb8349241d3b52962026f7504a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 28 Mar 2019 13:23:59 -0700 Subject: SL-10829, SL-10830 Replace old spot prio calc. Replace fudge factors on light radius and falloff for deferred lights. --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 55410c1ed7..f8264d971c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -89,7 +89,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = (falloff * 0.5)+1.0; + float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; dist_atten *= 2.0; -- cgit v1.2.3 From db091d23db70952b4ad8b610ef02942a8f13f223 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 22 May 2019 11:00:30 -0700 Subject: SL-10969 Fix linear attenuation on forward projector lighting. Revert setup of falloff to prev code. Revert deferred water spec and tweak refl/refr blend. --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index f8264d971c..73bc1141b0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -124,7 +124,7 @@ void main() { discard; } - +//col.rgb = vec3(0); frag_color.rgb = col; frag_color.a = 0.0; } -- cgit v1.2.3 From 653133b9c035e7c34563b199e991189ca3046092 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 11 Jun 2019 13:03:06 -0700 Subject: SL-11370, SL-11372, SL-11337 Fix culling on Low+ water reflection pass. Make Mid+ / High use class1 deferred sky again (no rainbows, but faster!). Fix setting of cloud color for deferred sky/cloud shaders. Put water reflections back in wrong colorspace for consistency with release. --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 73bc1141b0..b3ce1ce2e0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -89,6 +89,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; + float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; -- cgit v1.2.3 From 5bd055fe585233b3c43e02f2082f5a95f79b825b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 18 Jun 2019 14:33:28 -0700 Subject: SL-10829 the 2nd Made pointLightF use correct colorspace as multiPoint already was. --- indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl') diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index b3ce1ce2e0..d805c9ea48 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -58,6 +58,7 @@ uniform vec4 viewport; vec3 getNorm(vec2 pos_screen); vec4 getPosition(vec2 pos_screen); +vec3 srgb_to_linear(vec3 c); void main() { @@ -89,6 +90,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; + col.rgb = srgb_to_linear(col.rgb); float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); -- cgit v1.2.3