DEV Community

Cover image for Unity Visual Effect Graph Guide - Everything That You Need to Know
Ramsingh Manek
Ramsingh Manek

Posted on

Unity Visual Effect Graph Guide - Everything That You Need to Know

Unity's Visual Effect Graph (VFX Graph) is a powerful tool that enables game developers to create stunning particle effects that enhance the visual fidelity of their games.

It provides a flexible and customizable framework that allows for the creation of advanced particle systems that can be used to add depth, detail, and immersion to games.

In this blog post, we'll explore how to create advanced particle systems using Unity's VFX Graph.

What is a Particle System?

A particle system is a collection of small, dynamic objects, known as particles, that are used to simulate various effects, such as fire, smoke, explosions, and more.

A particle system consists of a set of rules that govern how particles are generated, their lifespan, movement, color, and other properties.

The rules are defined by a set of parameters that can be adjusted to create different effects.

What is Unity's Visual Effect Graph?

Unity's Visual Effect Graph (VFX Graph) is a powerful tool that allows developers to create complex particle systems with a high degree of control and flexibility.

It is a node-based visual scripting tool that enables developers to create stunning particle effects quickly and easily. 

VFX Graph is built on top of Unity's High Definition Render Pipeline (HDRP), which provides enhanced visual quality and rendering capabilities.

Creating a Simple Particle System

To get started with VFX Graph, let's create a simple particle system that emits particles from a point in space. 

Here's how:

↪Create a new Unity project and import the HDRP package if it's not already installed.

↪Create a new VFX Graph asset by right-clicking in the Project window and selecting Create > Visual Effects > Visual Effect Graph.

↪Open the VFX Graph asset by double-clicking it in the Project window. This will open the VFX Graph editor.

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Context > Spawn.

↪In the Spawn node, set the Spawn Count parameter to 10 and the Spawn Rate parameter to 1.

↪Right-click in the graph view again and select Create Node > Output > Output Particle System.

↪Connect the Spawn node to the Output Particle System node by dragging a connection from the Spawn node's output port to the Output Particle System node's input port.

↪Save the VFX Graph asset by pressing Ctrl+S or by selecting File > Save.

↪Create a new GameObject in the Scene view by right-clicking and selecting Create > Empty.

↪Add a Visual Effect component to the GameObject by selecting Add Component > Effects > Visual Effect.

↪In the Visual Effect component, select the VFX Graph asset that you just created.

↪Play the scene, and you should see particles being emitted from the GameObject's position.

Advanced Particle Systems

Now that you know how to create a basic particle system in VFX Graph let's explore some more advanced techniques that you can use to create more complex effects.

Particle Trails

Particle trails are a common effect used in games to create the illusion of movement.

They are often used for things like rockets, bullets, and other fast-moving objects.

To create a particle trail effect in VFX Graph, you can use the Trail Renderer node.

Here's how:

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Renderer > Trail Renderer.

↪Connect the Trail Renderer node to the Spawn node by dragging a connection from the Spawn node's output port to the Trail Renderer node's input port.

↪In the Trail Renderer node, set the Trail Length parameter to 1 and adjust other parameters to your liking.

↪Save the VFX Graph asset and play the scene.

Particle Collisions

Particle collisions can add a sense of realism to particle systems by creating interactions between particles and other objects in the scene.

To create a particle collision effect in VFX Graph, you can use the Collision node.

Here's how:

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Context > Collision.

↪Connect the Collision node to the Spawn node by dragging a connection from the Spawn node's output port to the Collision node's input port.

↪In the Collision node, adjust the Collision Type and other parameters to your liking.

↪Save the VFX Graph asset and play the scene.

Particle Textures

Using textures in particle systems can create more interesting and detailed effects.

To use textures in VFX Graph, you can use the Texture Sheet Animation node.

Here's how:

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Texture > Texture Sheet Animation.

↪Connect the Texture Sheet Animation node to the Spawn node by dragging a connection from the Spawn node's output port to the Texture Sheet Animation node's input port.

↪In the Texture Sheet Animation node, select a texture sheet and adjust other parameters to your liking.

↪Save the VFX Graph asset and play the scene.

Particle Forces

Using forces in particle systems can create more dynamic and realistic effects.

To apply forces to particles in VFX Graph, you can use the Force Field node.

Here's how:

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Context > Force Field.

↪Connect the Force Field node to the Spawn node by dragging a connection from the Spawn node's output port to the Force Field node's input port.

↪In the Force Field node, adjust the Force Type, Force Strength, and other parameters to your liking.

↪Save the VFX Graph asset and play the scene.

Custom Shaders

To create truly unique and customized particle effects, you can use custom shaders in your VFX Graph.

You can create a custom shader that defines how particles are rendered and then use it in your VFX Graph to create the desired effect.

Here's how:

↪Create a new shader asset by right-clicking in the Project window and selecting Create > Shader.

↪Write a custom shader using ShaderLab syntax that defines how particles are rendered.

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Renderer > Custom.

↪Connect the Custom node to the Spawn node by dragging a connection from the Spawn node's output port to the Custom node's input port.

↪In the Custom node, select the custom shader asset you created earlier.

↪Save the VFX Graph asset and play the scene.

Audio Reactivity

You can use audio reactivity in your particle systems to create effects that respond dynamically to the game's sound effects and music.

To create an audio-reactive particle system in VFX Graph, you can use the Audio Spectrum node.

Here's how:

↪In the VFX Graph editor, right-click in the graph view and select Create Node > Context > Audio Spectrum.

↪Connect the Audio Spectrum node to the Spawn node by dragging a connection from the Spawn node's output port to the Audio Spectrum node's input port.

↪In the Audio Spectrum node, adjust the parameters to your liking.

↪Save the VFX Graph asset and play the scene with audio.

Conclusion

Unity's Visual Effect Graph provides a powerful and flexible framework for creating advanced particle systems that can add depth, detail, and immersion to your games.

By using techniques like particle trails, collisions, textures, and forces, you can create stunning visual effects that enhance the overall quality of your game.

So go ahead and experiment with Unity's VFX Graph to create your amazing particle systems!

Hope you like the Article, If you have any queries you can connect with our Unity Developers!

Top comments (5)

Collapse
 
vambier profile image
Vambier

I got a question about the collisions, as far as I can see there is no node for this:

In the VFX Graph editor, right-click in the graph view and select Create Node > Context > Collision.

I've been searching the web and everyone is saying that this is impossible since the VFX graph calculates particles on the GPU and the physics are calculated on the CPU.

Is the method you're describing really possible? I'm looking for something like that since collisions worked really well in the old particle system.

Collapse
 
hardikparmar1 profile image
Hardik Parmar

Image description

The latest unity version deprecated some colision method. You can use colision using Right-Click on Update Particle and select Create Block > Collision

Collapse
 
vambier profile image
Vambier

Thanks for the reply! But that way you can only collide particles with pre-defined geometry, not with the scene right?

Collapse
 
raiyan profile image
Raiyan Sunasara

Best Remote Team is a business that specializes in the creation and development of mobile applications for various platforms such as iOS, Android, and Windows. These companies provide end-to-end services that include ideation, design, development, testing, deployment, and ongoing maintenance of mobile applications.

Collapse
 
abhisham profile image
Abhi Shah • Edited

Quite An Informative Blog Keep Posting!!!