Overview
"I want to display tons of particles..." "I want to create explosion and magic effects..." "I need more advanced visual effects..."
In game development, you often face these kinds of visual effect challenges. VFX Graph is Unity's official visual effect creation tool. It uses node-based visual logic to create effects and leverages a GPU-based particle system to display massive amounts of particles with high performance.
Differences from Legacy Particle System
Particle System (Shuriken)
- CPU-based particle system
- Has been in Unity since the early days
- Configured via the Inspector
- Module-based design
- Supports collision detection
- Easy to set up, extensive documentation available
- Performance degrades with high counts (limited to a few thousand)
VFX Graph
- GPU-based particle system
- Configured via a node-based graph
- Can display massive amounts of particles (millions possible)
- Limited collision detection
- Steeper learning curve
- Integrates with Shader Graph
- Enables more advanced visual effects
Performance Comparison
| Scenario | Recommended System |
|---|---|
| Displaying massive particles in a single system | VFX Graph (significantly lighter) |
| Displaying many different effects simultaneously | Particle System (can be lighter) |
| Placing many instances of the same effect | VFX Graph (light with instancing) |
When to Use Which
Use VFX Graph when:
- You need massive particle counts (explosions, fire, smoke, magic, etc.)
- Advanced visual effects are required
- You want to integrate with Shader Graph
- You need many instances of the same effect
Use Particle System when:
- Collision detection is needed
- You want quick setup
- Simple effects are sufficient
- You need many different effects simultaneously
VFX Graph Basic Structure
Two Core Elements
VFX Graph consists of two elements.
| Element | Description |
|---|---|
| Visual Effect Component | Attached to a GameObject |
| Visual Effect Asset | Stores the effect configuration |
Four Context Nodes
Data flows from top to bottom through VFX Graph nodes.
1. Spawn Context Node
Determines the number of particles to generate per frame and passes them to Initialize Particle.
- Constant Spawn Rate - Issues Spawn events at a constant rate
- Burst - Generates a large number of particles at once
Other Spawn blocks:
Periodic Burst(bursts at regular intervals),Variable Spawn Rate(dynamically varying spawn rate), and more are also available.
2. Initialize Particle Context Node
Initializes particles.
- Capacity - Maximum number of particles that can exist simultaneously (see guidelines below)
Platform-specific Capacity Guidelines:
| Platform | Practical Capacity Range | Notes |
|---|---|---|
| High-end PC | 1M - 5M | Highly dependent on GPU performance |
| Mid-range PC | 100K - 500K | |
| Console | 100K - 1M | Varies by platform |
| Mobile | 10K - 50K | Also consider heat and battery |
Estimating Capacity: Capacity is the "maximum simultaneous count." Estimate the actual display count from spawn rate x lifetime. Setting it too high wastes VRAM.
- Set LifeTime - Particle lifetime
- Set Position Shape - Initial particle position (generated from a shape)
- Set Velocity - Initial particle velocity
3. Update Particle Context Node
Handles per-frame particle updates.
- Gravity - Applies gravity
- Linear Drag - Applies drag
- Force - Applies force
- Collision - Collision detection (limited)
4. Output Particle Context Node
Configures the final rendering of particles.
Output types:
| Output | Usage |
|---|---|
| Output Particle Quad | Billboard quad (most common) |
| Output Particle Mesh | Uses a 3D mesh |
| Output Particle Strip | Trail/ribbon effects |
| Output Particle Point | Point sprites |
Key blocks:
- Orient - Particle orientation (billboard, etc.)
- Set Size Over Life - Size change over lifetime
- Set Color Over Life - Color change over lifetime
- Main Texture - Texture to use
- Blend Mode - Alpha blending settings
Installation
- Open Window > Package Manager
- Select Unity Registry
- Select Visual Effect Graph
- Click the Install button
Additional Setup for URP Projects
Version note: In URP 14+ (Unity 2023.1+), VFX Graph works without special configuration. The following steps are for earlier versions.
For URP projects, you may need to configure the URP Asset.
- Select the URP Asset (Universal Render Pipeline Asset)
- Select the Renderer you're using from Renderer List
- Verify that VFX Graph is enabled under Renderer Features
Basic Usage
Creating an Effect
- Select GameObject > Visual Effects > Visual Effect
- A game object with a Visual Effect component is created
- Click the "New" button on the Visual Effect component
- Select a template (Simple Loop, Burst, Continuous, etc.)
- Save with a file name
Editing the Graph
- Double-click the Visual Effect Asset in the Project window
- The VFX Graph window opens
- Add and edit nodes to customize the effect
Using Learning Templates
You can learn from Unity's official learning templates.
- Select Assets > Create > Visual Effects > Visual Effect Graph
- In the Create New VFX Asset window, click "Install Learning Templates"
- Various templates are added
Script Control
Sending Events
using UnityEngine;
using UnityEngine.VFX;
public class VFXController : MonoBehaviour
{
VisualEffect visualEffect;
void Start()
{
visualEffect = GetComponent<VisualEffect>();
}
public void Play()
{
// Default event
visualEffect.SendEvent(VisualEffectAsset.PlayEventName); // OnPlay
}
public void Stop()
{
visualEffect.SendEvent(VisualEffectAsset.StopEventName); // OnStop
}
public void SendCustomEvent()
{
// Custom event
visualEffect.SendEvent("CustomEventName");
}
}
High-Performance Approach (Using IDs)
public static readonly int CustomEventID = Shader.PropertyToID("CustomEventName");
void SendEvent()
{
visualEffect.SendEvent(CustomEventID);
}
Setting Properties
You can set properties defined in the VFX Graph Blackboard from scripts.
// Setting various properties
visualEffect.SetFloat("SpawnRate", 100f);
visualEffect.SetVector3("EmitterPosition", transform.position);
visualEffect.SetTexture("MainTexture", myTexture);
visualEffect.SetGradient("ColorGradient", myGradient);
// Getting properties
float rate = visualEffect.GetFloat("SpawnRate");
// Debug: Check current particle count
// aliveParticleCount uses GPU Readback,
// so there is a 1-2 frame delay.
// If particles don't have a Lifetime set,
// all particles remain alive permanently.
int aliveCount = visualEffect.aliveParticleCount;
Exposed Property: When creating a property in the Blackboard, it must have Exposed checked to be accessible from scripts.
Performance: For frequently called properties, pre-cache the ID with
Shader.PropertyToID()and useSetFloat(int id, float value).
Sending Events with Parameters
Use VFXEventAttribute to dynamically pass parameters like position and color.
public void SpawnAtPosition(Vector3 position, Color color)
{
VFXEventAttribute eventAttribute = visualEffect.CreateVFXEventAttribute();
eventAttribute.SetVector3("position", position);
eventAttribute.SetVector4("color", new Vector4(color.r, color.g, color.b, color.a));
visualEffect.SendEvent("OnSpawn", eventAttribute);
}
VFX Graph side setup: In the Initialize Particle context, add
Get Source Attributeblocks (position, color, etc.) to receive parameters passed from the Event.
Preventing Auto-Play on Start
Use one of the following methods:
- Set Initial Event Name to empty - Disables auto-play
- Set Initial Event Name to a custom event name - Won't start until you manually send the event
Common Use Cases
Large-Scale Particle Effects
- Explosions, fire, smoke
- Magic effects
- Rain, snow
- Starfields, fireworks
Environmental Effects
- Fog
- Leaves blowing in the wind
- Dust
- Fireflies
UI Effects
- Button particles
- Transitions
- Background effects
System Requirements
Supported Render Pipelines
| Pipeline | Support |
|---|---|
| Universal Render Pipeline (URP) | Yes |
| High Definition Render Pipeline (HDRP) | Yes |
| Built-in Render Pipeline | Partial (limited support from Unity 6+) |
Built-in RP support: From Unity 6 onward, VFX Graph can be used with the Built-in Render Pipeline, though some features have limitations. URP/HDRP is recommended for new projects.
Supported Platforms
- PC (Windows, Mac, Linux)
- Consoles (PlayStation, Xbox)
- Mobile (iOS, Android) - with some limitations
- WebGL - with some limitations
GPU Requirements
- GPU with Compute Shader support
- DirectX 11+, OpenGL ES 3.1+, Vulkan, Metal
Mobile Considerations
| Item | Recommended Value |
|---|---|
| Minimum requirement | OpenGL ES 3.1+ (Android) / Metal (iOS) |
| Particle count | 10K-50K is a practical upper limit |
| Capacity setting | Keep to the minimum necessary |
Mobile optimization: On mobile, set Capacity low and avoid complex node graphs. Older devices may not support Compute Shaders.
Key mobile limitations:
- Output Particle Strip may not be supported
- Won't work on older devices without Compute Shader support
- SampleGradient node precision may be lower
- GPU throttling is more likely due to device heat
Shader Graph Integration
VFX Graph integrates with Shader Graph, allowing particles to be rendered with custom shaders.
Integration Steps
- Create a Shader Graph: Create a VFX Graph-specific Shader Graph
- URP:
Create > Shader Graph > URP > VFX Shader Graph - HDRP:
Create > Shader Graph > HDRP > VFX Shader Graph
- URP:
- Configure Output: Select the
Shader Graphoption in the Output Particle context - Assign the shader: Drag and drop the VFX Shader Graph
Use cases: Distortion, custom lighting, special warp effects, and other expressions that can't be achieved with standard blend modes.
Using SDF (Signed Distance Field)
A distinctive VFX Graph feature is the ability to use SDFs for particle generation and collision detection that follow mesh shapes.
Use Window > Visual Effects > Utilities > SDF Bake Tool to generate SDF textures from meshes.
Output Event
You can send events to C# when particles are destroyed. Use this for displaying damage numbers, triggering sound playback, etc.
Important Notes
Collision Detection Limitations
VFX Graph's collision detection is limited. Use Particle System when complex collision is required.
Learning Curve
Being node-based, there's a steep initial learning curve. If you're used to Particle System, it may feel unfamiliar at first. Learning Templates are recommended for getting started.
Render Pipeline
URP or HDRP is recommended. While Built-in Render Pipeline has limited support from Unity 6 onward, some features have restrictions.
Summary
VFX Graph is a GPU-based high-performance particle system.
- GPU-based - Display massive particles with high performance (millions possible)
- Node-based - Create effects with visual logic
- Shader Graph integration - Works with custom shaders
- Four contexts - Composed of Spawn, Initialize, Update, and Output
| Use Case | Recommended System |
|---|---|
| Massive particles, advanced visuals | VFX Graph |
| Collision detection, simple effects | Particle System |
Choose the appropriate particle system based on your project's requirements.