Eevee: Fix contact shadow creating to overshadowing
authorClément Foucault <foucault.clem@gmail.com>
Sun, 28 Oct 2018 18:24:56 +0000 (19:24 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Sun, 28 Oct 2018 20:48:22 +0000 (21:48 +0100)
This was because the shadow rays could be generated below the geometric
normal.

source/blender/draw/engines/eevee/shaders/lamps_lib.glsl

index 6f7a2f9bb09dc1beb63e0ce4f3d266a895dcd1a7..b33f1a0572e7d3845e1856eacd4a8f1b2d5e9838 100644 (file)
@@ -226,6 +226,10 @@ float light_visibility(LightData ld, vec3 W,
 
                        vec3 ray_ori = viewPosition;
 
+                       if (dot(viewNormal, ray_dir) <= 0.0) {
+                               return vis;
+                       }
+
                        float bias = 0.5; /* Constant Bias */
                        bias += 1.0 - abs(dot(viewNormal, ray_dir)); /* Angle dependent bias */
                        bias *= gl_FrontFacing ? data.sh_contact_offset : -data.sh_contact_offset;