Unreal Engine 5 - Footprints In the Sand (Landscape Displacement)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello fellow unreal engine developers today i'm going to be showing you how to create these footprints in the desert landscape i'll be showing two techniques a fake displacement method which is the one i recommend for unreal engine 5 at the moment and a true displacement method which has some issues that may be resolved in the future full disclosure i'm going to be using a toolkit called open land to do this because the blueprint coding is quite heavy to achieve this effect the great thing is the developers generously made this toolkit free for non-commercial use and it has a host of useful features which i may show you in future videos if you do need to use it in a commercial project the full license is only around 30 pounds and well worth it for the amount of coding effort it would save you at the end of the video i'll briefly describe how the blueprint functionality works so you get some knowledge you can apply in your own projects right after that long intro let's create those footprints in the sand [Music] first things first let's get everything set up we need you can achieve this effect on any landscape but if you want to do it on the desert landscape here then follow my earlier tutorial you'll see it in the link above and below and you can get this dunes landscape set up so that's the first thing you need to set up either the desert dunes landscape or your own landscape and then the next thing we need to do is get hold of the open land toolkit so if you go to the github link that i've put in the description you'll see this link to the unreal open land repository and all you need to do is use this drop down that says code download the zip file somewhere on your computer and then once you've unzipped it somewhere you'll have these folders and files go into the open land folder at the top then go into the content folder and you want this open land this third open land folder so copy that with control c and then find your project so here it is footprints in the sand go into the content folder of your unreal engine project and paste it in there and you'll have the open land and in here the open land directory in here and if you uh go go into your project now and look at the content browser you should have an open land folder in here with various subfolders with maps and blueprints like so if it looks like this open land at the top level and these folders at the bottom level you're ready to go and the last thing i wanted to show you this is not really to do with footprints but a lot of people were saying in the landscape video that they didn't like the triangle shadow artifacts what i mean by that is if i look into the sun can you see how you have these horrible looking triangles of shadows and this is caused by the fact that the landscape has a limited resolution and these are the vertices of that resolution and also the sun is low in the sky so the shadows are actually being cast in quite a harsh fashion now in most maps you'd have foliage or rocks or buildings that covered it up but because this is a large featureless landscape we're seeing these shadows in all their ugliness so the only um real quick fix i've got for this is just to raise the sun up a bit and and reduce the exposure so that you don't see these artifacts so if you go to your directional light for the sun and look at the rotation so one of these rotations will be minus eight minus on the y axis which is quite low in the sky so if i change that to -15 which will raise the sun up you can see that those have pretty much disappeared there's one there still but so you could even raise it a bit more that might just go away actually that just might be a temporary artifact that says well look as we go around oh it's still there so again i could raise it a bit more let's do minus 16 or even minus 17. okay and now it's gone so now you can see i've still got some shadows um but those triangles have gone and if it's too bright for you you can now go to your post process volume go to exposure and i've changed the metering mode to manual and then the exposure compensation we can reduce that so i could reduce that down to 10 and i've got a similar lighting model to what i had before but those artifacts have gone and if i go into play mode hopefully i won't be able to see those triangles as i look towards the sky okay so if you using your own landscape obviously make sure that you've got a character running around otherwise you've got nothing to leave footprints so you can add a third person character to your map we've got dust cloud here that was another tutorial we did which again i'll i'll put a link to in the description below in case you didn't see that so you can see as i'm running around at the moment and there's no evidence left beneath the mannequin that i was ever there so what quite a few of you were asking for is can we have some footsteps in um underneath the character and the answer is yes um so let's get into the first method of adding footprints so i call this first method fake displacement and it's my recommended method with unreal engine 5 at the moment it doesn't use runtime virtual textures or the virtual height field mesh which have a few problems which may may be resolved in the future so this method is guaranteed to work at the moment and is pretty simple to set up as well so let's uh start off by putting in the blueprint element which will write the trails in the sand and if i open up my content browser in the in this open land directory blueprint you will find a default folder and in there there's an open land deform manager and if i bring this in doesn't matter where it goes in the landscape this component is responsible for um writing and handling the trails in the sand or writing them to what's called a render target i'll i'll talk at the end of the video a bit of more about how this works under the hood but you can see that we've now got an open land deform manager and it's got various parameters so we'll leave all the defaults at the moment and again i'll talk about these at the end of the video i don't really want to get bogged down in the detail at the moment but for now make sure that you've got the follow player character ticked on this is a quick way for it to put a trail underneath your character so it will project underneath the character that's running around and create a circular trail so it's a quick way to test out whether this is working later on we'll add it to the actual feet so you've got footprints and that's probably all you need to worry about for the moment we'll come back and look at fading later on so this writes the trail to a target but we need something in our material that reads from this render target and applies it to our landscape material so we've done part one of what we need to do we now need to read the footprints and put them into the material so in order to do that we will go to our landscape and somewhere within here you'll have your landscape material it could be your own landscape material or if you've been following my previous video you'll have the bright desert sand material instance so open or browse to find that material instance and open it up and what i'd like to do is just drag it over to the side of the screen what i'm going to do is i'm going to pull this in a bit once i've made it small enough okay so that means i can adjust these parameters as we go so um the other thing we've got to do and this is a very important uh thing is in the landscape while you've got your landscape selected search in the details for dynamic and you must take this use dynamic material instance the reason being is that the blueprint code that we're going to put into the landscape material is going to set this render target dynamically that comes from the open land d4 manager so make sure that is set to true that's uh that's very important okay so now we need to open up our material this is the bright the bright desert sand is a material instance so if you go to the hierarchy you'll see the parent material which is ms surface material click on that and it will open up the material graph for this and it will look something like this so it has the textures for the color metalness the ambient occlusion roughness and displacement and normals and then they all get into this adjustment function and then go out into a surface material if you're using your own landscape material it might have a lot more nodes before but it should end up in a material attribute node and what we want to do is we want to apply our displacement to to start off with in this fake displacement just to the normals so the way we're going to do this is we're going to take our result node here and if you do break material attributes it will let's have a bit of space here anything that we've got up to this point in time will be broken into their constituent attributes and then we'll follow that by a make material attribute which combines everything together and then we'll put that back into the final result mode the reason we're doing this is so we can do some modifications in between so what i want to do now is take the base color the in fact i can take everything from here so some things i know i'm not going to use here so i won't worry about too much that's probably fine so the main things you need is base color metallic specular roughness opacity and you'll need normal as well okay and just to make sure everything's still working i would save this asset and go back to your desert and make sure everything still looks the same as before you might have a short delay while it prepares the shaders but what you're expecting to see is no change at this point in time because we've just taken the attributes out and then recombined them and put them there what we do want to do now though is we want to take this normal and we want to run it through the displacement function to read from this deform target so if you do open land read open lands deform data and this is a function that i will look at later on the video to show you what it does but it basically allows you to put in the existing normals and then it will spit out a normal with the displacement applied so at the moment we've got some errors because we haven't put in all of the required inputs so the other thing it needs is it needs a maximum height for your displacement so let's create a parameter so if you press s on your keyboard and we'll call this parameter displacement height and let's set it to a default value of 50 and then plug that into the max height okay and so that will displace by a maximum that the landscape by a maximum of 50 although we're not really doing real displacement we're just making the normal look different by that displacement so if you do a save hopefully you won't get any errors okay that looks good go back to your desert and now let's go into play mode and can you see underneath the character there's a circular displacement as i said this is a fake displacement it's just using it's just changing the normals to make it look like there's a divot in the ground there's not really any displacement if you've got low to the ground it's flat but it's quite a powerful illusion and as i said it's not using any of the virtual technologies that cause some issues so this is a good first start but it's not footsteps or not footprints i should say it's just a circle so what we want to do is we want to expand this to attach this deform component to each foot of the character so to do that let's go to the actually we can shut this surface material down now we've done everything we need to do there what we'll do now is we'll go back to the open land deform manager component and you can uncheck the follow player character we don't want that big circle under the player character for now and what we'll do now is if you go into your world settings if you don't see this world settings here by the way just go to window and it should be somewhere within here yeah world settings just check that and it'll appear somewhere on the screen you can drag it into where you want it so in the world settings you should be in your third person game mode and you should have a player controller a class sorry a default pawn class of a third person character so if you let me just move that along a bit if you just browse to that character and open up the third person character and go to the viewport if we go around what we want to do is we want to attach the trail making component to each foot so what you can do is you can add a component and if you search for let's see what's called um yeah if you search for deform it's called open land deform component so click on that and actually drag it underneath the mesh because we want it to be a child of the skeletal mesh and let's call this first one trail l for left and if you just move around moving quite quickly here what we can do is we can move it you might want to uncheck the snapping here and just move it so that it's sort of in the middle of the base of the foot sort of like that so that's where your footprint is going to emanate from and you can see there are some parameters here as well the maximum depth what it does is it looks below the foot this number of um pixels or units i should say and that's where it draws a trail so the higher you make this the more it leaves a trail even if the foot's higher up in the air so leave it as the default for now and come back and play with if you need to and then you can change the size of the foot footprint so you don't have to have it in a uniform dimensions if you want it longer on the length of the foot you could make the x and the y different i'll leave it as maybe maybe i'll make one of these i'll come back and change that later let's leave it as 40 and 40 for now and then you get a choice of brush material as well so there's various deform brushes here you know deform brush foot brush hole again you can play with those and we'll have a brief look at those later on so let's choose brush foot that might be the right one for this particular application there's some other stuff for drawing debug lines to test it out but we probably won't need that okay so we've done the left trail um let's duplicate that with control d and we'll call this one trail r and what we'll do is oh actually sorry one very important thing go back to trail l we need to make sure it's attached to the foot socket so if you go to the parent socket here and you want to select this foot l socket and then you want to position it so so make sure you make sure you've selected the foot socket first and then position it where you need it under the foot sorry about that forgetting to tell you that important point okay middle here okay and what i'll do actually is i'll delete this trail r and then duplicate it again call it trail r and the parent socket is going to be foot r socket and you should see it should snap straight to the right foot because it's uh in the same relative location with that foot so we now have a trail l and a trailer underneath the feet and they both have an area at the same area size of 40. okay so compile go back to your play mode and let's see what happens and now you can see as you run around we now have footprints being left underneath those feet components so you can adjust the um area size to get the effect you want and you've pretty much got the fake displacement finished now the only last thing i'll show you is that there's you see that the footprints are left behind everywhere you might want them to fade over time otherwise you'll just end up with a desert full of footprints so come out of here if you go to the default manager open and default manager you might have to go back to your details panel here i mentioned briefly there was this fading section so if you enable deform fading there's a couple of parameters here for the percentage of fading and how often per second it does that fade so i think one is the maximum and the fade interval of one second so again you can play around with these um i've tried a fake percentage of 0.3 which i think is a third every time and i'll fade the fade into 4.1 which means it'll do it 10 times a second so if you now go into play mode if i run in a circle you can you see by the time i get back to the start the first footprints are starting to fade away i've probably done a bit too a bit too slowly yeah but you can see now the first footprints that i had here have virtually gone so you can play around with that and um that's uh a more authentic effect and uh if you have if you're running in things like mud or water which are very viscous you can make that fade very quick so that the footprints pretty much disappear straight away so that's the first method and that's my recommended method fake displacement let's move on now and look at the second method this next method i'm calling true displacement and this is the uh using virtual height field meshes to replace what you used to do with tessellation in unreal engine 4 i did a video last week on the differences between unreal engine 4 and unreal engine 5 for displacement and i mentioned in that video that there were a lot of issues with the current virtual height field mesh however i think it's still worth showing the technique because it may be something that's fixed in the next months or so and this will therefore become a a proper way of achieving displacement however there's lots of issues at the moment and it's very convoluted to set up so be prepared for quite a few activities to get this working and even then there are problems that you're probably not going to want to live with so that being said let me show you how you achieve true displacement for our footprints so continuing on from where we left off what we're going to do now is we are going to take our landscape material and height information we're going to write it into two runtime virtual textures one for the material information or the textures and the other one for the height information we're then going to read that height into a virtual height field mesh which has got adaptable vertices so we can then apply displacement for the footprints into that virtual height field mesh and we'll also get the textures from the runtime virtual texture to apply to the virtual height fill mesh so it looks like the landscape there's quite a few things to do as i said so let's get started with the things we need to enable in order to get this to work there's a setting and a couple of plugins so if you go into your project settings edit project settings search for virtual and under engine rendering you want to enable enable virtual texture support make sure that's checked it'll ask you to restart but just hold fire for a second come out here and go into edit plugins and there's a couple of plugins we want to enable so if you type editor and scroll down a bit to editor scripting utilities make sure that's checked this will allow us to use a couple of widgets that openland provides to set some of these virtual elements up for us so make sure that's checked and then search for height or height field and you want to enable the virtual height field mesh it says it's experimental and in my experience that's very much true there are quite a few things that don't work as i would want them to but again this may be fixed soon so let's uh let's give it a go and then it'll say restart now so rest pause the video restart and then i'll rejoin you in a second or two okay so hopefully you've restarted your project without any problems let's do this in stages the first thing i want to do is i want to write the material information for the landscape to a virtual texture and then apply it to the landscape just to see it if it looks the same as it did before so in order to do that let's go into our content browser choose the open land folder and there's a widgets subfolder and you'll find this openland rvt widget in that folder if you right click and run the edit to utility widget it will say it's using the landscape as the act the ground actor so it's going to add a virtual texture that surrounds this whole landscape if your landscape's got a different name it'll probably appear here so just click add rvt support and then it tells you a couple of things you need to do i'll do these with you over in the outliner you now have two runtime virtual textures so make sure that the one that says rvt volume height is selected and then select the virtual texture of rvt open land height then go to the rvt volume material and under the virtual texture select rvt open land material now that tutorial stuff disappears now get rid of that and now we have our two runtime virtual textures ready to receive information so the next thing we need to do is change our landscape material to right to we're not going to do the height yet to write to the runtime virtual texture material so you need to go to your material for the landscape so landscape landscape material open that up this is my bright desert sand instance and then in there go to hierarchy and open up the parent material if you haven't already left it open and you should eventually get to this material graph which is where we put in some code for our footprints in part one of this video what we're going to do now is we're going to instead of directly writing these attributes out to the material we're now going to write them to our runtime virtual texture so delete this make material attributes node here and right click and type runtime virtual texture output select that and so connect everything that you can connect to from here base color specular roughness and the normal is going to come out of our deform function for the footprint so take the normal from here and take that out so what this does is that has now written it to the runtime virtual texture and what we're going to do now is going to read that runtime virtual texture and plug it into the final output of the landscape material so in this empty space down here do run time and you want to choose runtime virtual texture sample and don't forget to do this this is something i forget all the time you need to specify which virtual texture you're reading from we want to do the rvt open land material and what we now need to do is we now need to make our material attributes again so we're going to copy over the things we copied in a second ago base color specular roughness and normal and then we'll connect that to the output so we've got the same thing going on except we've got this runtime virtual texture in between that's being written to and then read from in order to create our final material output so click save here and go back to the desert you can see a little bit of blurring you might have seen that while it quickly compiles and creates the runtime virtual texture now we haven't completed the setup of this because the landscape component here needs to specify which virtual textures it's writing to we we specified which one it's reading from but we need to specify which one it's writing to so if you go down to select landscape select the details and go down to a section called virtual textures this has been set up actually this has been set up for us already by the widget but if you were doing this by hand you would have to add in the two virtual textures of open land material and open land height to write to so these have already been set up for us so now when it writes the material information in the landscape material it's writing it to the open land height so if i go into play mode it's uh it looks the same even the normal based footprints are there because we were writing those to the texture as well there might just be some slight blurring of the texture because you can set the resolution of your runtime virtual textures depending on the quality level you want in the final destination platform and if you want to be sure that it's using the runtime virtual texture just to test it out go to the material and just disconnect in where we're sampling this you know the runtime virtual texture sample output just um disconnect say the base color press just press the alt key to disconnect it and save it and then if i go into back here you see how the the texture has gone black because we no longer have the color so that's showing you that it is coming from the runtime virtual texture and um runtime virtual textures are pretty good they've been around for a while and used for various things like blending of meshes in the landscape with the with the actual landscape so that that works pretty well so let's go back and reconnect the base color resave and we should have our color back and again you saw that little blurriness while it quickly rebuilt the runtime virtual texture okay so that's the first part done and that was pretty successful what we want to do next is we want to create a virtual height field that will act as a proxy for our landscape so we're going to we're going to make our landscape invisible and we're going to use height information from the landscape to drive a virtual height field where we can provide more vertices especially in the foreground for our footprints to have real displacement so that the next thing we need to add is the virtual height field mesh so if you go into your content explorer go back to again open land widgets and you'll find another widget here openland hf mesh widget right click on it and run it and if you click on the add hf mesh support button you can see over in the outliner it's added a virtual height field mesh and it tells you a couple of things you need to do over here so what we need to do is select it go to the top of the details panel and in the virtual texture that drives this height field we want to select the rvt volume height so it's the volume that we need to select okay and the other thing we need to do is we want to switch off rendering the landscape so go to your landscape component come down to where the virtual textures are defined and here where it says draw in main pass change that to never what this means is that it won't actually draw the landscape it will still be there for collision purposes but in its place we're going to have the virtual height field mesh so what will happen now is if we go into play mode you'll have this weird invisible landscape and actually you can still see the desert way down in the ground because we are that is the virtual height field mesh it's just that we haven't generated the height information for it yet so you get these sort of ghostly footprints that are appearing about a thousand feet beneath us so anyway that at least proves that the height field is there but we need to get that height information into our runtime virtual texture and then into the virtual height field mesh so let's come out of play mode and first of all let's write the height information to this rvt so go back to your material your surface material or whichever material you're using for the landscape and we need to plug the height into this world height node of the runtime virtual texture so let's forget about displacement for the time being again let's do this in stages to get the height in here right click and type world position this world position is in three dimensions and we only want the height so drag off here type mask and choose the component mask and select just the b component so r r g and b are x y and z axes so we just want the height which is the z axis and then plug that into the height and that gives us the height information into our runtime virtual texture so save give it a moment to compile and i don't know if you notice here but if you've got the landscape selected can you see how our runtime virtual textures you can now see what's being written to them the this one is the material one so that's the sand material textures and here is the height information so this sort of dotty view of black and white is the ups and downs of the dunes so that's the that's the rvts being written to so if we now go to our virtual height field mesh one thing we can do here is normally doesn't show it in the editor but if you go to actor hidden in editor yours will be checked at the moment because i've done this tutorial before i've unchecked it so if you uncheck back to hidden in editor it'll actually show it on the screen in the editor and if we go into play mode it looks the same now here we see one of the first issues with virtual height fields looks the same but there are no shadows so again this may be a big problem for you our landscape before generated shadows based on where the sun was again if you have lots of meshes on the landscape so foliage rocks and buildings you may not notice this so much and in fact my dust cloud is uh obscuring the problem a bit as well but um i have to say it is working so the um runtime virtual textures are now being projected on to the virtual height field mesh you get the occasional sort of flickers that are going on um and i'm going to show you later on the parameters that allow you to determine the level of detail um you know for the number of vertices you see on the actual virtual height field because that can cause issues as well you don't get that right but uh okay we've we've got past stage two and that's working okay i'm also gonna um let you know that if at this point in time you see some horrible triangulated pixelated shadows on here it may be to do with lumen and ray tracing so if you go into your edit project settings i know i had this problem when i first did this if you search for lumen first of all you've got this use hardware ray tracing when available i found that when i had that on it just didn't work properly so i switched that off and then also if you go into ray tracing i did unchecked support hardware ray tracing again there are a couple of different tracing methods detail and global you can play around with those and you might have to generate mesh distance fields as well usually you'll get some um instructions if things aren't right you'll get instructions in the editor as to what you need to set on here but it is a little bit tricky to set up so so anyway we've got the virtual height field mesh set up we've got the runtime virtual textures created what we now want to do is generate some real displacement in our height so to do that if you go back to the surface material here what we want to do is we want to use the deform function which allows you to take in an existing world position offset and output the deformed offset so let's get a little bit more space here let's get rid of this mask i'll tell you why we're doing this what we're going to do is we're going to we're going to feed in the absolute world position into our deform and then what will come out is the deform that the height plus or minus the displacement of the footstep so if we take this out here and put it there that should give us displacement with footprints so let's see what we get do a save in fact no there's something i've missed i'm not even going to try and test this yet the world remember the world position offset is the in three dimensions so we need to do a mask so type mask do component mask and set it to b for the z-axis otherwise i think you'll get some issues and that's and the output from this is the world height okay so that that looks right now we've taken we've taken the world position offset we've applied our default deformation to it for the footprint and then we've masked off the height here so save this go to our desert go into play mode and can you see now we are sunk into the landscape we're getting some true deformation in there probably want to make the foot print a little wider now we've got some real displacement and again i'm seeing a little bit of flickering going on because that uh stability of that virtual height field mesh but it's not bad for a first attempt so let's do a couple of tweaks come out of here and go into your character um go to the trails that we attach to the feet remember we attached let's come around here we attached two trail components to the feet and what i'm going to do is make them a bit bigger so let's make them 70 by 70. compile let's go into play mode okay that's quite good so the other thing you might notice is that the feet are always sunk into the landscape and that's because the the brush that's right in the displacement isn't going fully as deep as the landscape offset so we could add a parameter for that if we go back to our material and we could hit we could here have this is our displacement height parameter here what we could do is we could use the s key oops s and left click and we'll create a new parameter called offset height and what we'll do is we'll just simply add here the offset height to the displacement height before we plug that in so this just gives us an opportunity to raise or lower the landscape or the virtual height field mesh after we've applied the all the footprint stuff so let's make that default this should be a negative value so let's make this minus 20 i suppose we've got 50 here about half and save that and now if we go into play mode you can see that now i'm getting the displacement but my feet are still resting on top of the um the landscape and you can see if i come out of here if you if you open your material instance here go down to near the bottom you can see the parameters here provide so you can play around with those so you could you know you can make it deeper for the footprint and then we'll make the offset minus 30 to bring it back up and then go in there and now we've got slightly deeper footprints but our feet are still visible within there so um so again you know you're seeing flickering here the the other thing i want to mention is that you adjust the detail of the virtual height field mesh in the lod section of the virtual height field mesh so if i come out of play mode with my virtual hf mesh selected if i go to the go to lit mode and choose wireframe so this is my v i've got my virtual height field my select you can see this is the detail level uh which is it's not bad it's pretty detailed if i come up here to the lod section of the mesh and by the way it's it defaulted to this mihf mesh which it does read from the runtime virtual texture sample but actually i should have been using my desert sand landscape here does it scan material shouldn't make any difference let's just double check lit yeah it's the same it's just that you might be confused why it was using that material that was just the default that was in there let's go back to the wireframe mode and it's these parameters here that look at the detail or control the detail in the foreground the background so if i make the lod distribution one we're back to virtually what we had with the original landscape so no detail at all and then as we increase this you get a little bit more detail and then the distance scale affects how far away the lods diminish so you can play around with those and obviously if you go very high with these you're going to have a lot of detail going all the way into the landscape and there might be performance penalty i i haven't really played around with performance i don't know if that's an issue or not um but um this affects you know the detail you see again this is like used to do with tessellation um but it's now done with the height field mesh so i want to show you another issue to do with height fields that i again think is problematic at the moment so to show this problem in more detail i've added some quiksil mega scans into the landscape so these are just various rocks and sort of canyon features that i've added to the landscape and the problem i want to show you is that the meshes that i've added here are added to the landscape they're not added to the virtual height field mesh so if your virtual height field mesh changes height information due to those lod settings then the um meshes will actually change relative to the height field measure it's probably best if i show you the issue so i've got the virtual height field mesh selected here and this is the um sort of starting point that i had it set at a lod distribution of 1.7 which is fairly detailed vertices on the mesh so if i go into play mode and let's just go so i run towards the camera so if you look at the rocky meshes you probably might see some very subtle movement so what's happening is that as the displacement detail the height field vertex detail in the background loses lod it just subtly shifts that information now obviously you can you can increase the level of detail here in fact you can increase this one as well which makes it last for longer that might make the issue less problematic let's go the right way okay and they're sticking to the ground a bit more there but the problem is that very distant features and i've noticed this in landscapes with mountains um you get the steeper the slope the more that the error factor in the virtual height field mesh shows itself so you can actually get mountains that literally pop up and down sort of from half their size to full size because the vertexes that represent them are just popping in and out of detail so again virtual height field measures have a bit of a problem with the more slopey the terrain is and i'm going to show you the extremes of this here in the foreground let's come out again let's put this right down to let's put this down to one and i'll make the lod distribution 1.1 which is quite a few vertices you can see straight away that it's got almost a stepped effect here so as i run you see it's almost the rocks are sinking into the landscape and i know this is an extreme example but this is what you see in the far background of virtual heightfield mesh landscapes so again you've really got to think about whether you have mountainous terrains with virtual height field meshes anyway that's um a few of the problems with it they may get resolved so you know there may be hope for this true displacement but as i said i'd stick with the fake displacement of the normals for now which doesn't need to use anything experimental and i'll finish off this video by giving you a brief description of how these blueprints are working so you actually get some insight into the way the blueprint technology achieves this displacement i'm going to go into in full detail just to show you an overview so let's move on to that this has already been my longest video so far so i'm just going to look at the keynotes in each blueprint just to show you the flow of logic and then i'll leave you to explore the rest on your own so let's start off with the openland default manager this is the blueprint that we placed on the landscape and the key thing here if i go to the top of the event graph at the begin play so when the game starts it clears a 2d render target called rt hit info and the 2d rendered target is really just a plane on which you can draw with materials so this is going to be where we store our footprint trails and then we later apply them to the landscape meshes so that's the first thing clearing out the render target ready for new footprint trails and the only other really key thing in here is if you look in this set material parameters function just down here it gets your landscape and it sets the hit info render target to the render target that it's just cleared and that means that that landscape material will have this render target and can use it to write to the material textures that's why we needed to set the dynamic material instance on our landscape material so that's the only other key thing so um that's all i'm going to look at in the d4 manager the next i'm going to look at is the component that writes the trails and i'll just briefly describe how that works so if we go to the open land folder blueprints and deform this is open land deform component these were the components that we added to each foot of our character so i open this up and again there's quite a few things here but i'll just cover the key things first thing is at the beginning of the game it gets that open land d4 manager that way it can get references to the render target and then it's got an event tick which executes every frame so as this is a visual update he needs to check every frame where where the component is and then write the footprint trail so let me go through here and go to the next bit of interest it does a line trace downwards from the component so we had two components on our feet and we set a depth on each of those components so effectively what it's doing here is it's tracing or sending a line trace down for this depth to see if it hits any ground underneath and if we didn't have that depth there it would leave the footprint even while the feet were in the air which we don't want we only want the trail while the feet are on or near the ground hence the line trace depth so does the line trace to see if it hits a landscape underneath and if it does hit something it gets the d4 manager and it writes data so this this um function here is writing the information to the footprint information to our render target so it passes in uh the name of the default manager the brush that we're going to use for writing to the render target we get the location of the component so if i open this up and again there's a lot in here but the key thing is that it begins drawing to the render target it draws the material based on the brush we've got and the positions and the sizes we've been given there's some logic in here that calculates the world position and because the render target is actually smaller than the world so it uses some pivot points and world positions there so you can explore that see how that works and then once it's drawn onto the canvas it ends draw canvas to render target to effectively complete that that tick event so now we have information in the render target we need to get it on to the landscape so the last part of the logic flow if i close this down in our material this is what we've been building in this tutorial we used this read openland deform data where we passed in the height we wanted normals were came in and the new normal was output with the footprint similarly with the world position offsets for the true displacement let's put out so if we go into this function and i'm just going to zoom out it's quite a lot in here but it's sort of two streams this top stream here is all to do with true displacement where it says w calculate wpo blend with existing wpo and these four common boxes at the bottom are all to do with the normals so that was the fake displacement that we did so let's look at the top stream first what we have here is some code that gets the current world position masks it on the r and g which is the x and y plane and passes it into this function and this function is what uses the render target it effectively looks at that x y position adjusted for where the render target is on the landscape and it spits out the height displacement this input here is the maximum height we wanted as a parameter and then it multiplies the mod the height by a value probably between 0 and 1 here for the height and then it goes over here and let's ignore some of these things for now the key thing here is it takes the existing world position offset and it adds the height to it and outputs it so that's how it does the true displacement as for the fake displacement using the normals that's actually quite uh a bit more complicated and i i also would say i haven't fully gone through this in detail to understand this yet but what it's doing is it's using the again it's getting the absolute position in x and y coordinates and it is creating some calculations here in order to be able to work out the normals for those uh render displacements so you can see there's some logic here there's one trail that multiplies by one and there's one that rotates a third another one that rotates two-thirds before applying those displacements and that will get out probably a normal at that point which it then passes into a bit more logic which calculates the normal it then mixes the normal from the render target with the normal of the landscape or the height field mesh so based on the slope and then the final thing it does is if there are if there's any other normal information that came into this function for example if you had some micro displacement that happened earlier in the material function and then it will blend with that as well and finally output the normal so um there's some as i said some smart uh functionality in here and you could probably learn a lot just from studying all of these um all of these blueprints even the brush materials for the render target are quite involved are they effectively creating um feathered brushes that go from so you get sort of nice smooth slopes on the sides of your normals or displacements so as i said this has been a very long video i just wanted to give you a brief overview of the way the logic flow through these blueprints so that you learn a bit from it and i hope you found today's tutorial helpful stick with me and i'll have a few more tutorials coming up soon so i'll see you then bye for now
Info
Channel: UnrealityBites
Views: 38,038
Rating: undefined out of 5
Keywords:
Id: GhtZK8J2LcM
Channel Id: undefined
Length: 61min 33sec (3693 seconds)
Published: Thu May 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.