
Secondary grid intensity (float) This parameter lets you set the intensity of the secondary grid lines, to help with visual clarity. Secondary grid line width (float) Set to 0.005 by default, a quarter of the primary grid’s line width. I have set this to 25 by default to create a 4×4 grid within each primary grid cell. Secondary grid size (cm) (float) The size of the secondary grid’s cells, in centimeters. By default this is set to true, because subdivisions are sexy. Use secondary grid (boolean) This boolean will toggle an additional set of grid lines. I found a value of 0.02 looks best in my demo scene. The strength of the two lines that intersect the origin will be double this setting. Primary grid line width (float) The thickness of the primary grid lines.
This is entirely optional, I just prefer cm. Inside our shader I am dividing parameters marked with (cm) by 100 to make the conversion.
Side note: As we’ve already covered here on techarthub, Unity units are usually measured in meters. By default this is set to 50, which means grid lines will be spaced at half-meter intervals.
Primary grid size (cm) (float) The length of a single grid cell in centimeters.
Line color (color) The color of the shader’s grid lines. Working with the shaderīefore we jump into the creation process, I think it’s best to give you a brief rundown of how the finished shader works so you can decide for yourself which features are worth including. The Creating a Procedural Grid Material in Unreal Engine tutorial is similar (but not identical) to this one. If you’re an Unreal Engine developer and you’ve landed on this page by mistake, I have also created a version of this shader for UE4/5. Feel free to use them in your own projects however you like! You can download both the URP and HDRP versions of the shader (they’re virtually identical) from this resource page, or from the project’s GitHub repository. Click any of the images to view in full res. If you’re already confident you know your way around Shader Graph and you just want to see my implementation, here is what my graph looks like in version 2021.2.6f1.
In the following sections we’ll be going through the shader creation process step-by-step. With a range of features and being entirely procedural, the shader will be highly customizable and look good at any scale. In this tutorial we’ll be using Unity’s Shader Graph to create a multipurpose world-space grid for both the Universal and High Definition Render Pipelines. If the grid also makes your blockout look a little prettier, then that’s even better! While blocking out a new scene, the grid provides a proper sense of both scale and distance, and helps delineate between surfaces. I don’t think I am exaggerating too much when I say that a versatile grid shader is at the core of a level designer’s toolkit.