QUICK TRICK to Realistically BLEND ASSETS with LANDSCAPE | UE5 Runtime Virtual Texturing Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to gamedev academy i'm shane and in today's class we're going to take a look at how you can add assets like rocks etc to your landscape in unreal engine and not have it look like us and what i mean by that is get them to blend a little bit more believably than they would without this technique that i'm about to show you so if we have a look on my screen what we have here are two identical setups so they're both very small landscapes with the exact same material applied and then two mega scans assets and literally all i've done is this one was the original i duplicated it over here and this is the one with what we have called runtime virtual texturing applied to it and i want to just highlight what this does before i show you how to do it so if we have a look um here let me just go right to this bit here this is where these two assets join and you can see that it's really noticeable that i've just stuck two together that don't really belong together however um over here this is exactly the same remember we don't have that same problem because this sun texture here is blending into the material used on the rock and it's making a much more believable group of assets really so um if we have a look at that you can see that there are some differences that happen so you've got this bit here if you can see my cursor on screen and it kind of really sticks out of it here it's still there it's there but the coloring of it's changed again in order to get it to blend in better so this is a really cool technique and what i've done here is i've used mega scan stuff so it's a mega scans um material for the landscape it's also a mega scans rock that i've got which also has the mega squares material on which means the way that you can download them from mega scans is it comes as one master material and then you get lots of instances which means if you set this up once it'll pretty much work for everything in your level so it's a really cool technique anyways let's stop waffling and we'll get into what you need to do to get this set up so first thing you need to do and i actually fell foul of this i spent about half an hour trying to work out why it wasn't working for me we need to turn it on in the project settings so the way that we do this is if we go to edit project settings and then this window pops up and if you just search for virtual and then there's a section here for virtual textures and enable virtual texture support make sure that you tick that so originally mine wasn't enabled and so it wasn't working so that's step one okay now what we'll do is we'll go to a fresh level so you can see me setting this up from scratch so here's a level where i've just got this set up so if we just do this really quickly um so if we go for i think it's called sand yep so let's apply this sand material that i got from mega scans to the landscape lovely and we need the rock that i also downloaded where's that here it is the thai beach rock i'm just going to plop that there and we're just going to get it so that it intersects and actually i'm going to go a little bit bigger as well just so that we can see what we're doing so we've now got these two meshes intersecting that'll do it so you can see we've got these hard ugly edges here and that's what we need to work on okay to do that then we need to create two what are called runtime virtual textures so if i just get rid of this search thing here and we go into the content folder which i believe i'm in yeah and you can see that i've already got two runtime virtual textures set up for the other level so we're going to set these up for this level as well to make sure this works so what we'll do for that is just right click in here go to textures i'm going to create a runtime virtual texture okay we're going to call one rvt underscore and this one's going to be environment environment and i'm just going to put environment two so that i know this is the the different one for me so that's one of them set up and then we're going to create another so let's go in there and rbt underscore height height two there we go and then we need to open this height one up so we just double click on it and what we need to do is tell this that it is just the height one so this little drop down box here virtual texture content you can see that there's one here for world height so we just need to change that and then click on save and then we can close this window on this tab rather and that is our two rvt runtime virtual textures setup okay the next step is to now create two runtime virtual texture volumes and this works together with those textures to give us the effect that we want and it also tells it where we are kind of sampling the texture from in this case it's going to be the sand on the landscape so we need to get that set up so we're going to click up here which is the add button and then i'm just going to start typing runtime and then you can see that it suggests runtime virtual texture volume so we'll click on that so now with that created we can go into the details tab here and this is little eyedropper tool and we're just going to click on that which is pick actor from scene and we're going to select the landscape like so you see landscape now appears here which is what we want which means that the boundary line actor is that and we also need to just tell it which one this is going to work for so we'll go for the environment first so rbt underscore environment and now we can click on this set bounds button and you'll see that now this volume has changed size to match the size of the landscape now we need to repeat this again so let's go to here we'll start typing runtime create a new volume we are going to select the landscape again then we are going to select the height so rvt underscore height 2 and click on set bounds so that's now starting to pull all this information together okay with that done now what we need to do is make some changes to our landscape material so what we need to do for that is we're just going to click on the landscape and if we scroll down we can see that the landscape material is here i'll double click on this and we can see it's an instance so then i'm going to double click here which is this master surface that it gives us when we use mega scans so this is kind of how it starts and we can just close that one there okay so you can see what this does is comes out into a material attributes node and we're just going to move that over a little bit make some space and then we need to just get these material attributes so if we come out of result here and we go for get material attributes awesome and then we need to add a few channels to this so we'll go one two three four and we want base color to be the first one the next one we're gonna have a specular so i'm gonna change that down here and then we need a roughness so we'll have roughness third and the last one's gonna be normal brilliant now we need somewhere to put this information so we'll create a runtime virtual texture output so if we just start typing that runtime virtual texture output is here and then we need to just plug these in so we're going to get the base color we'll go into base color specular will go into specular our roughness will go into roughness but we just need to change the normal from tangent space to world space and if we just drag out here and type transform like so and by default it'll do what we need it to do so it's going to be tangent space to world space and then we can just put that into normal and we'll convert this back later but for now that's what we need to do we also need to get the absolute world position so if we start typing world position create a new node there and we need to mask this so we're going to type component because it's a component mask like so and what's important about this is that we do it on the blue channel so it gives you rgb channels but they can also be width height and depth so we're going to turn off the width and height and turn on the depth which is the blue channel in this case and we're going to plug that into our world height and that prepares this material to pass on its information to whichever other material comes into contact with it so we can now save that building that's all saved and now we just need to go back into here make sure that we select our landscape and we're going to scroll down and we are looking for where is it the virtual texture section here we're going to add two array elements and now we need to add these two runtime virtual textures that were created so in my case it's going to be rvt underscore environment 2 and rvt underscore height 2. for you it will just be environment or height and what's kind of important at this stage is that you're seeing these previews pop up if you don't it means you might not have it enabled which is my issue so make sure you can see something popping up here okay now we've got that done we just need to make some changes to the material for the rock so let's click on that find the material for it let's scroll up here so here's the material i'll just open that scroll down and here's the default material so this is different to the sand one so we'll just turn that off and we need to make some additions to this one as well so you can see this one also comes into a material attributes node so let's just move that over a little bit and what we wanted to do now is blend between this material which is the rock and the sand material based on an alpha which is taking its information from the height of the assets in the level so let's get that set up so what we need again is world position so let's get world position like so and we need also a runtime virtual texture sample which is this one here now we need to tell this one which sample we want and just over here and i'm going to choose the rvt underscore height 2. so this is what we're going to be basing our alpha on so it's the height information that we really need here okay so now what we're going to do is get a component mask component mask which comes out of our world position make sure that this is working on the b channel because we're dealing with height and what we want to do is get a subtract node like so so this is our world position and we're also going to take our world height from here and we're going to subtract one from the other and so if it is i think the way it works is if it's a positive value that means it's going to blend because it needs to blend if it's negative value it won't because it doesn't need to blend okay so that's coming together what we also do and i wish i could tell you why we do this but we're going to get a divide note and we are going to divide by 10 and we're doing this because when i learned how to do this this is the way that they did it one of the people that works for epic games that taught me this so i'm going with it because it's their method and it works right so what we also need now is coming out of here so this material here we're going to blend the material attributes lovely i'm going to go from a to b so all of these values here need to go into the alpha like that and we're going to have the result of this going into b and not into a and the result of this is going to go into the material attribute there and we're just going to kill that wire so now we know what b is going to be and we know what's going to drive that is this maths and stuff we've got going on here what we need now is just something else to blend with it and for now what i'm going to do is just get a constant vector and we're just going to set this to red and this is just to make it easy to see we'll change it for the proper material in a little while let's just set this to a nice strong red color now you can't just plug this in because it's about blending material attributes so we need to create a set material attributes node we're going to add one it's going to be base color and that goes into base color and we can now pass that through into a like so so now we've got this is our maths and it's going to say take the rock material and blend it with red based on the height i have missed one node out though before we move on so coming out of this divide we just need to create a saturate node here and that's going to then feed into the alpha okay so now we can save this and we'll go back into our level and see what we've got going on so this is why we made it red so that you can see the effect that this material change is having so you can see here's our sand here's our rock and where the height between this and this is quite different we are getting um this blending through red and it goes into the other material which is brilliant that's what we want so now what we're gonna do is just finish this off and the job is as they say a gooden so let's go back into our rock material i'm going to be making changes to what feeds into the a of the blend material attributes node so we're going to get rid of both of these we need a runtime virtual texture sample like so and this one's going to be not the height it's going to be the environment so this is going to bring in the environment texture which in this case is our sand so let's click on that and we also need to create a set material attributes and you can see that we don't yet have enough inputs for this so we're going to add one two three four and we're just going to put them in the same order so we've got a base color first followed by specular and then we've got roughness and finally normal and then we can pass the first one two three straight straight through so basically it's a base color speculative specular roughness to roughness and if you remember we have to convert our normal map again so we'll get normal we'll go to transform and you can see it's still doing tangible space to world space so i need to reverse that this time so we're going to do world space to tangent so we can change that over here in the bottom corner so we're going to go world space to tangent space brilliant and that is pretty much all we need to do so we take the result of this plug that into a and we save so the preview here is showing us that based on height it is now blending between two different materials but it doesn't give us the best preview here so let's go back to our level and you can see that now these are blending together really well and what's good is it's always based on the height and it's always happening at time so if we make this lower the blend will happen at a different height so we can have these just sticking out and they'll still blend or we can go really quite a bit higher so that most of that other sun's popping out and it still blends and that's it that's what i wanted to show you that's the technique it means that basically any asset that you bring in can blend into your landscape in a much more realistic and believable way and it just looks nicer it's easier on the eyes and that brings us to the end of the video i decided to make this as a separate tutorial i am currently in uh research and development of quite a large unreal engine 5 tutorial series if you want to see that then make sure you give this video a thumbs up subscribe to the channel otherwise you're going to miss it and it also be really helpful if you could support me on patreon to give me the support to keep making tutorials like this anyways that's me don thank you so much for watching and i will see you in the next one
Info
Channel: Game Dev Academy
Views: 94,272
Rating: undefined out of 5
Keywords: unreal engine, runtime virtual texturing, rvt, runtime virtual texture, runtime virtual textures, blend, seamlessly, landscape, materials, megascans, mega scans, tutorial, blending, ue4, ue5, realistic, asset blending, blending asset with landscape
Id: ATfzfvtvfIo
Channel Id: undefined
Length: 16min 58sec (1018 seconds)
Published: Sun Aug 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.