 Hi, welcome to Gamedev Academy. I'm Shane and in today's class We're gonna take a look at how you can add assets like rocks etc to your landscape in Unreal Engine and Not have it look like arse 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 here, I'll 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 Over here. This is exactly the same. Remember. We don't have that same problem Because this sand texture here is blending into the material used on the rock and it's making a much more believable group of assets really so and If we have a look at that and 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 that kind of really sticks out But here it's still there. It's there, but the colouring 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 been here is I've used mega scan stuff So it's a mega scans material for the landscape It's also a mega scans rock that I've got which also has the mega scans 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 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 tie beach rock And we're 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 measures intersecting That ought to do it saying 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 to so that I know this is 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 RVT underscore height Your height to 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 set up 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 a lie drop at all 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 and see landscape now appears here Which is what we want Which means that the bounds align 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 RVT underscore environment and Now we can click on this set bounds bottom 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 to 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 No, no, 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 going to have as specular So I'm going to change that down here and then we need a roughness So we'll have roughness third and the last one's going to 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 need to change the normal from tangent space to world space And if we just drag out of 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 it into normal and we will 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 Brilliant, 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 we created So in my case, it's going to be RVT underscore environment to and RVT underscore height to 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 was 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 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 Just over here and I'm going to choose the RVT underscore height to 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 node 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 changes 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 This blending through red and it goes into the other material, which is brilliant. That's what we want so now what we're going to do is just finish this off and The job is as they say a good and so let's go back into our rock material And we're 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 is 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 I 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 base color first followed by specular and Then we've got roughness Finally normal and then we can pass the first one two three straight straight through so base color to base color specular to 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 tangent space to world space. 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 runtime 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 Suns 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 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 gonna 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 done. Thank you so much for watching and I will see you in the next one