Grid is opaque and different scale on macOS
Closed, ResolvedPublic


System Information
macOS 10.12.6 AMD Radeon R9 M390 2048 MB

Blender Version
Broken: blender-2.80.0-git20170615.f2d7a28a098-x86_64

Downloaded from

All working versions of 2.8 have shown this for me, on 10.12.5 and 10.12.6, In Evee and Clay the grid is an opaque 'floor' and appears to be very large.

Exact steps for others to reproduce the error
Just load the build and observe the cube in the default scene

Blender Render


Mike Erwin (merwin) triaged this task as Confirmed priority.Jun 15 2017, 6:11 PM

Exact same issue on Mac + NVIDIA.

However, Mac + Intel works as intended!

I think this may come from derivative calculation. I use the GLSL function fwidth to compute line thickness and it requires local derivatives. So it may be a driver error or a faulty implementation of derivatives.

MacOS 10.13.4
NVIDIA GeForce GTX 775M 2048 MB graphics

The grid world positions lie (correctly in my view) in the plane Z=0. This makes the waves collapse to 0. I would think the fix below would also work on other platforms where presumably the grid world position is incorrectly in a plane with Z coordinate much larger than the x,y so has no effect on the clamping.

diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index baf508fd854..b6d764f3043 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -42,7 +42,7 @@ float get_grid(vec3 co, vec3 fwidthCos, float grid_size)
        grid_domain /= fwidthCos;
        /* collapse waves and normalize */
-       grid_domain.x = min(grid_domain.x, min(grid_domain.y, grid_domain.z)) / grid_size;
+       grid_domain.x = min(grid_domain.x, grid_domain.y) / grid_size;
        return 1.0 - smoothstep(0.0, GRID_LINE_SMOOTH / grid_size, grid_domain.x);

With the above patch I see the following infinite grid rather than no grid and half occluded cube:

Thanks @Adam Latchem (adamlatchem) for finding the problem. I've commited a more general fix to this problem. Hopefully it should work on mac now.