Wednesday, July 30, 2014
Blueprint and Cascade Fireworks WIP
A while back, when UE4 was still Rocket, I did what I always do when i get a new game engine: Make some fireworks! It's a great test of the performance of the engine and the particle systems and the overall workflow.
Unreal has always had a great particle system with Cascade, and in UE4, it's largely unchanged. There are, however some big additions, namely GPU accelerated sprite particles. That means tens of thousands of individual particles can be rendered with a single draw call and little overall performance cost. Perfect for fireworks!
So, I went to work and created a system that looked pretty darn good, completely in Cascade (With some help from the material editor, of course!)
I also wanted to test the physics accuracy, so I researched how high fireworks traveled, how fast they launched, etc and input all that into particle system. Sure enough, UE4's Cascade can simulate real-world physics pretty accurately! Launching my projectile at 7162.8 cm/sec with a constant acceleration in -Z of 981 cm/sec/sec sent my projectile almost exactly to the right height of 24384.0cm !
For reference, here's the info-graphics I pulled my expected velocities and heights from (I'm basing my fireworks off an 8" shell):
Fast forward to a few weeks ago when I came across the project files for this while cleaning up some external hard drives. I fired it up in UE4 4.3 and took a gander. It still looked great, but I had just seen some fireworks a few weeks before on the Forth of July and I knew mine weren't quite right. So, I went searching for reference. While the ones I created previously had some of the basics, the details were really off.
Specifically, the way the shell looked as it tumbled upwards was just not right at all. Mine flew straight and true with a bright-white tail of solid sparks. Real fireworks launch a flaming ball of explosives into the sky and the tail you see is the fuse that burns to ignite the bursting charge that makes all the pretty flaming colors happen. This causes it to corkscrew and tumble through the air, releasing yellow sparks as it flies.
This presented a problem inside Cascade. As far as I could figure, there was no real way of rotating the emitter around to create the corkscrewing effect actual fireworks exhibit.
Enter one of my favorite things about UE4: Blueprints + Particles! When there's a limitation of Cascade, Blueprints are there to help me extend the system in some very awesome ways. In this case, adding that rotational element to allow the shell to tumble through the air.
To make a long story short, I redid the particle system to be a rotating projectile actor, added a bunch of functionality and looked at some standard fireworks types and gave the whole thing some variety! There are now two shell types, four blast types and it's really simple to extend and modify!
I'm releasing it out to he wild for anybody to use, modify or whatever. If you'd like to give me credit in whatever you make, that would be wonderful, but I mostly hope everybody can learn from it!