Unreal Engine 5 - Footprint Masking and Sand Particle FX

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello fellow unreal engine developers in my last video i showed you how to create these footprints in the sand that was just over an hour long but there's still more to show you so i'm back with part two and i'm going to show you how to use footprint masks to blend materials together and also quite a few of you are asking for particle effects as the feet hit the ground to throw sand into the air so there'll be two parts today's let's get straight to it [Music] welcome back to part two of this footprints tutorial if you haven't done so already make sure you've done the tutorial in the video shown in the description below and in the card above and in that video i showed you how to achieve true or fake displacement so you should have ended up with a character that can run around and leave footprints in the sand so you only have to do the fake displacement section in order to continue with this tutorial so if you didn't want to do the whole virtual textures virtual height field mesh displacement you don't need to but you can still carry on with this tutorial even if you got that far so once you've done that you can come back here and i will show you two more things to do with footprints the first area i'm going to cover is footprint masks so i'm going to show you how you can use the masks to blend materials together in your footprints and then i'm going to show you the particle effects attached to your foot in order to leave sand trails as you run around if you're only interested in the particle effects then you can skip to the future chapter i had a few people ask me for that so i wanted to make sure i covered that as well so let's get on with the mask section first if you go to your landscape find your material should be bright desert sand although you might have chosen something different for yours browse to that open it up and then in the hierarchy open up the parent surface material or parent material so we don't need the material instance anymore and you should have something like this if you did the fake displacement then all we did was created the material attributes with the normal changed in order to give the illusion of the footprint depth if you did the full displacement you'll have some extra nodes in here to do with calculating the height and putting out runtime virtual textures but in both cases you're going to have the same node here and you'll notice there are two additional outputs this d4 mask and this normalized deformation mask and that's what we're going to talk about in the first part of today's tutorial so these two things do similar things but they're slightly different if you if i hover over it it says for the d4 mask it just checks whether there's a deformation in the current position so this is this is like a switch it's either on or off if if you have a footprint or a trail in the landscape then it will be one and if there's nothing there'll be zero whereas this one is a blend depending on the brush you use to create your trail so this will be this will have feathered edges and this is probably the more useful mask for for today's tutorial certainly this one is useful where you want to switch features on and off in the where the trail is so let me show you the difference between both of these if we let's just take the normal out of the equation for now so just attach your normal here directly so that we don't have any deformation and first of all we'll look at the d4 mask so plug that into a base color save and if you go back to your desert it should be black because we've got no color in there at the moment go into play mode and as i run around you'll notice that wherever i leave a trail that d4 mask is a value of one or white in this case but there's no graduation between zero and one it's either on or off so if i choose the other mask so i go to the take the normalized deformation mask and plug that into the color save and now if i press play you'll notice that it's got feathered edges so the mask here is dependent on the brush that you used when you write the footprint trails so different brushes will have different effects but you can see that it's more of a grayscale effect and this is what we're going to use today in order to effectively put things in the footprint textures either blend a new material under the existing material or change some attribute so let's go back to the surface material let's now plug the normal from the deformation back into the normal and now you'll see that when we go into play mode you can see that now it looks like that white texture is within the footprint but as i said it's just a mask at the moment so let's um let's do a simple example um before we do a blending of two materials so let's plug the base color back in here for now so what we can do is we can use the mask in order to blend between the existing color and some other attribute or actually you can blend between any of these attributes but let's use color as an example here so what i'll do is i will press three on the keyboard and left click on my mouse and that will create a vector3 or a color node double click to open it up and i'll make it green so zero red one green zero blue and then what i'll do is i'll take the output from this normalized deformation actually i'll yeah i'm taking i'll take the output from the color first and if you type lerp and choose this one here linear interpolate what this does is it allows you to blend between two attributes or two values controlled by this alpha channel so this will be wherever the value of the alpha is zero this will be wherever the value of one and it'll blend in between or interpolate in between so what we actually want is we want the base color at the top because we want that where there is no trail we want the green in the b channel and then we want our normalized deformation to control the blend and then we'll plug the output of this back into the color so what we should end up with is green wherever the um the where the trail is so let's save and go back into play mode okay nothing changed at the moment but as soon as we run around we have green wherever the deformation mask is so this could be some kind of toxic sludge under the desert so that's a simple example of blending but what you often want to do is blend two materials together so say you were running probably not so much in the desert but say you were running in snow and there was grass underneath you might want the grass material to be uncovered under the trail so we want to use that mask to blend between two materials so let's uh show you how to do that next so with your surface material open well first thing we need to do is we need to uh get hold of a new material so if you go to uh your window uh menu and choose bridge quicksort bridge you can choose whatever material you want but for my example if i typed coal soil and i got this powdered coal and soil so you can see here it's a very sort of dark material it'll probably show nicely underneath the desert even though it's not wholly realistic for the environment so what i'm going to do is i'm going to download that you'll probably have to press the download button here medium quality will be fine so once you've downloaded it just add it to your project and it'll create in the mega scan surfaces folder it'll create another folder called powdered coal and soil beside the bright desert sound that you already downloaded okay so you can close that down now and what we'll do is go back to our surface material and what we want to do now is we want to get rid of the green lerp here and then you can plug your base color back in and what we want to do is we want to create another material that we can blend with based on that normalized deformation mask so the easiest way to do this is to bring up your content browser with control space find the powdered coal and soil folder and click on all of the shift click so you've set all three of these textures not the first material instance and drag it in to some blank space above here so you should end up with three textures let's organize them like this so the first texture is the color or diffuse texture the second one is the ambient occlusion roughness and displacement and the last one is the normal and so what we need to do now is we need to make material attributes plug the rgb of the first texture into the base color the green channel of the second texture holds the roughness so plug that into the roughness and the rgb of the third texture you plug into the normal and we ought to have some specular um values as well otherwise um you know we might have it fully um reflective or not so if you press one on your keyboard and left mouse click it'll provide you with a scalar parameter i suggest you make it something like 0.2 so it's not very reflective just a little bit and plug that into the specular and now let's just put a comment around this and say dirt material so we've now got the material in isolation we don't have the uv coordinates yet but what i suggest you do is i suggest you take this this first node here just move it up drag around it and just move it up slightly so it's in line this first tiling node allows you to specify what's the name suggests the tiling and rotation so it this result is the uv coordinates after tiling so i suggest you take the result of this and plug it into the uvs of each of those three samples so that means the tiling of the dirt texture will be the same as the tiling of the sand texture which is fine for this example so now we have material attributes for dirt material and we have material attributes for the sand material so how do we use the deformation mask to blend between them well there isn't a lerp feature but there is a very useful node for blending material attributes if you right click and type blend material you can see blend material attributes and effectively it's similar to a lerp but it blends all of the attributes of the material between a and b based on this alpha channel so what we'll do is we'll take the output of the sand channel here and plug it into our main a that's what we want to be where there's no trail we will then take the output of our dirt mask actually let's not do that first let's do a test first of all just to see if this dirt mask works just take the output of the dirt mask and plug it directly into the output of the ms surface material i just want to see if this actually works first before we try to do anything more sophisticated so let's save this go back to a desert and you can see straight away that we have this dark rocky texture with a very slight bit of reflectiveness and that's what we want to be underneath our sand okay so the first part of that works so go back to the surface material now continue where we left off in the blend material attributes we'll we'll connect the dirt material to the b channel and now we want to blend based on the normalized deformation so plug that into the alpha and finally plug the output of this into our final output node so now this will be mainly desert sand from here but with some dirt where the mask of the footprints is so save that and we're going to play mode and we're still getting the deformation but i can't really see the rock underneath and that's because the normalized mask isn't really powerful enough to show the ground underneath what i mean by that is it's in the range of zero to one but there's so little at the one range that we're not masking much of the rock material so in order to see more of the rock underneath we just need to increase the power of the mask and we can do that with a simple multiply so come back to your surface material and from the normalized deformation drag out and hit your multiply button and let's just multiply it by two so all it means is that um instead of the range of zero to one we'll have the range of zero to two so we'll have more of the upper range of the um of the mask would hopefully show more of the rock in between but we still want it to be between zero and one before we plug into the alpha and to do that we just take out of here and put saturate and saturate has the effect of clamping the value between zero and one again and so we'll then plug that into the alpha so this should show more now of the rock through the trail so save that go into play mode and now you can see especially if i run around a bit here now you can see the rock underneath much more clearly and if you wanted to see more of the rock you could make the footprint wider in the last tutorial we showed you how you can change the footprint component to make the footprint wider but as i said this although this is a kind of a bit of an unrealistic example because we'd expect to have more sand underneath the desert you can think of this application in areas where something has fallen some material has fallen on top of something else like like snow on fields or rock that would make more sense to apply this material so uh let's move on now to looking at particle effects a number of you said to me that in order to sell the effect of running through the sand we really needed sand particles every time you planted your foot in the sand so i'm going to show you that now you can tweak this effect to your liking you you might want to have a different particle effect but the key thing i want to show you here is how to synchronize it to the footsteps so um or footprints i kept saying footsteps in the last video when i met footprints so first thing i want you to do is i just wanted to get some extra starter content the reason being is that there is some dust particle material in the stars content that i want to use so go into your content draw go into the add feature and in here if you do add feature or content pack at the top go to content at the top and choose start content and just do add to project and what you'll find is it will add this starter content folder with lots of bits and pieces blueprints audio files particles materials just things that you can use in your project so we just want to do that first then close those down and what we'll do next is again we'll open up the content browser and at the top level i'm just going to create a new folder just to keep things organized and call this fx double click on that and we want to create a new niagara system so right click and in effects choose niagara system and what we'll do is we'll do a new system from selected emitter i'm going to i'm going to choose one that already exists so click next and the one i want to use is the omnidirectional burst so click on that and plus to add it and finish and it will ask you to name it so call it ns for niagara system foot dust and then if you open it up you should see here a exploding particle you might have a background here it doesn't matter i've just switched my background off but this is sort of exploding particles and it's using the default sprites at the moment so let's just change a couple of things we'll come and tweak this later on as i said the important thing here is getting it firing at the right time and then we can come and tweak it so if you go to the [Music] the sprite renderer in the right at the moment it's the materials default sprite material so what we'll do is we'll change that if you click on it and type dust you'll see this dust particle m dust particle so you can select that and it's a it's a two by two sprite so you need to change this sub image size here to two and two and now you can see it works there the dust particles slightly better because it's got a more sort of faded edge it's not quite so bright so it probably looks slightly more realistic so leave all the other settings to see after the moment just save this but leave it open so that we can come back and tweak it later as i said the key thing we want to do next is to make sure it fires at the right time and in the right location so in order to get it attached to the feet of our character go to your world settings if you don't see world settings here go to window world settings and make sure it's checked on and go to your default pawn class bp third person character and browse to that and open it up and if you go to the viewport and pan around we should find there's our character if you select the character mesh here you'll see all of the information regarding this character so we're using the queen character which is the female mannequin and it's using this animation class animation blueprint quinn c so this is is in the animation blueprint we want to find out the where the animations are we want to attach the particle effect to the when the foot hits the ground so browse to the animation blueprint open it up and it says it's a child and anim of abp manny so what we could do is we can go to the parent class abp manny if you go right to the top right where it says parent class you can browse to that and open that up okay and we'll get rid of abp quinn now we don't really need that and you can see that there is this state machine make sure your there's two graphs event graph and animation graph make sure you're on the anim graph go into the locomotion and it's pretty simple it goes from idle to a walk run animation so we want the walk run animation and then go into this blend space for walk run so this is the main animation control for this character and if you want to see it working hold the control button down and you can drag this green cross around you can see that when i'm stable i'm doing nothing and then i walk and then eventually run and so there are four animations involved in this they're listed on the left hand side here there's actually sorry three animations this walk in place which is very um for very slow movement walk forward for medium movement and run forward now i'm not really bothered by the walk because most most of the time you're gonna get into the run animation almost straight away so i'm already really interested in the run animation so browse to the run animation and open it up close down your content browser and what you'll see straight away is they're very helpfully put on sink markers for when the left foot down is down and the right foot's down if i pause this you can see that if i go to this frame that sink marker is when the left foot's down and this sync marker is when the right foots down the right foot is down so we can use these frames as references to play our particle system so what we want to do is create another notified track so go in here notifies add notify track and we can call it article effects you don't have to call anything but it's just useful and let's create one for the left foot first so so here where the where the left foot is planted right click on our particle effects channel add notify and you can see that we've got play niagara particle effect so we can play that at the same time as the left foot is down and if you select that and look in the details panel here we can specify which niagara system we want to play so go in here and type dust and make sure you've got your ns foot dust selected and then the other important thing is we want to attach it to a bone so this is for the left foot so if you type l and then from the drop down make sure you select foot l socket this will be attached now to the left foot at this offset location so you can probably leave this as zero it'll be in the middle of the foot but that'll probably be um that'll probably be fine so that will now play uh and be attached to the left foot when that left when that frame hits and the left foot is planted so what we need to do now is copy and paste this to the other left feet so if you um right click and copy and then what we'll do is we'll just right click on the other areas and paste for the left and then just paste the first right one we'll obviously need to make some changes select it and we need to change the foot that it's attached to so here type r and attach it to the foot r socket the right foot and again copy and paste it to the right foot marker here and here so it put it that way but it is in the right place so now we have six particle effects playing at the in fact is that the right location no not quite anyway it doesn't matter if it's slightly out um so hopefully now if we go into let's save this two final things we've got to do is uh on the third person character with the mesh selected because we've changed the animation for manny rather than quinn we need to change the animation blueprint here to abp manny um that's just saves us it's it's virtually identical it just says just having to copy all of the anim graph stuff over so compile and save and if you go into play now you'll think that nothing's happening but that's simply because the dust particles are too small to see so we need to increase the size of them so come out of play mode go to your niagara system and if you select the initialized particle on the omnidirectional burst you'll see that there's a sprite size here so if we choose it between 10 and 30 for example to make them bigger save that and now if we go into play mode you'll see as we run around there's a puff of white smoke it doesn't really look like anything like sand at the moment but at least it seems to be working so every time the left and right feet hit the ground particle system is spawned and does that omnidirectional burst so last thing we need to do is really just tweak the particle system to get the particles that we want so i'll just tweak a couple of parameters for you then i'll leave it to you to tweak it to your desired taste so let's come out of play mode go to the particle system and what i'll do is if i go to the spawn burst instantaneous i'm going to make it so there's a lot more particles coming out so let's do 1000 and then i probably need to make them smaller again so go to the initialized particle let's make them between 5 and 15 and then color is the main thing i want to change so go to the color here and what i'll do is i'll saturate it sort of in this sort of orangey section and then i'll take the value here either brightness of it sort of down low here and click on save and let's see what that looks like a bit dark and probably a few too many particles especially when i get close so let's do a final tweak so let's make it a little bit lighter and change the number of particles to 600 save that comes play mode and that's okay and again i could play around with i probably want more particles again probably was right at a thousand and just make them slightly smaller so uh i'll leave you to play around with that hopefully you found these tutorials useful stay subscribed and i'll see you in the next one so bye for now
Info
Channel: UnrealityBites
Views: 12,459
Rating: undefined out of 5
Keywords:
Id: __-8JlcZKzw
Channel Id: undefined
Length: 30min 48sec (1848 seconds)
Published: Wed May 11 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.