Grid Lines

No 3D design program would be complete without a grid.

I implemented a 2D grid of squares using a Plane Mesh. A shader was written to draw the lines of the grid.

Distance fade-out of grid

This was quite challenging for a number of reasons:

LOD means Level of Detail, it is related to the density of displayed squares of the grid as the camera is zoomed in and out.

At various points of zoom, the minor square size needs to switch and so does the major square size to maintain a consistent grid resolution that is useful.

During this development work I realized that the rate of zoom needed to be made non-linear as the mouse wheel was rotated since we want an ever slower rate of zooming in and an expanding rate of zooming out.

Another consideration is how big should the grid be to keep enough of it in the field of view.

Also, a cool feature is that the grid lines are tinted with a blend of the axis line colors related to the camera normal vector. Maybe this is helpful and adds some nice look to the grid.

More Blog posts

Most recent first