V(ulcanix)FX (Part II)

Updated: Aug 22, 2019

Today I'm going to talk about particle effects. Much like shaders, and really anything in Unity, you can achieve some really cool stuff depending on the amount of work and customization you are willing to put in. Besides some simple screen-obscuring smoke clouds in both Fix It With Fractions and Spellbound, this was the first time I've worked with particle effects, and the first time it was up to me alone to decide the feeling I was going for, and to try and execute it by playing with all the numbers.

Vulcanix is all about atmosphere. I started with a thick, dark smoke plume coming out of the main volcano. As I said before, there are a ton of different settings you can use to change the look of your particle effect, but the ones that make the greatest difference are thankfully the most straightforward. Color, size, and lifetime are all applied to individual particles, while emission rate and shape [of the general area where they will spawn] change how the system as a whole behaves. Now, the most important part is what material is applied. In simplest terms, this defines what the particle is: Unity's default sphere, a cloud, a star, a smoke wisp... The problem (for someone like me, anyway) is that the materials are created with a base sprite, the opacity or greyscale values of which define the different shapes. In other words, if I want my individual particles to look like smoke wisps, I need a black-and-white image of a smoke wisp as a template for them. A few Photoshop tutorials later, and we're all good. The material really defines what your end effect will look like, so it's important to get this part right. The material's shader also plays a part, as it controls how the particles look when they're all blended together and viewed over top of one another. I found the built-in "Alpha Blended Premultiply" one to do the job.

Those basic settings may be all that you need, but there are tons of others, ranging from "Size By Speed" to defining worldspace collisions, many of which can be set using random seeds or even curves. The one extra thing I added to my system was "Color Over Lifetime", which allowed me to tweak the alpha and fade my particles in and out, so they don't appear to just pop into existence. Putting it all together, you get something like this:

Besides livening up my volcano, I created another effect for my lava. I didn't like the way the lava trails met the big lake around the outside of the map; there's a clear break in the models, and the materials are moving in different directions, which can't be helped. I used a particle effect to help mask this, creating something that I hope looks like lava splashing and putting it right where the edges meet.

The last one I did is probably the most important. I wanted even more smoke in the atmosphere, but to create a particle system with as much volume and density as I really wanted really brought my game to a crawl. The larger you make the volume, the more you have to crank up the emission to get a uniform spread within it - that only makes sense. My next idea was to give each UFO its own personal fog cloud, so that no matter where you looked on the screen, the area was still slightly obscured...but the main problem with that was that UFOs could see the thick clouds around each other. The good news is that I had already solved that problem with my PX_Canvas render layers. You'll remember that those are what I use in conjunction with the CameraFacingBillboard script to let each player see the indicators over each others' heads, but only the single one of them facing towards their own camera. By making use of these layers again, each cloud is now only visible by the camera of the UFO it's surrounding.

I just had one last problem, which was that I was seeing some really weird texture clipping with the smoke. My best guess is that something went wrong when I created the image for the fog material, but the easy fix was to just change the shader. By adding the line "ZTest Always", you can manually make the ZTest always pass and ensure that the thing will always be rendered on top of everything else onscreen, regardless of relative depth or shader queue. Now my effect doesn't abruptly stop with a hard edge when it cuts through the's actually rendering on-top of it, as in, you're seeing through the ground to the smoke particles below it. YMMV for stuff like this, but it was exactly what I needed to get a nice fog overlay.

Vulcanix is probably my favorite map so far. Even with the much smaller pool of assets I'm working with compared to the others, I think these particle effects really go a long way to tie it all together.