From 33e46aac13f35511ddb0a58f6441e3d8b7fe1f35 Mon Sep 17 00:00:00 2001 From: mandryskowski Date: Tue, 18 Jul 2023 19:18:19 +0200 Subject: [PATCH] Revert the change of the limit for interpolation of R0 with respect to metallic and SSR Commit 2c000cb72fc04fd76c5d3b6bc53955f83bf50c71 changed the interpolation limits from (0.04, 1.0) to (0.04, 0.37). This is incorrect, as we want to have an F0 of 0.04 for dielectrics (materials with metalness of 0.0) and an F0 of 1.0 for metals. The Schlick approximation uses an F0 of 0.04 for all dielectrics and it's good enough. Having it lower than 1.0 leads to an incorrect application of the Fresnel effect for metals and leads to bugs like #79549 --- .../renderer_rd/shaders/effects/screen_space_reflection.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl index 1626244b0a..1e01d94533 100644 --- a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl @@ -263,7 +263,9 @@ void main() { // Schlick term. float metallic = texelFetch(source_metallic, ssC << 1, 0).w; - float f0 = mix(0.04, 0.37, metallic); // The default value of R0 is 0.04 and the maximum value is considered to be Germanium with R0 value of 0.37 + // F0 is the reflectance of normally incident light (perpendicular to the surface). + // Dielectric materials have a widely accepted default value of 0.04. We assume that metals reflect all light, so their F0 is 1.0. + float f0 = mix(0.04, 1.0, metallic); float m = clamp(1.0 - dot(normal, -view_dir), 0.0, 1.0); float m2 = m * m; m = m2 * m2 * m; // pow(m,5)