t1k:unity:rendering:vfx-graph
| Field | Value |
|---|---|
| Module | rendering |
| Version | 3.1.7 |
| Effort | medium |
| Tools | — |
Keywords: particle, unity, VFX Graph, visual effects
How to invoke
Section titled “How to invoke”/t1k:unity:rendering:vfx-graphUnity VFX Graph — GPU Particle Effects
Section titled “Unity VFX Graph — GPU Particle Effects”Visual Effect Graph reference for Unity 6 (com.unity.visualeffectgraph). GPU-based, node-graph particle system.
VFX Graph vs Particle System
Section titled “VFX Graph vs Particle System”| Feature | VFX Graph | Particle System |
|---|---|---|
| Simulation | GPU (compute shader) | CPU |
| Particle count | Millions | Thousands |
| Node graph editor | Yes | Inspector-based |
| Mobile support | Requires compute shaders | Full support |
Rule: Use VFX Graph for high-count effects (rain, fire, magic, debris). Use Particle System for simple mobile-friendly effects.
C# Integration
Section titled “C# Integration”using UnityEngine.VFX;
public class VFXController : MonoBehaviour { [SerializeField] VisualEffect vfx; VFXEventAttribute hitAttr; // cache once, reuse per-call
void Start() { vfx.Play(); vfx.Stop(); vfx.Reinit();
vfx.SetFloat("SpawnRate", 100f); vfx.SetVector3("EmitPosition", transform.position); vfx.SetVector4("Color", new Vector4(1, 0, 0, 1)); vfx.SetTexture("MainTex", myTexture); vfx.SetBool("EnableTrails", true);
// CACHE event attribute once — never call CreateVFXEventAttribute() per-event. hitAttr = vfx.CreateVFXEventAttribute();
int aliveCount = vfx.aliveParticleCount; }
void OnHit(Vector3 hitPos) { // Reuse cached hitAttr — overwrite values per-call. hitAttr.SetVector3("position", hitPos); hitAttr.SetFloat("damage", 50f); vfx.SendEvent("OnHit", hitAttr); }}Key Gotchas
Section titled “Key Gotchas”- Requires compute shaders: Won’t work on low-end mobile GPUs (OpenGL ES 3.0 minimum)
- Exposed properties must be explicitly exposed: Right-click property → “Expose” in graph
- Event attributes not cached: Create
VFXEventAttributeonce, reuse - SRP only: Requires URP or HDRP — won’t work with Built-in RP
- Particle System prefab warning: VFX Graph assets are
.vfx, not.prefab
→ Full architecture (Spawn/Init/Update/Output contexts), events, property binders, effect recipes (Fire/Rain/Explosion/Magic), performance tips: references/architecture-and-recipes.md
Related Skills & Agents
Section titled “Related Skills & Agents”unity-urp— Render pipeline integrationunity-shader-graph— Custom VFX shadersunity-mobile— Mobile VFX optimization
Reference Files
Section titled “Reference Files”| File | Contents |
|---|---|
| architecture-and-recipes.md | Spawn/Init/Update/Output contexts, events, property binders, effect recipes, performance tips, gotchas |