 Today's video is brought to you by the Compiling Shaders t-shirt over on the Gamedev Academy store. Check it out using the link in the video description and use early bird at checkout for 10% off your order. Good morning class, welcome to Gamedev Academy. Make sure you sign the register by saying hi in the comments section. I'm Shane and in this week's video we're going to be taking a look at how you go about creating a landscape layer blender material using materials that you get from Megascans, which is how you get really cool photorealistic materials like the ones that I have on screen right now. So if you'd like to all take your seats we will make a start. Okay so the first thing we're going to need will be some Megascans materials and if you're not aware how to do that I'll just show you we'll get an additional one. I've got some already but let's get some snow. So if we click on this icon up here which is that quickly add to the project and then we're going to go to Quixel Bridge. That will then open this little window here for us and then what I'm going to do is just search for some snow. So let's search for snow like that. I quite like the look of this fresh snow here so we'll click on that. Then you need to click on this download button just here. You can see that that's now downloading for me and now that it's downloaded the last thing I need to do is just click on this add button here and you can see that has now added that into my Unreal project so there's the material and there are the textures associated with it. So what you need to do is get yourself I'm going to say a minimum of three materials for this. I'll show the ones that I've got. So if we go here in my content browser I've got this surface so it puts it in a folder called Megascans and you've got surfaces and I've got some fresh snow, some wind swept snow, I've got layered rock, a mossy rock, a rocky step and some wild mossy grass. I've got six to choose from. I'm probably just going to use about four for this but you're going to need to have those surfaces to start with. So I'm definitely going to use this rocky step for instance and that just looks like this. It's a nice material. Anyways, let's make a start on building our landscape layer blend material shall we? So here's what we'll do. We need to just choose any one of these materials that we've got, these surfaces so I will do this one because I'm in this folder. We'll just open it up again and then we need to find the parent material so the way that the Megascans ones work is they're all kind of material instances so we need to find the parent. So if I scroll down here, there's the parent, if I click on this little search icon here that then takes me to the folder in my content browser and then I can double click on that to open it. OK, this is what the material looks like and we're going to create a material function that's based on this. So what we'll do is just do a big marquee selection and we're going to select everything apart from this M underscore MS surface material. We don't need that, but we do need everything else. So I've selected it. I'm going to do a control and see for copy. And then I'm going to go back here so I can see my content browser. Now we're going to create a material function. I'm going to create a few of these because these are what we're going to use to blend between. So I'm just going to go up to my main content folder just so I can see everything in one place. I'm going to right click and create a material function. So that's in the materials section here and there's material function. And I'm going to call it MF material function underscore layer one like that. And we're going to give them quite nondescript names because we can these are just the layers we can switch between what materials are in each layer later. But for now, we just need to have MF underscore layer one. Now we'll open this up and we have an output result, but nothing going into it. So what I'm going to do is just control and V for paste. Here's all the stuff that we copied. And I'm just going to connect this up to the output. And that's it. This is now ready to go is behaving in the same way as the parent material so that this works in our material instance that we're going to create later. We do need to rename everything and give it the layer names. So here's what I'm going to do this albedo here, the base color. I'm just going to rename to layer one underscore albedo. And then I'm just going to copy that layer one so I can paste it. So that's layer one underscore. This metalness is going to also be layer one underscore. The ARD, the ambient occlusion, roughness and displacement is going to be layer one underscore as well and same for the normal. OK, so that takes care of that. I also want to put these in a group. So if we look, we're currently in a group called zero seven texture maps, which is what they've come through as named by Megascans. But what I'm going to do is just select all four. And I'm going to give it a new name. I'm going to call it layer one like that. And then I'll know that that's all to do with layer one. OK, one final thing that we need to do is just control how the tiling works. And for that, we're going to create a scalar parameter. So we'll just right click and start typing scalar like so. And this one's going to be called layer one tiling. And we just need to put that through a multiply node. So I'm going to create a multiply node just here. Nice. And then the output here, so from the result at the top, we want to put that all into the output of the multiplier. I'm just going to move all the wires by holding control. And then when I click and drag, you can see they all come together and we'll just pop that in there, lovely. OK, now the result's going to go into A. So that's going straight through. And this now is going to be how we multiply that number. So let's just plug this into here. The default value we want to have as one. So let's just set that. And that means it's now currently doing nothing. And all of this stuff here is now to do with tiling. So we'll just expand our group there. And we just want to put this in the same group as well. So group here, we're going to put this in layer one. OK, that then is our material or our material function ready. So let's just save that. OK, I'm just going to tidy up a little bit now. So I'm just going to close that because we're done with it. And I'm going to close this one. And I'm going to leave this material function open. Now for each layer, we need another one of these. So I'm going to build a material here that's got four layers to choose from. So we need to duplicate this four times. So I'm just going to right click here and duplicate. And you'll see it becomes MF underscore layer two, which is the name I want to give it. And each time we duplicate these, we need to make the following changes. So let's just open this up. So we need to change the layer name. So this is layer one. We need to make it layer two underscore albedo. And I've got to do this for each of these textures, which I shall do ever so quickly. That's that one. That's that one. And here is this one, layer two. I also want to change the name here, make this layer two tiling. And all of these nodes here. So the tiling parameter there and each of these textures. Oh, it won't let me do that. I've got to do them one at a time. So we're going to do it with the textures first. And the layer is now going to be called layer two. So I just need to create that layer. And then here we can then just choose to add that to layer two. And that's it. So I can save that. So I've now got two layers ready to go. What I'll do now is just time-lapse me creating the next two layers. And then I'll pick up with you when it's time to start putting the blend material together. OK, that brings me to the end of all the renaming and duplicating and stuff. So that's ready to go. You can see I've now got one, two, three, four of these material functions. And I've renamed everything accordingly and put them into the right groups. OK, now back into my content browser. And I want to now create a new material. So let's right-click and create a material. And I'm going to call this one M underscore landscape blend. Seems like a pretty apt name, doesn't it? And we will open that bad boy right up. The first node that we need in here is a landscape layer blend node. So let's create that. Awesome. And because we're doing four layers, we need to create four array elements here. So we'll click this plus button four times. One, two, three, four. And then we just need to drop these down and name them. So where it says layer name, I'm going to have layer one. And then I'll just repeat this for the other three layers. OK, so we've done that. You can see that the layer names that I chose are reflected here. And it looks nice. So they're called layers. So I could have just named them one, two, three, four. But hey, live and learn. OK, so the result of this layer, I want to actually plug into a break materials attribute node. So let's just start typing break material attributes. There it is. And that creates that. And then we just plug these into the corresponding inputs over here. So base color goes into base color, metallic into metallic, roughness into roughness, normal into normal. And just because there is an occlusion on here, we'll plug that in as well. So that should be ready to go. Now we need to plug in the results of our material functions over here. So for that, we're going to create a material function. Let me find it. Material function call. And we're going to need four of these. And you can see, once you get one, you can just choose which material function you want. So if I now search for layer, we'll search for layer one. There it is. And then the result of that goes into, you guessed it, layer one. And then I'm just going to copy that and paste it three more times, paste, paste, and paste. This one is going to be layer two. This one, yeah, you guessed it, layer three. And oh my god, how did you know this was going to be layer four? You're very clever. OK, now we're going to plug these bad boys into their corresponding inputs over here. That's looking damn fine. And then just for no reason other than I wanted to look a bit symmetrical, I'm going to move that up a little bit there. OK, would you believe it? That's the actual material done. We can save that. Now we're going to go back into our content browser here. And from this M underscore landscape blend, we are going to right click and create a material instance. So the naming convention for this is to put instance at the end. I personally don't like that, so I'm just going to get rid of that. And I'm going to put instance, so M inst. I like to call them that. You can name it however you want, but I've done that. So that's going to create our material instance here. Now, if we open this up, you'll see that all the naming and hard work that we've just gone through is reflected in this material. So if we now scroll down, these layers that we created, layer one, layer two, layer three, are all here. And also the names of these attributes. So layer one, Albedo, layer one, metalness is there. We've also got the layer one tiling and the same for everything going down up to layer four. That allows us to bring in these four mega scans of materials that we want. So what I'm going to do is just tear that away and go back to where I can see my content browser. It's just going to make my life just a scotch easier. And I'm just going to pull that over there. Right. What we need to do now, this is where we can tell this landscape blend material which materials we want it to have included. So let's just go back to surfaces. And I'm going to choose the ones I want. So my base material, I think what I want is the probably the layered rock cliff. So what we'll do is here we're going to tick the boxes for those three and we'll just turn the tiling on while we're here. And for some reason, my previews aren't showing up, which is a bit of a pain, but I do know which is which. I say that, I don't know if I do actually. So we've got the rock there. We've got the normal. And then that's the other one there. So I just like to know which is which. So that's how that they have ordered them. OK. So the albedo, the base color is this one. So we select it and then where it says albedo here, I'm just going to click on this little arrow and that loads that in. The normal, I'll do the same with here. And then this one we just use for the roughness, the ARD. So that loads that in. So that's the first one done. Now for my next one, I'm just going to turn on the same ones. You'll notice that I didn't turn on metalness for this one because it's just black anyway. You can see, or we don't even have one here. There is no metalness to this material. So I can leave that turned off. OK, let's just turn on these parameters here. And then we're going to choose which surface we want next. So I think I'm going to go for mossy cliff next. So I know that this one is my albedo. This one, I believe, is the normal. It is. And this one is the ARD or the ORD. Brilliant. And I'll just do that for the remaining two layers now. I'll just, I'll time lapse it for you. OK, and that gets that ready to go. So what I need to do now is just save that material and I can now get it applied to my landscape. So I'm just going to dock this back up here for now. Go back to my level and select my landscape. Now let's just go back up to my content. So it's this material instance landscape that I'm going to need with this selected. We'll scroll down. There's my landscape material. Click on the little arrow to choose what I have selected in here. That. OK, now you'll find that you get something that looks like this where the material is not working at all and that's because we're telling Unreal Engine to throw four different materials at this but it doesn't know how. So it's kind of like taking its hands off of them and we're like, whoa, I don't know what to do. You're going to have to tell me. Which is what we'll do now. So we're going to go into... So from up here, we're going to go to landscape mode. It will probably put you into sculpt mode or manage maybe but you want to be in paint mode over here. And you can see that our four layers are now listed. So what we need to do for each of these layers to get them working is just click on the plus button to create layer info and we're going to choose weight blended layer brackets normal. So we'll do that. And then I'd like to put it just into the default location so we'll save there. And then you'll see it has a little think about it and when it's done, it puts down that first material. Now we need to repeat that for the other three layers. So we'll just go one, two and three. Weight blended layer normal. Awesome. Right, now this little red paintbrush thingy here this is how we can paint with each layer. So I already know that up the top of this mountain here I'm going to want some snow. So let's turn on the snow layer and I'm just going to increase the size of my brush with my bracket keys. How strong is my tool strength? Just turn that up a little bit. And then at the top of the mountains let's get some snow going on. Oh yeah. So I'm going to do it quite strong up here like that. That's pretty good. And now for the surrounding area I'm just going to drop this down a little bit and then with a lower tool strength I can just paint the surrounding area so that it hits a little bit less and then we're going to drop it right down just to kind of add a little bit of a dusting and that kind of fades that in. So we already know that we've got this rocky material below that and then as it kind of gets closer towards it looks like a pain here doesn't it? We're going to have the rock get a little mossier. So again I'm going to use a lower tool strength this because I do want it to blend and I'm just going to paint in and around this area here and you'll see that that does start to show through. We'll get some of that going on along here as well. And we're just blending and we're blending. This is beautiful. So obviously I'm not doing my whole landscape here because it would take me all day but I'm doing enough. And then finally I'm going to use this step material because it just looks a bit greener and we're going to put that in a little bit closer. Just increase the tool strength a little bit. That's definitely done something like that. I'm just going to add some over here and maybe we'll use this one again just no lower tool strength I think just to break that up a little bit. So I'll add the odd click there. Okay so that is blending the materials but I do just want to show you one more thing because that doesn't look the best. And what I'm going to do is just go back into this oh hello into the material instance settings and I want to show you that by default they tile too much and it looks a bit crap. So we're going to go for this closest one to us here which we can see is layer 3 and we're going to set the tiling to 0.1 and you can see that that instantly looks better. We're going to do the same for this one set that to 0.1 and that looks good but as they kind of get further away they start to look too tiled again so I'm just going to actually set this one to 0.03 let's make it much lower. You can see that now looks pretty nice and for the snow because that's really far away I'm going to set that to 0.01 and you won't see that change much because it's quite far away and it also shows me now that I could do a little bit more here so let's get some of this guy and just because I think I've got too much snow there oh yeah that looks grand there we go so I now will save that close it I will save everything else save all and that my little friend is how you create a landscape layer blend material using Megascans materials so thanks for coming to class hit that subscribe button to become a part of GameDev Academy and ring the bell to make sure you're not late for future classes I believe that quality education should be available to everybody and for that reason all of the classes here at GameDev Academy are completely free and we're supported by our very generous school governors over at Patreon if you'd like to become a GameDev Academy governor and support our work as well as helping us steer the channel in the right direction then use the link in the description to be taken to our Patreon page okay that's everything class dismissed now get out there and make something amazing