7
\$\begingroup\$

I'm working with particles and little bit with shader. Both of them can do the same task like creating effects of flame, snow, glowing ...

So which one is better and what are differences between them?

\$\endgroup\$

1 Answer 1

5
\$\begingroup\$

This will depend a lot on the specific effect you're trying to achieve.

As one example, here's a pair of fire effects created by Edward del Villar. The one on the left uses particles, while the one on the right is a LineRenderer with a custom shader:

Two fire effects by Edward del Villar

Because the version on the right is rendering on a continuous ribbon of geometry provided by the LineRenderer, it's able to bend and swish fluidly, while the particle solution visibly breaks up in motion, revealing the individual cards that make it up.

A particle system can be made more fluid/continuous by increasing the number of particles, but this can quickly eat into the fillrate available for the frame (drawing & blending over the same pixel multiple times instead of only once). This is especially concerning on mobile devices, so if you can make a shader that gives a similar effect in just one pass, it will often be faster (as long as the shader itself isn't too heavy)

But, the discrete particles also make it easier to make a chunky/cartoony stylized look to the flames, or create complex motion like swirling vortices and turbulence or sparks bouncing off walls. So if those aspects are important to your game's visual direction, particles could be a better choice.

Like everything in game development, there are many ways to achieve an effect, so with enough time investment we could probably give more fluid motion to the particle version, or more chunky art direction or complex animation to the shader version. More often than not, it will come down to which style makes it easier to get the effect you want quickly & reliably, since there are so many other features to work on. ;)


Finally, it's important to remember that these two tools aren't mutually exclusive, and you can often make spectacular effects by rendering custom shaders on particles themselves, on accompanying geometry, or in post-process effects on top of the particles, to compliment and enhance the visuals.

Check out this presentation on VFX used in Infamous Second Son for lots of inspirations for how shaders and particles can act in concert for beautiful results.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ How's about the performance? While shader run on gpu and particles seems to run on CPU? \$\endgroup\$
    – TomSawyer
    Mar 21, 2017 at 9:36
  • 1
    \$\begingroup\$ Not exactly. Many engines do their particle updates on the CPU (stepping their movements, size/colour/texture animation, aging existing particles, emitting new ones), but the result is still a batch of geometry that gets rasterized & rendered by the GPU. There are also systems that run particle simulations fully GPU-side. Like many things in games, it's hard to say categorically "this will always have better performance than that" — it will depend on your effect and what hardware you're running on, so profiling is always the best way to know for sure. \$\endgroup\$
    – DMGregory
    Mar 21, 2017 at 12:11
  • \$\begingroup\$ In the case of Unity for mobile you're limited to shaders running on GPU and particle systems on CPU. For the future the VFX Graph workflow may be available for mobile but for now it's only available for high end PCs and consoles. \$\endgroup\$
    – netlander
    Feb 10 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .