Getting Started with Shader Graph

What is a Shader Graph?

A Shader Graph enables you to build your shaders visually. Instead of hand writing code you create and connect Node in a graph network. You can do things like:

  • Procedurally alter your surface appearance
  • Warp and animate UVs
  • Modify the look of your objects using familiar image adjustment operations
  • Change your object’s surface based on useful information about it, its world location, normals, distance from camera, etc.
  • Expose to the material inspector what you think is important to edit for your shader
  • Share node networks between multiple graphs and users by creating subgraphs
  • Create your own custom shader graph Nodes through C# and HLSL
  • The graph framework gives instant feedback on the changes, and it’s simple enough that new users can become involved in shader creation.

How do you create Shader Graphs?

To use Shader Graph you must first create a Shader Graph Asset. In Unity a Shader Graph Asset appears as a normal shader. To create a Shader Graph Asset you click the create menu in the Project Window and select Shader from the dropdown. From here you can create either a PBR or Unlit Shader Graph Asset. This will create a Shader Graph Asset in the project. You can double click on the Shader Graph Asset or, with the Shader Graph Asset selected, select the Open Shader Editor button in the Inspector to bring up the Shader Graph Window.

Editing the Shader Graph

When you open the Shader Graph Window you start with the Master Node. You connect Nodes into the Master Node to create the look of your surface. To learn more about the underlying material models check out the existing Unity Standard Shader documentation.

You can quickly edit your surface by changing the default values!

But, you know what’s even more exciting? Adding textures and other complex interactions. To add a node simply right click on the workspace in the Shader Graph Window and select Create Node.

Each included Shader Graph Node has a number of input Ports, we’ve included default values that you can customize however you like!

Adding in a Texture (or other assets) is also really easy, just create a Node of that Data Type and connect it with an Edge!

Your Shader Graph shader is just like a normal shader in Unity. Right click create Material in the Project Window to create a new Material you can use on any object in your game. You can create multiple Materials from the same shader.

You can expose Properties in your shader so they can be overwritten in each Material you create from your shader. This is easy. In the shader graph right click on any variable node and select Convert to property node or add a new Property using the Blackboard. These exposed Properties appear in the Material Inspector for each Material you create from your shader.

To see your new Shader Graph changes affect your in game Materials click the Save Asset button in the Shader Graph Window

How do I get access to the Shader Graph?

It is recommended for users to access the Shader Graph via the Package Manager or via Templates. To use the Shader Graph in your project either start a new project using a template that includes Shader Graph or download a Render Pipeline package from the Package Manager. The Shader Graph will be downloaded automatically for your use in either of these cases.

Packages that contain Shader Graph: - Lightweight Render Pipeline - HD Render Pipeline

Templates that contain Shader Graph: - Lightweight 3D Template - HD 3D Template

Download from Github

If you wish to download via Github you must clone to SRP repository then reference these package versions directly in your project's package manifest.

What are the requirements for using Shader Graph

This is a feature for the new Scriptable Render Pipeline, available in 2018.1+. It will not work out of the box without an SRP.

We won’t be supporting this feature for the legacy renderer.

I want more tutorials!

More will be coming (including more examples!) over the coming months. We have an end to end shader creation video Here as a starter point.