What is VFX Graph?
VFX Graph (Visual Effect Graph) is a node-based tool in the Unity Editor for creating visual effects such as fire, smoke, sparks, and magic by simulating particles on the GPU, enabling complex effects with large numbers of particles in real time.
VFX Graph is one of Unity's graphics tools, alongside Shader Graph, and works with projects that use the Universal Render Pipeline (URP) or the High Definition Render Pipeline (HDRP).
How does VFX Graph work?
A VFX Graph is built from several core parts:
- Contexts: Stacked stages that control different parts of a particle system, from spawning to output and rendering.
- Blocks: Small operations within a context, such as setting velocity, adding turbulence, or changing color over time.
- Operators: Nodes that calculate or modify values, such as noise, math, or random numbers, and provide them to other parts of the graph.
- Properties: Exposed values, such as spawn rate or color, that designers can adjust without changing the graph's underlying logic.
- Events: Signals that can trigger effects, such as spawning particles or starting an effect, from sources such as C# scripts or Timeline.
Unity saves the graph as a Visual Effect Asset, which can be added to a scene through a Visual Effect component.
What are the contexts in a VFX Graph?
A typical VFX Graph uses four core contexts to control a particle effect from spawning through rendering:
Context
Spawn
What it controls
How many particles are created and when, such as at a constant rate or in a single burst
Initialize
What it controls
Each particle's starting values, such as position, velocity, size, and lifetime
Update
What it controls
How particles change over time, such as through gravity, drag, turbulence, or collisions
Output
What it controls
How particles are rendered, such as with quads, meshes, or lines, and which shader is used
Context
What it controls
Spawn
How many particles are created and when, such as at a constant rate or in a single burst
Initialize
Each particle's starting values, such as position, velocity, size, and lifetime
Update
How particles change over time, such as through gravity, drag, turbulence, or collisions
Output
How particles are rendered, such as with quads, meshes, or lines, and which shader is used
What is VFX Graph used for?
- Fire, smoke, and explosions: Build dense, layered effects such as fire, smoke, explosions, and other volumetric-looking effects.
- Magic and sci-fi effects: Create spells, portals, energy trails, holograms, and other stylized effects for games.
- Weather and environments: Fill scenes with rain, snow, dust, embers, fireflies, and other environmental effects.
- Impacts and feedback: Trigger sparks, debris, flashes, and other effects in response to gameplay events.
- Visualization: Represent point clouds, simulations, and other data as particles for visualization, industrial, and XR applications.
What is the difference between VFX Graph and the Built-in Particle System?
Unity provides two primary particle systems, with a key difference being where particle simulation runs:
Simulation
VFX Graph
GPU
Built-in Particle System
CPU
Particle count
VFX Graph
Designed for large numbers of particles
Built-in Particle System
Generally better suited to smaller particle effects
Authoring
VFX Graph
Node graph
Built-in Particle System
Modules in the Inspector
Render pipelines
VFX Graph
URP and HDRP
Built-in Particle System
Built-in, URP, and HDRP
Physics
VFX Graph
Supports GPU-based particle collisions using scene depth and collision shapes
Built-in Particle System
Can interact with Unity's physics system
Scripting
VFX Graph
Exposed properties and events
Built-in Particle System
C# scripting and particle data access
VFX Graph
Built-in Particle System
Simulation
GPU
CPU
Particle count
Designed for large numbers of particles
Generally better suited to smaller particle effects
Authoring
Node graph
Modules in the Inspector
Render pipelines
URP and HDRP
Built-in, URP, and HDRP
Physics
Supports GPU-based particle collisions using scene depth and collision shapes
Can interact with Unity's physics system
Scripting
Exposed properties and events
C# scripting and particle data access
What are the benefits of VFX Graph?
- Large particle counts: GPU-based simulation can support effects with large numbers of particles and complex visual behavior.
- Visual authoring: Artists can create complex particle behavior by connecting nodes instead of writing code for every effect.
- Real-time previews: Changes to the graph can be previewed directly in the Unity Editor as effects are developed.
- Reusable building blocks: Subgraphs let teams package reusable logic and use it across multiple visual effects.
What are the challenges of VFX Graph?
- Hardware requirements: VFX Graph relies on GPU features such as compute shaders, which limits compatibility with some lower-end or older hardware.
- Gameplay interaction: VFX Graph uses GPU-based simulation rather than Unity's standard physics system, so gameplay interactions and particle data access work differently from the Built-in Particle System.
- GPU performance: Complex effects can consume significant GPU resources, so effects should be profiled on target hardware to balance visual quality and performance.