Fix T51724: Blender 2.80 EEVEE, Cycles, Clay Black Wall Graphical Glitch
[blender.git] / source / blender / draw / modes / shaders / object_grid_frag.glsl
index 0196b1a6f984b9464005bd28dd27e242ee4f38f2..61bd4d58a4a4f1650a84be43231cdf6f35a21ae5 100644 (file)
@@ -75,7 +75,11 @@ vec3 get_floor_pos(vec2 uv, out vec3 wPos)
                camera_vec = normalize(eye);
        }
 
-       float p = -dot(planeNormal, camera_pos) / dot(planeNormal, camera_vec);
+       float plane_normal_dot_camera_vec = dot(planeNormal, camera_vec);
+       float p = -dot(planeNormal, camera_pos);
+       if (plane_normal_dot_camera_vec != 0) {
+               p /= plane_normal_dot_camera_vec;
+       }
        vec3 plane = camera_pos + camera_vec * p;
 
        /* fix residual imprecision */