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.
This was quite challenging for a number of reasons:
- Major and Minor grid lines need to be drawn that respond to zoom and hence LOD
- The grid needs to fade out into the distance as the camera looks across it
- The grid needs to be seen from below
- The grid lines should not mix with the axis lines
- The lines should maintain their thickness as the camera zooms in and out
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