Particle Systems From BEGINNER To PRO | Godot Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Very good tutorial on particles. Thanks for sharing

👍︎︎ 2 👤︎︎ u/Sousio 📅︎︎ Nov 22 2021 đź—«︎ replies

furcifer, yes! thanks!

👍︎︎ 1 👤︎︎ u/softfeet 📅︎︎ Nov 22 2021 đź—«︎ replies
Captions
You can do incredible stuff with the particle systems in Godot, but too many developers just don’t know how! We will go from beginner-level techniques to really really advanced trickery. And make some nice effects along the way! We prepared some simple textures, you can download them with all the particle systems we make in this video from our GitHub! This video is part of GoGodotJam 2, find out more on the website and join the jam that starts November 18th. Links are in the description! Let’s start with a nice little fire effect. Create a scene and add a particles2D node. As a texture, we can use this little smudge. Of course, you can use something a little nicer for your game. So now we have a falling smudge. We can remove the gravity to stop it from falling, and give it an initial velocity. Let's say around 250. Flames tend to rise up so we give it a direction of (0, -1, 0). Flames also tend to change color over their lifetime, and this can be done with the color tab. And here we come to the first few tricks. We want to add a color ramp, which is a gradient texture. This needs a gradient and we can see it go from black to white. A thing to note is the default size of the gradient, see if you can spot a difference when we reduce it. Until we reduce it to really really low, it looks the same. This happens because when the gradient is read, it is interpolated between the near colors. Our flame should go from yellow to red. It will look much less janky, when we give it a fade in and fade out. For that, we need to add more colors. Let's add one in the first third and set the starting color to transparent. We repeat that at the end, just mirrored. The fade is linear, which might look a little harsh at the end, so we can add another point for smoother fading. Flames tend to emit light, we can get this effect by choosing an additive canvas item material. But the flame does look unnaturally steady. So let us look through the properties and find a fix. Explosiveness sounds awesome, if we put it to 1 all particles emit at the same time. If we have a lesser value, the particles will spawn fast but drop out at some points. A little bit of that might be cool for our flame, but let's not overdo it. A bit of variety in the lifetime helps, and a bit in the velocity. The particles also spread too much, let's reduce that a bit. We can also use a few more particles! The texture is a bit large, let’s scale it to 0.5. We can make it look a bit more varied by rotating the texture randomly. Just set the angle so something very high and the angle random to 1. Some subtle angular velocity aka rotating adds some more visual complexity. An effect gets convincing when the movement is so complex, that the brain does not see the individual sprite anymore. One more thing, the fire particles should not change when we move the origin around. Go to drawing and uncheck local coords. Let us call this a good enough fire and put this aside, so we can try out some other features. The next thing we are going to make is an explosion. We can use the fire as a base, so we just duplicate it. Interestingly, when we change the properties of the material, both particle systems change. This does only happen with parameters below the material here. We can fix it by making the material unique. By the way, if you duplicate the whole fire scene, the material is made unique automatically. However, I would advise making it unique in any case to prevent mistakes. For our explosion set the explosiveness close to 1, and the spread to 180 degrees. I think we need a few more particles, too. Particles coming from an explosion start with very high energy, but quickly slow down. We can do this using damping. So increase the velocity and place quite a bit of damping. We can make the effect even more pronounced with a damping curve that is higher at the end. Internally, this is also a texture, so keep in mind how large you really need it to be. I feel like the explosion is a bit weak in the middle, so maybe we try a scale curve - that way, we get this nice ring of fire. When we like the effect, we can go all the way up here, and set it to oneshot. We now need to set emitting true once and it goes boom. If you have a retro game, this might not be the kind of explosion you think of. So let us try another one. Let’s use a sharp pixel texture with an animation by sprite sheet. You can also use individual frames with an animated texture, but we will not. So set the sprite sheet you have as the texture. Give the node a CanvasItemMaterial. Check “Particles Animation” and configure the number of rows (or horizontal frames) and columns (or vertical frames) of your sheet. We could make the animation looping, but this one should not loop. We can set an emission shape, so our explosions start at different places. A sphere makes sense here. To animate them, we increase the animation speed. I like speed 1 with a shorter lifetime. We remove the gravity and give it some scale random. By the way, when we don’t set the scale higher than 1, it does nothing because scale random always randoms between 1 and the value you put for some reason. So it would choose a random number between 1 and 1. Some angle random looks great too. Let’s increase the amount of explosions. Again, we want some explosiveness. This is an explosion after all! We can use the color ramp to do sharp switches between colors so we can enforce our color pallet. Just insert two keys per color and when you change the color, put the keys very close to each other. Actually, this looks good with a gravity that moves upwards. And a bit of lifetime random! And again, uncheck local coordinates. But enough with the fire stuff for now! I think we are ready to get a bit more advanced now. Let’s say in our game we have a thing that pulls everything towards it. This needs to be communicated to the player, and a particle system is a great way to do so. Luckily, we can put negative values in the radial acceleration. The slider is capped at -100, but that does not stop us. You can input even smaller values. When we choose a collision shape that is a bit larger than a point, we can see some pulling going on. We can see it even better when we change the emission shape to a ring. This can be done in emission shape and set the radius. How about 120 for the inner radius and 150 for the outer one? This looks quite good already. We can give the effect even more direction when we use a texture like a dash and activate “Align Y” in the Flags. This will rotate the texture to face the movement direction. In the first frame, the direction is not calculated yet, which is why it looks janky. This can be fixed easily with a color gradient. Let us fade them in a little, darken them as they get sucked in, and fade them out. And maybe let us add some random hue variation just for fun! We have worked so hard, we now deserve a little fun. Let us destroy something! How about we crush a sprite into single pixels? To do that, we can use the emission shape “points”. How do you set these points? Well, you can use this slightly hard-to-find button up here. But hey, at least it is underlined since version 3.4! Add your sprite or mesh, choose “Solid Pixels” and make sure to check “Capture Emission Colors from Pixel” because we want the color! We could add a texture, but the default pixel looks cool here. Maybe we scale it up a bit. We also need a lot of particles. Now we just make it fly away with a bit of velocity or whatever you like. That looks good I think. We can use an animation player to hide the sprite while the particle system is active. So animate the modulate of the sprite and set the particles to emitting. I need more explosiveness. If you want more control over the direction, you can use “directed points” when loading the emission mask. Godot generates textures that encode where to spawn particles and with what color or direction. You can see these textures in the emission shape. And while we are at it with the animation players, let us see what we can do with them. The properties of a process material can be changed at runtime. When you want to change them individually for all instances, don’t forget to make them local to scene. We can change them via code, but animation players are also very convenient. When you have an animation and open the animation tab on the bottom, these key icons appear next to every property. When you click on one, an animation track is created for you. This really opens up possibilities now. So maybe exploit gravity to make a changing wind effect? Or change the speed scale for pulsing? Or we emit all these particles, and then dramatically suck them back in? Just play around with that. There are tons of possibilities, make whatever you need in your game. And now we officially enter fancy territory. There is no law that forbids attaching a shader to a particle system. These are not particle shaders, by the way, we will talk about those soon. We can use a fragment shader to give our particles a nicer animation. We could make particles that do a distortion with a screen reading shader. Or make them pulse! But the coolest effect can be done when we use particle properties in the shader. We can access the INSTANCE_CUSTOM from where we can read the relative lifetime, maximum lifetime, orientation angle and animation frame in the RGBA components. In 3d, we even can read INSTANCE_ID to get the particle id, but as 2D folks, we can hack our way around that. To separate the particles and animate them individually, we can use the color or animation frame. This can now be used freely in the shader, for example, to play an animation like we did here. Or use some texture scrolling to make these sweet little effects. We will not go into detail about that, because we already made separate videos about each of them. We linked them in the description! And now to the ultimate superpower: Particle shaders. Particle shaders give you all the control you could ever ask for. Want the particles to fly on a path? No problem! Avoid obstacles? Sure! Move according to airflow based on thermodynamics? Go for it! You can write them in two ways: You can convert a particle system you already have and edit it. This is easy and fast if you just want to add some functionality. And it is a good way to get started. But you may need to remove some unused stuff. Or you start from scratch. We will give you a more detailed introduction in this video. And we made some videos on how to explode and build a sprite and how to make a particle follow a path based on particle shaders. This should give you a nice introduction. That has been a lot of stuff packed into a short amount of time. So let us know if you guys have any more questions! The GitHub with all particle systems is linked in the description! If you think this video was helpful, let youtube know by liking, commenting or sharing this video.
Info
Channel: PlayWithFurcifer
Views: 3,574
Rating: undefined out of 5
Keywords:
Id: F1Fyj3Lh_Pc
Channel Id: undefined
Length: 10min 59sec (659 seconds)
Published: Tue Nov 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.