Shader Graph
- Game Development course
- Advanced
- Lesson 2/71
- 4 min
Learn to create shaders visually with Shader Graph.
Visual Development with Shader Graph
Shader Graph is a Unity tool that enables you to create shaders using visual nodes and connections without writing lines of code. It is natively used across Scriptable Render Pipelines like URP and HDRP.
// Shader Graph generates optimized HLSL code in the background
// Provides instant real-time previews for artists and developersBy connecting nodes, you can preview mathematical operations, texture blends, and lighting responses in real time.
Nodes and the Master Stack
Every operation in Shader Graph is represented as a Node (e.g., Multiply, Lerp, Sample Texture 2D). The data produced by these nodes is ultimately connected to the Master Stack inputs.
// Master Stack is split into two primary blocks:
// 1. Vertex: Object position and vertex deformation
// 2. Fragment: Final surface pixel colorExposed parameters (color, float, texture) added via the Blackboard panel allow material customization in the Inspector.
Practice Shader Graph workflow
Define a Start method. Inside, print the text "Shader Graph gorsel dugumlerle calisir" using Debug.Log.
Starter code
using UnityEngine;
public class GraphLogger : MonoBehaviour
{
// Start metodunu tanimla ve Shader Graph bilgisini yazdir
}Sample solution
using UnityEngine;
public class GraphLogger : MonoBehaviour
{
void Start()
{
Debug.Log("Shader Graph gorsel dugumlerle calisir");
}
}Expected output
Shader Graph gorsel dugumlerle calisir
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the most prominent advantage of using Shader Graph compared to traditional code writing?
- Allowing editing of only 2D audio files
- Always reducing the game disk size to zero
- Using only the main processor (CPU) instead of the GPU
- Developing shaders with visual nodes and real-time preview without writing code Correct answer
Explanation: Shader Graph eliminates the need for manual coding through visual nodes and immediate real-time previews.
2 Assigning texture to material
material.Set____("_BaseMap", texture);
material.SetTexture("_BaseMap", texture);
Explanation: To assign a texture to a material via code, the SetTexture method is called.
3 Shader Graph components
| Term | Meaning |
|---|---|
Node |
Mathematical or textural operation node |
Master Stack |
Final vertex and fragment output block |
Blackboard |
List of exposed parameters |
Graph Inspector |
Settings panel for the selected node |