0
0
Unityframework~10 mins

Shader Graph basics in Unity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Shader Graph basics
Start Shader Graph
Create Nodes
Connect Nodes
Set Node Properties
Compile Shader
Apply Shader to Material
See Visual Result
This flow shows how you start a Shader Graph, add and connect nodes, set their properties, compile the shader, and apply it to see the effect.
Execution Sample
Unity
1. Create Color Node
2. Create Multiply Node
3. Connect Color to Multiply A and B
4. Connect Multiply to Output
5. Set Color to Red
This simple shader multiplies a color and outputs it, showing how nodes connect and affect the final color.
Execution Table
StepActionNode Created/ModifiedConnectionsOutput Color
1Create Color NodeColor Node (default white)NoneWhite
2Create Multiply NodeMultiply NodeNoneWhite
3Connect Color to Multiply A and BColor NodeColor -> Multiply Input A and BWhite
4Connect Multiply to OutputMultiply NodeMultiply Output -> Master NodeWhite
5Set Color to RedColor NodeColor set to RedRed
6Compile ShaderAll NodesConnections activeRed
7Apply Shader to MaterialMaterialShader assignedRed
8Render FrameMaterialShader runsRed
9EndNo changesNo changesRed
💡 Shader graph setup complete, shader applied and rendering red color.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 5Final
Color Node ValueWhiteWhiteWhiteWhiteRedRed
Multiply Node InputsNoneNoneNoneColor Node outputs (A and B)Color Node outputs (A and B)Color Node outputs (A and B)
Output ColorNoneNoneNoneWhiteRedRed
Key Moments - 3 Insights
Why does the output color stay white until I set the Color Node to red?
Because initially the Color Node's default value is white (see execution_table step 1 and 5). The output color depends on the Color Node's value, so changing it to red updates the output.
What happens if I don't connect the Multiply Node to the Output?
The shader won't output the Multiply Node's result, so the final color remains default or black (see execution_table step 4). Connections define the data flow.
Why do I need to compile the shader after setting nodes?
Compiling processes the graph into GPU code so changes take effect (see execution_table step 6). Without compiling, changes won't appear in the material.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the Color Node value after step 3?
ABlack
BRed
CWhite
DNone
💡 Hint
Check the 'Color Node Value' in variable_tracker after step 3.
At which step is the Multiply Node connected to the Output?
AStep 2
BStep 4
CStep 3
DStep 5
💡 Hint
Look at the 'Connections' column in execution_table for when Multiply Output connects to Master Node.
If you change the Color Node to blue instead of red at step 5, what would the final output color be?
ABlue
BWhite
CRed
DBlack
💡 Hint
The output color follows the Color Node value as shown in variable_tracker and execution_table.
Concept Snapshot
Shader Graph basics:
- Create nodes (Color, Multiply, Output)
- Connect nodes to define data flow
- Set node properties (e.g., color)
- Compile shader to apply changes
- Assign shader to material to see effect
Full Transcript
Shader Graph basics start by creating nodes like Color and Multiply. You connect these nodes to define how data flows from inputs to output. Initially, the Color Node defaults to white, so the output color is white. When you set the Color Node to red, the output color updates to red. Connecting the Multiply Node to the Output node is essential for the shader to produce the final color. After setting nodes and connections, compiling the shader processes these changes so they take effect. Finally, applying the shader to a material lets you see the color change in the scene. This step-by-step process helps beginners understand how Shader Graph works visually and practically.