Easy Particle Rain in Godot 4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's make some rain hi I'm Mike and today I'm excited to finally get around to a suggestion that I got way back in March I think it was from someone with the username Chris Fritz who suggested that I take a look at weather effects in Godot uh and so that's what we're going to be doing today uh not all weather effects mind you because that's quite a large topic we're going to be focusing in on making a rain effect in particular we're going to be using the 3D particle note in Godot to Make It Rain I will get around to the other weather effects at some point in the future so if you're interested in that let me know which ones you're most excited for and I will prioritize those now I'm going to be using mostly just the default tools that are given to you within Godot to make this work with the exception of a single texture file that is just a a white circle that gradients often to transparency around the edges just because and I'll put it up a side by side here it adds a little bit of a realism to the Rain effects um and that's the only difference between these two uh shots hopefully you've been able to see that through YouTube's compression uh if not it is a rather subtle difference but it just adds a little bit extra if you're looking for the realism route after the tutorial part I'm also going to briefly talk about some of the things you may want to consider if you want to implement this in your uh particular games um but for now let's hop into Godot and I will walk you through the steps that I've done to create a simple rain effect in Godot so here we are in Godot as you can see I already have a scene set up for us to work on it's just a mesh instance that is a plane to represent the ground and as a child note to that I've added a GPU particle collision box and made the dimensions match the visuals of the ground I already have a world environment node with the sky setup using an HDR texture for the Skybox and the lighting information so let's get started let's first add the GPU particle node to the scene and let's set up the basics for the node to work so we'll give it the basic particle process material and a draw pass for the draw pass we'll set it to a Ribbon Trail and since we're going to be using Trails we'll go back up here and enable them uh and then the next thing we're going to do is we're going to adjust the emission shape in this case I'm going to make it a box that is again the same dimensions of as the ground next I'm going to adjust the direction and the initial velocity we're going to make the direction Point straight downwards we want to reduce the amount of spread from the direction we don't want it to be as high as 45 degrees because it's going to fly around everywhere so I'm going to reduce it to 5 and we're going to increase the initial velocity to about 10 or basically whatever looks good in theory you could look up the terminal velocity of range or set the initial velocity to that and then disable the gravity component to this the last thing that we want to do is we want to enable the Collision for the particles here so we'll go down and change Collision to rigid now one of the things that's important to know is that if we move the particle system around in such a way that the drawing box does not intersect with the particle collision box that we have previously set up there won't be a collision to detect and the other thing that this does is that these particles will only be rendered if the player or the camera for the player can see the drawing box so if you're looking away from it or it's out of frame the particles will just disappear and stop rendering because the game engine doesn't know that it's supposed to be seeing and rendering those particles to fix this and so we can have the particles spawning around the origin point and so we move that around more freely we can adjust the size and the dimensions of the drawing box and the way that this works is you give it the the starting point basically and then from there you can tell it how far out in each Direction like how wide how high and how deep you want the box to be and it's basically that's the reason that I have -10 for the X and 20 for the width so that way the origin point the center of the transform is directly in the middle of that dimension so with the instructions for the particles set up kind of in a basic way let's move on to the draw pass and give it a new material in this case it's going to be a basic standard standard 3D material we're going to disable the back face culling so we can see the the trail no matter which direction it spawns so we're going to set the transparency to Alpha and that will have an effect on the Shadows here which given that they are raindrops we don't necessarily want hard Shadows from them so that's all right you will notice that I accidentally disable that here but I'll turn it back on later and I'll point out why that's important when we get around to it next I want to go to the vertex color and set it to use as Albedo so that way we can control it from the protocol process material and then the last thing we want to do is we want to enable particle Trails down in the transform and that's it for the material but before we close the draw pass there's something else that is pretty neat that we can do here and that is we can change the width of it but we can also do that as a curve so if we create a new curve and what I'm going to do is I'm going to create it as a raindrop shape basically I'm going to set the maximum size of it to 0.1 and so that will be 0.1 of the total width of the original [Music] [Applause] and then as you can see it now starts to look a lot more like a raindrop and not just a falling Square uh now that's all set up let's increase the number of raindrops or particles that are being emitted I'm going to go up to a thousand and kind of see how it looks now there's a couple of adjustments that we can make here number one I'm going to increase the lifetime of the particles so that they more reliably will hit the ground and I'm going to increase the randomness of the particle generation because in nature it's not a evenly spaced interval between each new instance of a particle they're clumped together in much more of a random and natural feeling way so I'm going to increase it until I feel like it looks right as we kind of sit here in the middle of the rain it doesn't really look like a convincing rain and the main problem is it's a clear day at least according to the Skybox one thing that's you'll notice when it is raining is that it visibility is often not as good while it's raining as it is you know when it's a clear day so one way we can mimic that is Godot actually has built into its World environment node a volumetric fog so I'm just going to enable that and see how much of a difference it makes just turning that on another thing we can do is that when it's raining the Raindrop tail is not usually that long it's usually a lot shorter than it looks here so we can reduce the length of that I'm just going to reduce it by 0.1 here and then as a final touch Pure White isn't often something that we find in in the rain in nature really so it kind of stands out a little starkly so if we reduce that just a little bit bring it down to the mostly white but not 100 white it makes it a whole lot more realistic looking [Music] now we don't have to stay here we can add a little bit of blue if we want it to be more stylized or cartoonish um blue often being you know the color for water now if you want it to be a little bit extra realistic this is where we get to that texture that I was talking about earlier the just the white circle that has transparency around the edges now if we just add that to the material here [Music] you can see you can see an outline right now um and I just wanted to leave this in so you can see what happens if you don't have the alpha enabled for the material or for the yeah the transparency set to Alpha um which as I mentioned earlier I instantly disabled hopefully you can see this through the YouTube compression but it gives that just that little bit extra realism compared to not having that texture on the material [Music] now we're gonna jump ahead a little bit to a scene that's uh is very similar to the one that we just worked on but I have a first person character in the scene as well as a couple of UI elements to turn on and turn off a couple of different examples of different styles of rain that you could think about making or adding to your game now just a quick walkthrough of this scene there are two different types of rain one is a more cartoonish rain one is a more realistic rain and I've exaggerated the size of the raindrops for the cartoonist rain just to make it extra obvious and then I have two different styles of emission shape one of them is the box over the entire ground that we had before and the other is a ring that is a child of the player node so that as the player moves the emission of particles will move with it and this the idea here was I was trying to think about how I could Implement a system for the rain particles that would allow me basically to have infinite travel without overtaxing any kind of system resources and this was a solution that I came up with there's definitely some pros and cons to the system which as I walk around here you can see it kind of takes a minute for the rain to follow you so it feels like it's following you and that's not exactly what I want whereas if I have the environmental box just rendering the rain it feels like it's raining all around me [Music] and so I think partially the best option is to use a combination of the two so that way you can have it raining all around you but also you can still see rain falling in the distance so if you have a better idea or a suggestion for how to a better way to implement this definitely leave it down in the comments below I'd be very curious to see what are your advice is for how to make this system work better and I'm sure everybody else watching would appreciate that as well and then the last question that I have for you out there is on this particle system when they hit the ground they leave little puddles behind which is cool but I can't seem to replicate that in other scenes I don't know why so if anybody has any ideas what's going on there again leave in the comments below I'm I'm very curious as to why it works sometimes and not others and there you have it there is one way to implement a rain effect in Godot using the particle system now if you're going to be implementing this within your game there are a couple things that you'll want to keep in mind in terms of optimizations or things that you'll need to consider for your scenes uh one is that if you are wanting to protect the rain from getting inside of buildings in an urban scene for example you maybe want to eliminate the spread that the rain has when it's coming down so that nothing kind of comes in from the building's edges unless you have the Collision on the side as well as the roof the other thing that you may want to look into is if you have a densely packed city scene where there's going to be a lot of different roofs and different heights at which you want the rain to not pass through you probably want to look into using the height map for the Collision but that's it for me for now so if you found this video useful hitting the like button is a great way to help get the video up to a wider audience and if you missed my previous video where I go through a bunch of the options for the particle system you can find that over here other than that good luck with your projects take care of yourselves and I'll see you next time foreign foreign
Info
Channel: Watt Interactive
Views: 9,182
Rating: undefined out of 5
Keywords:
Id: dLWM8jxQx-4
Channel Id: undefined
Length: 13min 23sec (803 seconds)
Published: Sun Jul 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.