Published on

[Shader Graph] Grid Shader in Unity

  • Evelyn
    Full-time IndieDev.
    I'm Japanese, so please forgive me if my English is strange.

Please share this article if you like!


In this article, let's create a Grid shader using the Shader Graph.

There's also a Youtube video that explains it all, so if you're having trouble understanding just the text info, watch the video!

Table of Contents


Work with a rendering pipeline that allows shader graphs.

I use the Universal Render Pipeline (URP) to capture my screens.

Creating Grid Shader

First, make sure that the Shader Graph has been imported in the Package Manager.

Next, right-click in the project window and select Lit Shader Graph in the shader graph.

Double-click on the generated file to start editing.

The whole thing looks like this.

I know it's hard to tell from just this image, so let's take a closer look!

We will add variables so that the parameters can be adjusted from the material.

First, add a Float type Tile Amount and put your favorite value in the Default Value.

We can use this variable to adjust the level of detail in the grid.

Next, add a Line Thickness of Float type and set the Default Value to 0.9.

If the value is set to more than 1, the line will disappear, so change the Mode to Slider so that the value can only be changed between 0 and 1.

In addition, we will add Color.

The color specified by this variable will be used in the guri

By setting the mode to HDR, you can also adjust the light conditions.

By creating a Rectangle node and connecting One Minus as shown in the image, and connecting the output results of Color and Multiply to Base Color and Emission, a rectangle will be displayed.

The Tiling And Offset node and the Fraction node can be gridded by attaching them to the Rectangle node.

Using the shaders created here, you can easily display the grid like this.

Wrap Up

What did you think?

Please try to use the shaders created in this blog post in your own game development.

I look forward to the day when I can play the games you have developed.

Please share this article if you like!