From 7ceaa01878c13082a3a803e1d369eaddfea76050 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 25 Aug 2022 15:45:15 -0700 Subject: SL-17703: PBR: Tweak sunlight scaling to better match Substance 3D Stager, don't blow bloom out --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index d4140a0d92..3f21bd0219 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -358,7 +358,8 @@ void main() if (nl > 0.0 || nv > 0.0) { - vec3 sunColor = srgb_to_linear(sunlit * 2.0); // NOTE: *2.0 Midday should have strong sunlight + float scale = 4.9; + vec3 sunColor = srgb_to_linear(sunlit * scale); // NOTE: Midday should have strong sunlight #if DEBUG_PBR_SUN_FULL_BRIGHT sunColor = vec3(1); #endif @@ -366,7 +367,7 @@ void main() vec3 intensity = ambocc * sunColor * nl * scol; vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); - bloom = dot(sunSpec, sunSpec) / 8.0; + bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); #if DEBUG_PBR_SUN_SPEC_FRESNEL colorDiffuse = vec3(0); -- cgit v1.2.3 From dc8773ffe91d51f1918a7f6756b2746440d6a1b9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 26 Aug 2022 15:09:02 -0700 Subject: SL-17703: PBR: Fix albedo being washed out due to wrong color space. --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 3f21bd0219..36407065c0 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -291,7 +291,7 @@ void main() float dotBV = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo - vec3 base = linear_to_srgb(diffuse.rgb); + vec3 base = diffuse.rgb; float perceptualRough = max(packedORM.g, 0.1); vec3 c_diff, reflect0, reflect90; float alphaRough, specWeight; -- cgit v1.2.3 From 8b45dfd477f6aedbf2c835fa276733ce6eba8e9f Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 26 Aug 2022 15:19:03 -0700 Subject: DRTVWR-559: PBR: Cleanup debug --- indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl | 2 +- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 777021cd53..833f5d51b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -291,7 +291,7 @@ vec2 getScreenXY(vec4 clip) // Color utils -vec3 colorized_dot(float x) +vec3 colorize_dot(float x) { if (x > 0.0) return vec3( 0, x, 0 ); if (x < 0.0) return vec3(-x, 0, 0 ); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 36407065c0..02e7c55718 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -186,6 +186,7 @@ vec3 srgb_to_linear(vec3 c); // Debug Utils vec3 BRDFDiffuse(vec3 color); +vec3 colorize_dot(float x); vec3 fresnelSchlick( vec3 reflect0, vec3 reflect90, float vh); float D_GGX( float nh, float alphaRough ); float V_GGX( float nl, float nv, float alphaRough ); -- cgit v1.2.3 From 55b071dcd7d9f00dd3f489a333ffc6ad48a0bbc9 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 26 Aug 2022 15:19:48 -0700 Subject: DRTVWR-559: Cleanup: Preserve note about legacy dist_atten magic number --- indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 833f5d51b6..68a57d12f0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -52,6 +52,9 @@ float calcLegacyDistanceAttenuation(float distance, float falloff) { float dist_atten = 1.0 - clamp((distance + falloff)/(1.0 + falloff), 0.0, 1.0); dist_atten *= dist_atten; + + // Tweak falloff slightly to match pre-EEP attenuation + // NOTE: this magic number also shows up in a great many other places, search for dist_atten *= to audit dist_atten *= 2.0; return dist_atten; } -- cgit v1.2.3 From 08c23419befc99f4b2de16cce9f296234e8b8f5a Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 26 Aug 2022 15:31:30 -0700 Subject: DRTVWR-559: PBR: Cleanup --- .../newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 91d041cafa..71135786c3 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -68,6 +68,9 @@ vec2 getScreenXY(vec4 clip); void initMaterial( vec3 diffuse, vec3 packedORM, out float alphaRough, out vec3 c_diff, out vec3 reflect0, out vec3 reflect90, out float specWeight ); vec3 srgb_to_linear(vec3 c); +// Util +vec3 hue_to_rgb(float hue); + void main() { #if defined(LOCAL_LIGHT_KILL) -- cgit v1.2.3 From dd3c13a198fcc61f9056d42d136265fc38c45aba Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 26 Aug 2022 15:51:39 -0700 Subject: SL-17766: PBR: Remove redundant misc. dot() calculations --- .../shaders/class3/deferred/softenLightF.glsl | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 02e7c55718..e5e0a37d4f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -287,9 +287,12 @@ void main() vec3 b = cross( n,t); vec3 reflectVN = normalize(reflect(-v,n)); - float dotNV = clamp(dot(n,v),0,1); - float dotTV = clamp(dot(t,v),0,1); - float dotBV = clamp(dot(b,v),0,1); + vec3 h, l; + float nh, nl, nv, vh, lightDist; + calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist); + + float tv = clamp(dot(t,v),0,1); + float bv = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo vec3 base = diffuse.rgb; @@ -302,10 +305,10 @@ void main() #endif // Common to RadianceGGX and RadianceLambertian - vec2 brdfPoint = clamp(vec2(dotNV, perceptualRough), vec2(0,0), vec2(1,1)); + vec2 brdfPoint = clamp(vec2(nv, perceptualRough), vec2(0,0), vec2(1,1)); vec2 vScaleBias = getGGX( brdfPoint); // Environment BRDF: scale and bias applied to reflect0 vec3 fresnelR = max(vec3(1.0 - perceptualRough), reflect0) - reflect0; // roughness dependent fresnel - vec3 kSpec = reflect0 + fresnelR*pow(1.0 - dotNV, 5.0); + vec3 kSpec = reflect0 + fresnelR*pow(1.0 - nv, 5.0); // Reference: getIBLRadianceGGX // https://forum.substance3d.com/index.php?topic=3243.0 @@ -353,10 +356,6 @@ void main() colorSpec *= ao; // Add in sun/moon reflection - vec3 h, l; - float nh, nl, nv, vh, lightDist; - calcHalfVectors(light_dir, n, v, h, l, nh, nl, nv, vh, lightDist); - if (nl > 0.0 || nv > 0.0) { float scale = 4.9; @@ -518,13 +517,13 @@ void main() color.rgb = b; #endif #if DEBUG_PBR_DOT_NV - color.rgb = vec3(dotNV); + color.rgb = vec3(nv); #endif #if DEBUG_PBR_DOT_TV - color.rgb = vec3(dotTV); + color.rgb = vec3(tv); #endif #if DEBUG_PBR_DOT_BV - color.rgb = vec3(dotBV); + color.rgb = vec3(bv); #endif #if DEBUG_PBR_AVG -- cgit v1.2.3 From d6e8a6c98aa426e8f1ee92cd7bc65703cf0a22aa Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Fri, 26 Aug 2022 17:47:47 -0700 Subject: SL-17703: PBR: revert dc8773ff, tweak sunlight albedo to be darker --- .../newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index e5e0a37d4f..998ebf8836 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -295,7 +295,7 @@ void main() float bv = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo - vec3 base = diffuse.rgb; + vec3 base = linear_to_srgb(diffuse.rgb); float perceptualRough = max(packedORM.g, 0.1); vec3 c_diff, reflect0, reflect90; float alphaRough, specWeight; @@ -365,8 +365,8 @@ void main() #endif // scol = sun shadow vec3 intensity = ambocc * sunColor * nl * scol; - vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); - vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); + vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); + vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); #if DEBUG_PBR_SUN_SPEC_FRESNEL -- cgit v1.2.3