FIREWORKS in Unity using VFX Graph!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- Hello everyone, happy New Year and welcome to the Brackeys lab. Today we'll be working with fireworks. In Unity, of course. Yeah, we thought we would kick off the year with something exciting and what's more exciting than particle experiments? So, we'll split the process, hold on. We'll split the process of VFX brew into four steps. First, we add the rockets, then we mixed in some explosions. We'll then spice up the mix with some trips to the rockets and finally apply these trails to the explosion particles themselves. Actually, fireworks is an amazing effect to do because it teaches you the tools to create all kinds of other effects as well. And on top of that, it's a perfect example of how events work in VFX graph. GPU events can be used to trigger particles from other particles, such as spawning an explosion at the end of the rockets or creating particles as a trail. Alright, let's get celebrating. But first, this video is sponsored by Skillshare. Skillshare's an online learning community with thousands of quality classes on game development, tech, and more. If you're creating a video game and want to start creating your own 3D models, I really recommend you check out this awesome class on how to get started using Maya. Another really cool class is on how to animate characters in After Effects, which is definitely also worth checking out. Skillshare's the perfect platform to keep learning and thriving and a premium Skillshare membership gives you unlimited access to all classes for less than $10 a month. Join more than 7 million other creators and get your first two months for free by simply clicking the link in the description. So, put on your safety glasses, take a step back and let's light some fireworks. So, as you can see, I'm using Unity 2019.3, and this project is set up for HDRP. However, with this new version, Visual Effect Graph should work with the universal render pipeline as well. Just remembered to go Window, Package Manager, search for the Visual Effect Graph and instal or update it. And that's all this set up we need to do. We can now go to a project, hit the plus sign, go under Visual Effects and create a Visual Effect Graph. Let's call it, "Fireworks" and let's drag it right into a scene. And right away you can see that it starts spawning some particles. We also want to go to Edit, Preferences, Visual Effects, and in here there's an option for toggling Experimental Operators and Blocks. And we want to do that. This enables us to use GPU events. And with that, let's go ahead and double click on our fireworks VFX Graph in order to open it up. I'm just going to take this panel and dock it over here instead of the Inspector. And let's drag it out to make it larger, something like this. And let's also get rid of our console. We don't need that for now. There we go. So, the first element we are going to be creating are the rockets themselves. Because of this, let's go ahead and decrease the spawn rate to one. So, we just spawn one rocket every second. Inside of our initialised context here, we can go ahead and change the velocity. This is currently set to give us a random velocity between two values. I just want to go ahead and increase this on the Y to something like 11 and 14. There we go, now our particles go flying. Let's also change the lifetime randomness from a one to 1.2. And you'll notice that right now, our particles are flying off the screen. That's because we are yet applying any gravity to them. So, they will just keep on going with the velocity that we've set. Let's go into the Update context here. Let's hit Space and let's add a block for gravity. There we go, that looks much more like fireworks. We can also make it so that they don't all spawn from this same point. So, inside of our Initialise, let's add another block and let's search for a line. And we can use the Position Line Block. Let's move this to the top here, in order to spawn our particles on a line along the X. So, let's go ahead and set this to a width of something like seven. And now we should see that our particles are all spawning along this line on the X, really cool. If this is not happening to you, you might just be viewing everything from the wrong direction. You just want to make sure that up here, where we can see the different axis, X is pointing to the left. Awesome, finally we can go ahead and change the look of our particles. Let's go to the bottom context here, where we have the Output. And first of all, I'm going to change the blend mode from alpha to additive. I'll also change the main textures. Let's hit this button here and let's search for default, and here we have the default particle that looks really cool. I also want to set a size and I don't want this to change over the life of the particles. So, let's remove this default note here and let's instead hit Space and just search for Set Size to set them to a fixed size. And let's make this a size of something like 0.05. I know this is very, very small at the moment, but that's because the particles aren't yet glowing. So, to change that, let's go ahead and set their colour as well. Again, I don't want this to change over the lifetime. So, I'll remove this here and instead, add a Set Colour Node. There we go, and we can go in here and define a colour. So, I'm going to do some kind of bright yellow, and I'm also going to bump up the intensity. And this is what is going to make our particles actually glow. So, you can see that if I click and drag on this, our particles kind of start to appear as these glowing little things, and I'm going to set mine to seven. I think that's a pretty good value. If your particles are not glowing, it might be because you need to add a bloom post-processing effect. This is what takes the intensity of these colour values and kind of blows them out to give the impression that they are glowing. So, as you can see, I have my post-processing volume here and if I go to the Inspector, I've gone ahead and added a bloom effect. You need to do that as well. If you want to learn more about post-processing, we'll of course have a link for that in the description. And that's pretty much it for step one, adding the rockets themselves. This is not a very exciting one, but it lays the foundation for everything we are going to be doing from here. So, let's just go ahead and go to the top of our system, right click and name this system. And I'm just going to call it, "Rockets". Rocketman! Du, du, du, du, du, du, du! So, moving on to step two, which is a lot more exciting because that's the explosions. The way that we are going to be triggering these are using the GPU events that we talked about. So, to add a trigger for a GPU event, we go to the Update on the current particle system. So, on the rockets themselves, and we hit Space, and here we search for Trigger Event. And as you can see, we have three different events here. We want to choose, first of all, the On Die event. So, whenever these particles, the rocket themselves die, we want to go ahead and trigger an explosion. And we get to choose here how many particles we want to have in that explosion. So, I'm going to set this count here to 80, in order to trigger 80 particles to be spawned. Then we can click and drag from this green circle here out. And this will allow us to spawn in a GPU Event context. And from this context, this works very much just like the Spawn context up here. We can go ahead and we'll create an entire particle system. So, let's go ahead and just create the bare bone structure of a particle system. We'll go ahead and drag down from here into an Initialise Particle context. We'll go straight from that into an Update context. And then finally, we'll go from Update into Output, but instead of creating this from scratch, let's just copy the one from our previous system. So, hit Ctrl + C and paste it over here, hit Ctrl + V. Let's simply drag it down and connect it. So, we've now created another system with plenty of room for us to fill stuff in. And let's do that now. The first thing that we want to do is set the lifetime of our particles. So, let's hit a set lifetime. And let's make this random between two values. The first one we can make 1.5 and then maybe two, and right away, you can see that some particles appear down here in the bottom right corner. And the reason why they're just appearing here is because we haven't yet set the position of these particles. So, let's go ahead and do that. And since we want our particles to spawn at the position of our old particles, we simply want to inherit the source position of these particles. And there's of course a block for this. So, let's hit Space, and let's search for Inherit Source Position. And we'll choose this one here. And as you can now see, we spawn the particles in place of our old ones. You also noticed that sometimes we don't spawn enough particles and that's because we have to increase the capacity of our Initialise Particle system here, in order to make sure that we can display all of the particles that we are spawning. Of course, having all the particles just stay in one place is a bit boring. So, to change that, let's go ahead and modify their velocity. Inside of our Initialise again, we'll go Velocity, and here we can add velocity in different ways, I just want to add some velocity in a random direction. Let's hit that on the speed mode, let's go random. And then we can choose between two speeds. I'm going to set this to something like five and six, and there we go, we now have explosions. Of course, right now the particles just keep flying in whatever direction because there's nothing to slow them down. In the real world, we of course have air resistance to actually slow down whatever is travelling. So let's go ahead and add that now. So, inside of the Update Particle here, we'll add air resistance. This is called Linear Drag. So, let's go in and add here Linear Drag, and we can set the drag coefficient, how much we want to apply this force to something like three. And that definitely looks a whole lot better. Let's also just add a tiny bit of gravity to make these particles slowly fall to the ground. So, let's hit Space, again we'll add in a Gravity here, and we want this to be quite a lot less than the standard gravity. So, let's go ahead and set it to something like negative one. And I think that looks a lot better. It's a pretty subtle effect, but it just makes everything seem more organic and natural. Finally, for our explosion, let's make these particles look cool. So, let's go to the bottom inside of our Output node. And the first thing that we want to do is vary the size of these particles. So, instead of just using Set Size, let's remove this and let's search for Set Size Random. There's one at the top here. And we can set them to something like 0.03 to 0.07. There we go, that looks a lot better. And for these particles, I don't want them to stay the same colour over their lifetime. These definitely need to vary in colour. So, let's remove the Set Colour and let's add a Set Colour Over Life. And this gives us a gradient that we can play with. So at the top here, we have the alpha values for our particles, how transparent they are. And at the bottom we have the colours. So, just at the beginning of the particles' lifetime to the left here, I want to make sure that they are 100% opaque. So, let's just select the first key point here and remove it and move this one over to make sure that it's set to 255 in the beginning, and then we can definitely have it fall off at the end like this. Let's also take the colour here and turn it from a boring white into something more of a cyan colour. I want these to be really vibrant. Again, to make them show up, we need to add that glow. So, let's increase the intensity here to something like 5.2 maybe. That looks really cool and let's have them change colours, so the end colour here is going to be something different. Let's go to more of a bright purple and let's set the intensity here to something like 5.5. There we go, so now we can see them changing hue and changing appearance. I also want to begin the fadeout a bit quicker here. I think that looks much, much cooler. I might want to go ahead and decrease the amount of sparkle in the purple here. So, we'll just decrease the intensity on that down to something like five. I think that looks a bit less crazy, but you can of course experiment with this however you want. If you're going for really over the top cartoony style, definitely make things glow like crazy. If you're going for something more realistic, then maybe try and hold back a little bit. Now, a really cool little trick here is that we can actually make a bright flash right when the explosion happens using this gradient editor. All we have to do is simply move this colour over and create a new one here by clicking. And we'll make this one completely white and very, very bright. So, let's set the intensity of this to something like 7.5 and you can see just how crazy this flash is. And then we can control the duration of the flash by simply moving these closer or further from each other. So, if I move them really closely together, you can see that we can create that really quick, bright pop, like an explosion is happening and then we start to see all this sparkly stuff inside the fireworks. I really like this effect, I think it's super cool. I might have overdone it a tiny bit. I'll try and set this to something like 7.4. That looks better, and yeah, just a really quick and easy trick. And that's pretty much all we need to do on the explosion themselves. So, let's go to the top here. Let's take all of our nodes here, move them down a bit. Let's right click here and name the system. And I'm going to name it, "Explosion." Cool, I'm just going to tidy this up and now we can move on to step three, which is the rocket trail. So, I'm going to go ahead and make some room for it here. I want the rocket trail to be right next to the rocket system itself, there we go. And we actually used the exact same technique that we use to trigger our explosion, to trigger a rocket trail. The only thing that we change is the type of trigger we use. So, for the explosion we just want to trigger that when the particles die. For our rocket trail, we want to go ahead and trigger that. So, Trigger Event and we want to use Always, which is going to be called a re-update. So, in here with the Always, we can set the count to something like two. So, we're going to spawn two particles every update, and let's go ahead and lead this into another GPU event. So, we create a GPU event, there we go. And again, we can lead this into another particle system. So, let's just create the structure for that. Let's create an Initialise, let's create an Update, and finally, let's again, just copy the Output from our first system. There we go, and now inside of our Initialise, we can set the capacity here to 1,000 because we want quite a few particles on our rocket trails. We'll also added lifetime. So, let's go in here and Set Lifetime, and let's just set this to something like 0.3. And now you can see again, our particles start to appear. Again, we want these to inherit the position of our particle when they're spawned. So, to do that, we'll again put in the Inherit Source Position and right away, we can see that our trails start to appear. Of course we can do different things to this trail to make it look cooler. First of all, I would like to spread it out a tiny bit, so we can add a tiny amount of random velocity. So, we'll go under Velocity and let's choose random direction again, and let's just set the speed here to 0.2. There we go, so it now spreads out a tiny bit and I actually don't want to do anything inside of Update for these particles. However, we definitely have to change some things in the output. And one thing we could do here is maybe stretch the particles along the Y, in order to give the impression that the light is kind of being drawn out because the particles are travelling so quickly. I think that looks pretty cool, it's probably easier to see than explain. So, in here, let's go ahead and add a Set Scale, and this is going to allow us to control the scale in the different axis. And I'm just going to choose Y and set that to something like three. So, you can see that just stretches the particles a tiny bit. If I overdo this effect, you can see what happens. It really stretches them along the Y, but I'm just going to stick to a subtle value like three. And I'm just going to drag this above the colour. And that's also the main thing that we want to change. Right now, the colours are a constant colour. Let's remove this and let's instead set the colour over life. Again, this gives us this gradient here and let's make the particles instantly appear up here with the alpha. Let's also remove this one here and just have them slowly linearly fade out from 255 to zero. And then in terms of the colour, let's go ahead and choose a good orange colour. And again, let's definitely add some intensity here. Let's try 3.5. That's a very dark orange. Maybe make it a tiny bit brighter. I think that looks really, really, really cool. And let's also just have that fade to a standard orange without any glow, so that we kind of keep the look of the particles, but we slowly remove the glows so that the glow itself is more centred towards the top. I think that looks really cool. Awesome, so that's actually the rocket trails themselves. So, let's again, go ahead and name our system here. Let's name it, "Rocket Trail". Again, I'm just going to neaten this up and now for the fourth and final step, which are the explosion trails. This is definitely also the easiest, because we can take the trail that we just applied to the rockets and simply add that to the explosion particles as well, in order to give a really cool effect. So, to do that, we need to go into our explosion here and we need to, of course, add in a trigger event on the Update here. So, we'll hit Space, search for Trigger Event, and this time we could, of course use Always, but that is quite a few particles if we're spawning them every update. So, instead I would like to use Rate, which allows us to define a rate over time to spawn in the particles with. So, let's just make some room for that here. And let's set the rate to something like 40 particles per second. And again, let's create an event out of this. So, drag out and create a GPU event. And now, instead of creating this system from scratch, Let's just take our entire rocket trail here, hit Ctrl + C, Ctrl + V in order to duplicate it, move it over, simply connect it. And right away, we can see some of this effect working. Now, we just want to go down to the bottom here and remove the Set Scale so that these particles are not stretched. We also want to increase the capacity here, because we are spawning quite a few particles to something like 10,000 or maybe 5,000. And let's also change the lifetime to 0.5 just to make them stay a tiny bit longer. You can of course, also adjust the colour if needed. I might want to go ahead and make these a tiny bit more red. There we go, I think that's a pretty cool hue. And definitely play around with this and have fun, but that was the final step. And we now have, as you can see, real-time particles showing fireworks in Unity, and we can fly close to these, or we can look at them from a distance. Either way, I think they look really, really cool. And of course, because everything is just parameters that we can easily adjust in here. What we can do is simply, well, If we wanted to go more crazy, just crank it up. Let's spawn, for example, a hundred rockets a second. Of course, we also need to make sure to increase our capacity to do that. I think we can set this to something like 1,000 and increase the capacity on all of the other systems as well. And there we go, we have absolute mayhem. Awesome. That's pretty much it for this video. If you enjoyed it, make sure to subscribe and ring that notification bell, so you don't miss the next one. Also, don't forget to check out Skillshare, simply click the link in the description to get two months for free and start exploring your creativity. On that, thanks for watching, and I will see you in the next video. Dr. Brackeys signing off. Thanks to all of the awesome patron supporters who donated in November and a special thanks to InfintyPBR, Dante_Sam, Samuel, Lost to Violence, Love Forever, Chris, faisal marafie, Megan Frazier, Leo Lesetre, Miamia Pop, Mohammad Younis, Danijel Dusanic, Jacob Sanford, Naoki Iwasaki, Marc-Antoine Girard, Gregory Pierce, TheMightyZeus, Alison the Fierce, Yigit Kaya and Erasmus. You guys rock.
Info
Channel: Brackeys
Views: 156,392
Rating: undefined out of 5
Keywords: brackeys, unity, unity3d, material, materials, beginner, easy, how, to, howto, learn, course, tutorial, tutorials, tip, game, development, develop, games, basic, basics, VFX, graph, particles, fireworks, 2020, trigger, event, visual, effects, gradient, post, processing, glow, spawn, particle, system, firework, explosion
Id: iCEHarLRCzI
Channel Id: undefined
Length: 19min 3sec (1143 seconds)
Published: Sun Jan 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.