Game Development
Shader Graph
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 developers
By 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 color
Exposed parameters (color, float, texture) added via the Blackboard panel allow material customization in the Inspector.
Exercise Shader Graph workflow
Define a Start method. Inside, print the text "Shader Graph gorsel dugumlerle calisir" using Debug.Log.
Show example solution
using UnityEngine;
public class GraphLogger : MonoBehaviour
{
void Start()
{
Debug.Log("Shader Graph gorsel dugumlerle calisir");
}
}
Test yourself
-
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
Show answer
Developing shaders with visual nodes and real-time preview without writing code — Shader Graph eliminates the need for manual coding through visual nodes and immediate real-time previews.
-
Assigning texture to material
material.Set____("_BaseMap", texture);
Show answer
material.SetTexture("_BaseMap", texture);
-
Shader Graph components
- 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
Next lesson: Surface Shader