From e928e3fec4cd2b370421e592a1f01bb3874de67b Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 30 Aug 2022 13:57:46 -0500 Subject: SL-17705 AMD compatibility -- use a specific LoD of irradiance map to avoid black outlines on AMD --- .../newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 83348077d7..1f5fdde9ca 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -364,7 +364,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, vec3 c, float r2, int i) v -= c; v = env_mat * v; { - return texture(irradianceProbes, vec4(v.xyz, refIndex[i].x)).rgb * refParams[i].x; + return textureLod(irradianceProbes, vec4(v.xyz, refIndex[i].x), 0).rgb * refParams[i].x; } } -- cgit v1.2.3 From 2158162b50673afd7b93822823ce1f2be78e2842 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 30 Aug 2022 15:46:38 -0500 Subject: SL-18055 Fix for soft cube maps on chrome (don't clamp roughness value) --- 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') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 998ebf8836..34ebb67c3c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -296,7 +296,7 @@ void main() // Reference: getMetallicRoughnessInfo vec3 base = linear_to_srgb(diffuse.rgb); - float perceptualRough = max(packedORM.g, 0.1); + float perceptualRough = packedORM.g; // NOTE: do NOT clamp here to be consistent with Blender, Blender is wrong and Substance is right vec3 c_diff, reflect0, reflect90; float alphaRough, specWeight; initMaterial( base, packedORM, alphaRough, c_diff, reflect0, reflect90, specWeight ); -- cgit v1.2.3 From 8eaee1f033d9dac892e749cc65416e149021d8f6 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Tue, 30 Aug 2022 20:35:15 -0700 Subject: SL-17703: PBR: Fix albedo being in wrong color space, add support for debug default_irradiance.png --- .../shaders/class3/deferred/softenLightF.glsl | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 998ebf8836..56aa8437de 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -27,6 +27,10 @@ #define PBR_USE_IBL 1 #define PBR_USE_SUN 1 +#define PBR_USE_LINEAR_ALBEDO 1 +#define PBR_USE_DEFAULT_IRRADIANCE 0 // PBR: irradiance, skins/default/textures/default_irradiance.png +#define PBR_USE_IRRADIANCE_HACK 1 + #define DEBUG_PBR_LIGHT_TYPE 0 // Output no global light to make it easier to see pointLight and spotLight #define DEBUG_PBR_PACKORM0 0 // Rough=0, Metal=0 #define DEBUG_PBR_PACKORM1 0 // Rough=1, Metal=1 @@ -135,6 +139,9 @@ uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; uniform sampler2DRect normalMap; uniform sampler2DRect emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl +uniform sampler2D altDiffuseMap; // PBR: irradiance, skins/default/textures/default_irradiance.png + +const float M_PI = 3.14159265; #if defined(HAS_SUN_SHADOW) || defined(HAS_SSAO) uniform sampler2DRect lightMap; @@ -295,7 +302,11 @@ void main() float bv = clamp(dot(b,v),0,1); // Reference: getMetallicRoughnessInfo +#if PBR_USE_LINEAR_ALBEDO + vec3 base = diffuse.rgb; +#else vec3 base = linear_to_srgb(diffuse.rgb); +#endif float perceptualRough = max(packedORM.g, 0.1); vec3 c_diff, reflect0, reflect90; float alphaRough, specWeight; @@ -321,7 +332,14 @@ void main() #if DEBUG_PBR_IRRADIANCE_RAW vec3 debug_irradiance = irradiance; #endif + +#if PBR_USE_DEFAULT_IRRADIANCE + vec2 iruv = vec2(0.5f + 0.5f * atan(reflectVN.z, reflectVN.x) / M_PI, 1.f - acos(reflectVN.y) / M_PI); + irradiance = texture2D(altDiffuseMap, iruv).rgb * ambocc; +#endif +#if PBR_USE_IRRADIANCE_HACK irradiance = max(amblit,irradiance) * ambocc; +#endif specLight = srgb_to_linear(specLight); #if DEBUG_PBR_SPECLIGHT051 specLight = vec3(0,0.5,1.0); @@ -365,8 +383,13 @@ void main() #endif // scol = sun shadow vec3 intensity = ambocc * sunColor * nl * scol; +#if PBR_USE_LINEAR_ALBEDO + vec3 sunDiffuse = intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); + vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); +#else vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); +#endif bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); #if DEBUG_PBR_SUN_SPEC_FRESNEL @@ -577,9 +600,11 @@ void main() #endif #if DEBUG_PBR_IRRADIANCE_RAW color.rgb = debug_irradiance; + bloom = 0; #endif #if DEBUG_PBR_IRRADIANCE color.rgb = irradiance; + bloom = 0; #endif #if DEBUG_PBR_KSPEC color.rgb = kSpec; @@ -633,6 +658,7 @@ void main() #if DEBUG_PBR_LIGHT_TYPE color.rgb = vec3(0); #endif + frag_color.rgb = color.rgb; // PBR is done in linear } else -- cgit v1.2.3 From eff9f08bd9128bfa64ce1b86ce0d74a76d8cc548 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 31 Aug 2022 13:19:56 -0700 Subject: DRTVWR-559: PBR: Disable PBR bloom --- indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index fe829edb88..507eb37627 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -390,7 +390,10 @@ void main() vec3 sunDiffuse = base * intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); vec3 sunSpec = intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); #endif - bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); + // Disabling PBR bloom due to two reasons: + // 1. The glTF 2.0 Specification does not specify bloom, + // 2. As the camera moves there are lots of bloom shimmering. + //bloom = dot(sunSpec, sunSpec) / (scale * scale * scale); #if DEBUG_PBR_SUN_SPEC_FRESNEL colorDiffuse = vec3(0); -- cgit v1.2.3 From f4d7b11e16edc7fb803496801873a03587270e54 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 31 Aug 2022 20:59:43 -0700 Subject: SL-17975: PBR: Fix point light popping --- .../newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 71135786c3..679d3dacca 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -148,7 +148,7 @@ void main() float lightDist; calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); - float fa = light_col[i].a + 1.0; + float fa = light_col[i].a; float dist_atten = calcLegacyDistanceAttenuation(dist, fa); dist_atten *= noise; -- cgit v1.2.3 From 17a957fe44539a3d076e67ffc352036051814359 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 31 Aug 2022 21:00:58 -0700 Subject: DRTVWR-559: PBR: Cleanup: Don't do redundant dot(n,l) calc --- .../app_settings/shaders/class3/deferred/softenLightF.glsl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 507eb37627..85bb9fbbd1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -214,12 +214,7 @@ void main() norm.xyz = getNorm(tc); vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); -#if DEBUG_PBR_DA_RAW - float debug_da = da; -#endif float light_gamma = 1.0 / 1.3; - da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); // NOTE: PBR sRGB Emissive @@ -666,6 +661,12 @@ void main() } else { + float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0); +#if DEBUG_PBR_DA_RAW + float debug_da = da; +#endif + da = pow(da, light_gamma); + diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035 sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity); -- cgit v1.2.3 From 539fd5fcf9fa1872996fbb687b49307737f1c8b5 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 31 Aug 2022 21:04:45 -0700 Subject: SL-17975: PBR: Don't process point light if outside light radius --- .../app_settings/shaders/class3/deferred/multiPointLightF.glsl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 679d3dacca..c7c241b76e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -30,7 +30,7 @@ #define DEBUG_ANY_LIGHT_TYPE 0 // Output red light cone #define DEBUG_PBR_LIGHT_TYPE 0 // Output PBR objects in red #define DEBUG_LEG_LIGHT_TYPE 0 // Show Legacy objects in red -#define DEBUG_POINT_ZERO 0 // Output zero for spotlight +#define DEBUG_POINT_ZERO 0 // Output zero for point lights #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; @@ -113,11 +113,10 @@ void main() vec3 lv =(light [ light_idx ].xyz - pos); calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); - if (nl > 0.0) + float dist = lightDist / lightSize; + if (dist <= 1.0 && nl > 0.0) { - float dist = lightDist / lightSize; float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); - vec3 intensity = dist_atten * nl * lightColor; colorDiffuse += intensity * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); colorSpec += intensity * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); -- cgit v1.2.3 From ce685a12b9acc888a39c336c91ae6272db74ce91 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Wed, 31 Aug 2022 21:06:41 -0700 Subject: DRTVWR-559: PBR: Cleanup distance attenuation calcs --- .../app_settings/shaders/class3/deferred/multiSpotLightF.glsl | 5 ++--- indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'indra/newview/app_settings/shaders/class3') diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index a9a2b8dcb4..3efc9c1689 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -110,6 +110,7 @@ uniform mat4 inv_proj; vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh ); vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh ); void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); +float calcLegacyDistanceAttenuation(float distance, float falloff); vec3 colorized_dot(float x); bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc ); vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v); @@ -155,9 +156,7 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); - float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); - dist_atten *= dist_atten; - dist_atten *= 2.0; + float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); if (dist_atten <= 0.0) { discard; diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 41e40a07e7..87b7977f64 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -85,6 +85,7 @@ uniform mat4 inv_proj; vec3 BRDFLambertian( vec3 reflect0, vec3 reflect90, vec3 c_diff, float specWeight, float vh ); vec3 BRDFSpecularGGX( vec3 reflect0, vec3 reflect90, float alphaRoughness, float specWeight, float vh, float nl, float nv, float nh ); void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); +float calcLegacyDistanceAttenuation(float distance, float falloff); bool clipProjectedLightVars(vec3 center, vec3 pos, out float dist, out float l_dist, out vec3 lv, out vec4 proj_tc ); vec3 getLightIntensitySpot(vec3 lightColor, float lightRange, float lightDistance, vec3 v); vec4 getNormalEnvIntensityFlags(vec2 screenpos, out vec3 n, out float envIntensity); @@ -129,9 +130,7 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() - float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); - dist_atten *= dist_atten; - dist_atten *= 2.0; + float dist_atten = calcLegacyDistanceAttenuation(dist, falloff); if (dist_atten <= 0.0) { discard; -- cgit v1.2.3