I’ve been hesitant to upgrade Unity from my trusty 2018.3.x version, mostly because in the past it meant fixing a ton of bugs and possibly even ditching plugins until there was a release for the new version. But Unity kept adding newer and more compelling features with every release.
- 2D Lights and LWRP
- Shader Graph
- New Editor UI and UI Elements
- TypeCache would help speed up a few internal tools I’ve built
- Focused Inspector
No, I really shouldn’t upgrade. I mean, everything is working right now. What if everything breaks?
Uhm, isn’t that why we have source control? If everything breaks you fix it if its small or throw your branch away and forget about it.
Yeah, but when we tried this a few months ago with 2019 it blew up.
So we’ll try it again with 2020. Again, if it looks like it’s a ton of work then we’ll throw it away.
Hmmm. It would be really nice to get onto a newer version of Unity and be able to use some of those newer features in the game, if possible. Yeah alright, fine. Fine!
And so, I did an upgrade of the project in another branch that weekend. Amazingly the project converted without too many issues. I had to upgrade some packages - which wasn’t surprising - and fixup some editor code in one of my own plugins. I think it may have taken me all of 15 minutes to do. I’m pretty happy with the changes in 2020, especially being able to use the new editor UI and eventually play around with shader graph and the LWRP.
Building Pixel Effects using Unitys built-in particle emitters
I’ve been meaning to augment how effects are done in Electric Noir for a while, so this weekend while I was upgrading the project, I spent some time in a new project playing with particle emitters. I haven’t really worked with them before, other than following a few tutorials online. The goal this time was to really build something on my own and figure out the ins and outs of what my workflow might be to create some interesting effects.
My first test was making fire. Something that is pretty easy to do, even in sprite based art, but the good thing about using a particle emitter is that the fire will always be unique, so not every fire looks the same in your game. I also figured I could probably tweak whatever I ended up with into some kind of explosion effect later on, so much like the rest of humanity, fire is where I started my tech journey.
I played around with using a single particle emitter but I wasn’t getting the results I wanted. So I eventually switched to using three of them, stacked on top of each other, each one rendering on different sorting level. I used one for the darker orange of the fire, one for the lighter yellow of the fire, and the last one would handle the bright white to yellow center. Each emitter used the same material and texture, a 4x4px sprite with the four corners removed so it looks somewhat rounded.
I adjusted the size, color over time, noise and velocity over time until I was happy with how the particles were moving and then I worked on getting the effect to look more like pixel art. To do this I created a new layer in the game “Effects (No Display)” and moved my particle effects onto that layer. Next I created a camera that would only be able to see this new layer and set it to render to a Render Texture which I made incredibly low res (64x64). Once I had the effect rendering to this texture there wasn’t much work left, just add the texture to a quad in the scene and I had the following effect in my project:
I’m switching between the scene view and the game view in the gif to show how the particle effect actually looks vs the final in-game composite in the render texture.
Im pretty happy with this, especially since it is 100% modifiable in unity without needing any art asset changes. One thing I’m not sure about is how multiple effects would look on the screen, since I think that would require juggling multiple render textures… and AFAIK the only way to isolate RTs is by render layer… which are limited in Unity (I think there are 32…).