Reader small image

You're reading from  Hands-On Unity Game Development - Fourth Edition

Product typeBook
Published inJan 2024
PublisherPackt
ISBN-139781835085714
Edition4th Edition
Tools
Right arrow
Authors (2):
Nicolas Alejandro Borromeo
Nicolas Alejandro Borromeo
author image
Nicolas Alejandro Borromeo

Nicolas is a Game Developer currently working as a Senior Software Development Consultant for Unity in London. He is a Unity Certified Instructor teaching Unity clients all around the globe. He started using Unity in 2008 and teaching it in 2012 in several Universities and Education Institutes.
Read more about Nicolas Alejandro Borromeo

Juan Gabriel Gomila Salas
Juan Gabriel Gomila Salas
author image
Juan Gabriel Gomila Salas

Juan graduated in mathematics with a master's degree in Teacher Training, specializing in Game Design for social casino video games and as a video game developer using Unity and Unreal Engine for both PC and mobile. He was an online teacher on Udemy from 2015 to 2022 and subsequently on his own platform Frogames Training with over 150 online courses and over 500,000 students across 130 countries.
Read more about Juan Gabriel Gomila Salas

View More author details
Right arrow

Captivating Visual Effects: Harnessing Particle Systems and Visual Effect Graph

In this chapter, we will continue learning about visual effects for our game. We will be discussing particle systems, which are a way to simulate fire, waterfalls, smoke, and all kinds of fluids. We will see two Unity particle systems to create these kinds of effects, Shuriken and Visual Effect (VFX) Graph, the latter being more powerful than the first but requiring more hardware. These technologies are used widely in different games to simulate all kinds of effects, like explosions and gun muzzles in war games such as Battlefield or magic effects, as in Hogwarts Legacy.

In this chapter, we will cover the following particle system topics:

  • Introduction to particle systems
  • Creating fluid simulations
  • Creating complex simulations with Visual Effect Graph

Introduction to particle systems

All graphics and effects we have created so far use static meshes—3D models that can’t be skewed, bent, or deformed in any way other than by using shaders. Fluids such as fire and smoke can’t always be represented using this kind of mesh, but we can simulate these effects with a combination of static meshes, and this is where particle systems are useful.

Particle systems are objects that emit and animate lots of particles or billboards, which are simple quad meshes that face the camera. Each particle is a static mesh, but rendering, animating, and combining lots of them can generate the illusion of a fluid.

In Figure 11.1, you can see a smoke effect using particle systems on the left, and on the right, the Wireframe view of the same particles. There, you can see the quads that create the illusion of smoke, which is done by applying a smoke texture to each of the particles and animating them, so they spawn at the bottom...

Creating fluid simulations

As we said, the best way to learn how to create particle systems is to keep looking for already-created particle systems and explore how people have used the various system settings to create completely different simulations.

In this section, we will learn how to create the following effects using particle systems:

  • A waterfall effect
  • A bonfire effect

Let’s start with the simplest one, the waterfall effect.

Creating a waterfall effect

In order to do this, follow these steps:

  1. Create a new particle system (GameObject | Effects | Particle System).
  2. Set Shape to Edge and Radius to 5 in the Shape module. This will make the particles spawn along a line of emission:

Figure 11.22: Edge shape

  1. Set the Rate over Lifetime value of the Emission module to 50.
  2. Set the Start Size of the Main module to 3 and Start Lifetime to 3:

Figure 11.23: Main module settings

...

Creating complex simulations with Visual Effect Graph

The particle system we have used so far handles all calculations in the CPU. This has both pros and cons. A pro is that it can run on all possible devices that Unity supports, regardless of their capabilities (all of them have CPUs), but a con is that we can exceed CPU capabilities easily if we are not cautious with the number of particles we emit.

Modern games require more complex particle systems to generate believable effects, and this kind of CPU-based particle system solution has started to reach its limit. This is where Visual Effect Graph comes in:

Figure 11.33: On the left is a massive particle system, and on the right, an example of a Visual Effect Graph

Visual Effect Graph is a GPU-based particle system solution, meaning that the system is executed in the video card instead of the CPU. That’s because video cards are far more efficient at executing lots and lots of little simulations, like the...

Summary

In this chapter, we discussed two different ways to create particle systems: using regular particle systems and VFX Graph. We used them to simulate different fluid phenomena, such as fire, a waterfall, smoke, and rain. The idea is to combine particle systems with meshes to generate all the possible props needed for your scene. Also, as you can imagine, creating these kinds of effects professionally requires you to go deeper.

If you want to dedicate yourself to this (another part of the job of a technical artist), you will need to learn how to create your own particle textures to get the exact look and feel you want, code scripts that control certain aspects of the systems, and several other aspects of particle creation. However, that is outside the scope of the book.

Now that we have some rain in our scene, we can see that the sky and the lighting in the scene don’t really reflect a rainy day, so let’s fix that in the next chapter!

Learn more on...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Unity Game Development - Fourth Edition
Published in: Jan 2024Publisher: PacktISBN-13: 9781835085714
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime

Authors (2)

author image
Nicolas Alejandro Borromeo

Nicolas is a Game Developer currently working as a Senior Software Development Consultant for Unity in London. He is a Unity Certified Instructor teaching Unity clients all around the globe. He started using Unity in 2008 and teaching it in 2012 in several Universities and Education Institutes.
Read more about Nicolas Alejandro Borromeo

author image
Juan Gabriel Gomila Salas

Juan graduated in mathematics with a master's degree in Teacher Training, specializing in Game Design for social casino video games and as a video game developer using Unity and Unreal Engine for both PC and mobile. He was an online teacher on Udemy from 2015 to 2022 and subsequently on his own platform Frogames Training with over 150 online courses and over 500,000 students across 130 countries.
Read more about Juan Gabriel Gomila Salas