Landscape Material Tutorial Part 2 - Procedural Puddles (Unreal Engine 4)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone and welcome to the second part of our landscape material tutorial we haven't watched the first part I'm going to add a link to it right here check it out first so in the first part we covered how to create a landscape material and how to add layers to it dirt and mud layers what we add so we can now paint in our different layers and they're going to get hight blended let me quickly remove this again in this tutorial we're going to cover how to add procedural puddles on top of this that automatically conform to whatever slice underneath them so let's get started so this is what we created last time and you can add how many layers you want to this just be careful the more layers you add in the more layers you use per tile the higher the performance cost gets so be careful with that don't add more layers than you actually need and now what we're going to do is we're going to add right here a material function it's going to allow us to add or to paint puddles on top of this so to get started with that we're going to add a new material layer and suit up by going to materials and textures but your function let's call it puddles material layer and I call it tutorial let's open that up so we covered material functions in the last tutorial so check back there if you're not sure what this is for now let's get some textures in here so let's get put to our textures and take one of the textures from our material layers that we're using on the landscape in my case I'm going to use the mud let's just drag and drop them into our new material function I'm adding these so that I can actually see what I'm doing because these puddles are going to be procedural and if you don't have any input textures it's just going to display of that surface it doesn't really help right so we're not going to add any textures in this material function but we are going to use these textures to drive our puddles so basically the textures that we already use for our landscape material and to get started with this we're going to use our height map value which we haven't used before and we're going to use an if node so let me just quickly set this up and I explain what's going on afterwards need three more constants going to set this one to one we're going to plug it into the air spigot and equal to B and a is equal to B and the zero one we're going to plug into a smaller than B and this zero constant we're going to plug into the B now let's give me a let's let me give you a breakdown of what's going on here let's preview this if not so that we can actually see what's going on at the moment it's just pure white so we haven't if you haven't used this note before what it does is it looks at the a and B value and then if a is bigger or equal to B it uses a no sorry it it uses whatever is plugged in here if a is equal to B it uses whatever is plugged in here and if a is smaller than B it use whatever is plugged in here so basically it has these two inputs that it compares and then selects whatever is put into one of these three so at the moment we have our let me preview this really quick for you so that you can actually see what's going on so this is our height map and our height map has of course white and black values the whites are where our texture is going to get pushed out and black is where it's going to get pushed in and we can use that to determine where our puddles should be right because they should be somewhere in between these two so if you change this value right here our result should change so let's still just on if you input a more reasonable value than zero like 0.25 there we go now we have a nice selection for our puddles and since we've used this if node you can basically lerp between the sizes of the puddles with this node so if I put in something like 0.5 apple else get way bigger at 1 they should cover the whole area it's zero nothing by the way the way we're doing this at the moment the black areas are all puddles so we actually don't need us just was just to show you what I mean it's the interesting part and let's convert this one to a parameter call it the puddles sighs if you don't need to be premiere parameters they're just 1 and 0 values so that we get a nice selection between white and black let's actually use this mask that we created to add our partisan and to do that let's start with our normal map because it's the most obvious one so just use a LARP and let's use our our a normal map as to be slot for the a slot let's create a free vector by pressing and holding down free on the keyboard and then clicking on the canvas and let's give it a a a value for the normal map of our paddle and since it's just a puddle it should be flat so let's give it a flat value if you have worked with normal maps before a flat value is basically just a a 0.53 point 5 and 1 for the RGB channels so in Photoshop would be something like under 2828 and 255 it's just a RGB value for a neutral blue I guess let's plug that into our way let's preview this the moment it's at 0.5 so what we're doing right now basically is reducing the impact of our normal map actually let me preview this for you so this would normally map usually it looks like and now we're going to use this if and plug it into L into the alpha there we go nice selection of the normal map of our terrain and the puddles with a neutral blue so let's create a make mature attributes node and let's pluck the normal right in there if we start probing this so we can see how the normal maps already working of course we have nothing else plugged in area so what's something I like to do I like to go a little bit further with this so taking this again we're going to add a little bit more to it because what I find is that around the edge of these puddles you kinda these sticks and twigs and whatever is lying on the ground doesn't just stop right at the puddle right with you if you have real puddles you kinda get the height information around the edge where the water is just hitting the shore so I like to shift this normal map by a pixel o2 so that we get the normal map information right around the corner of puddle and that's really easy to do actually so we're gonna we're just gonna take our puddle size we're going to subtract from them we're going to subtract by a another constant convert is a parameter and call it the normative and this is going to be a really really small value something like maybe point zero two so we're taking our pal size we're subtracting it by this value we're just gonna do the same thing we did here so let's copy the if and the one and zeros place this new value into OB and a height map information into da if you preview this and if you take a look at a relative story out you see but it shifts it inwards just just a bit just by the value that's our normal shift because we're subtracting that right so the value for our policies changes basically oh let's use this as our alpha so what this is going to do is going to just shift in the edge for the normal map selection just a bit but that's still not what we want because we can't really see it at the moment but since I've created this before what this does is it looks as if the puddles just ending further in and gives a really strange effect on the landscape material so instead instead of just using our a complete normal map we'll be actually going to do something different we're gonna take our normal right in we're going to multiply what we're going to do is we're going to reduce reprove it up reduce the strength of the normal map and use that rind around the tower line so let's create a three vector multiply that one and if you would know that before the way you can adjust the strength of the novel map right inside unreal is by basically creating a node just like this one so one for the blue Channel point five for the other ones so at the moment nothing much is changing but if you reduce these values you can see how it gets more more blueish there's no if it's much impact and the Madam's take you there we go that looks more like it so now that we have this and if you actually sue this a different way because if you want to have control over how strong this is the way to do it is to create a console let's put in something like the point one that we want for our strength and let's build this app to be a free vector so a pendant by itself so this is our R and our wrapped in green channel now let's append this again so the append node basically just adds a another vector to it it's great a constant plug it in and just say one because this is our blue channel so now what we have is the same thing we created before with the r and g being zero point one and the B channel being one let's plug this into the multiplier we get the same result and we can create this a converges to a parameter call it I look normal intensity so the system's gonna end up the normal intensity for our normal shift now what we want to do is slope this and you want to learn between this new value and of course our old default normal map and of course we need an alpha for this so let's move this over actually let's let's do a little bit of clean up first so these are on inputs this is our part of selection or our puddle size so let's call it sides and all of this is going to be our normal so let's move this over so at the moment we have a really nice selection for this really nice selection for where our a normal map should be for the puddle and for the for the landscape material and now we want to get this this little in-between area between this and this value so what we're going to do is we're gonna invert this one with a 1 minus node so now we have it inverted and then we're just going to add it to this one so we take our or puddle mask and add the inverted normal shift mask and this gives us this few pixels that are where our normal shift should be then we can use this as a mask you're going to plug that into our B value now what you get is we get our models separate and then just around the edge for a few more pixels we get the same normal map we have on our landscape that's a nice nice area to see it just with reduced intensity okay so that's it for the normal map so let's clean it up a little XY more complicated than this doesn't it's commenters so did we know what's going on here and let's move on to next part because now that we have to know map let's go ahead and build our color for look for color what I like to do so the snow map has a really harsh edge and we color on puddles works stay usually they don't have a color right they only have collected dirty or really deep and well I guess that's when it does start showing up and doesn't have a hard edge like that so what we're going to do is we're going to once again take our height map multiplier let me prove it and let's multiply it by a concern let's say a constant value of five should work fine on this okay and what we're going to do after multiplying it we're actually going to increase the power another constant put in something like two and what this is it basically multiplies it by itself making the blacks blacker and whites even whiter and this isn't between in a 1 to 0 range anymore so this is a really messed up value at the moment but that's just fine so let's name these parameters because we want to change them later on so this one is going to be our death because this value is gonna basically define how deep or puddlers and the power is going to be our opacity your setup of zero no matter what depth this is always going to end up with no color at all and if if the opacity is higher it's going to end up si as a complete color patch even if the depth is really shallow so let's take this and clamp it we don't so usually you use or in most cases use a clamp to clamp between 1 and 0 which is usually fine but what we want to do is we want to take for our minimum value the our puddle mask so what we created before let's put it in draw minimum and this is going to make sure that our that did we don't color our terrain that we only color the puddle no matter what we put in here so even if I put na a depth of 1 which means the whole area should be colored it's it's so not influencing the terrain around because that wouldn't get colors ever right so that's what we're doing right here and then let's use that to LARP between a let me put it in here LARP so this is our alpha and the B value let's just put in our regular Lin scape color can actually see at the moment it's just a black value so let's create a free vector up there in here and let's change that to a crazy color sir and can show you what's going on there we go so now we have the color for our puddles you can see how it's where it's deeper it's darker and to the edge will get softer that's what you want and that's what we can control with death and depth of Pasadena let's change that to a with like color like this maybe yeah guess it's fine maybe make it a little bit darker and actually let's convert this to a parameter let's call it color and actually I guess this is the depth color just so did I that we can remember what's going on here and with this we already done with the color you can just black this intro make material attributes now if we preview this this should actually already start and make some sense there we go so we have puddles we have two normal map cut off and we get some nice color in there let's move this up commented so to select our color and now let's also adjust roughness the specular because we also need those to make some some nice puddles we're going to create another loop I'm depending on the size of our model use it as an alpha and for our or B we're just going to use the roughness of our landscape its prevalence so it's kinda hard to see I guess because this landscape is very rough of course but we can see it in the white areas and for our puddles we're just gonna create a constant and what I like to use for the roughness of the puddles is something like 0.05 so it isn't completely black but it's very close to plane completely plan let's put that into our roughness regular and there we go this is already looking like puddles run now we're not done yet because s with the normal map shifting I like to have the wetness shift on the edge of the actual landscape so basically the inverse thing we did for a normal for a normal map we shifted it inwards of the partner just a little bit and now I want to do the same thing for the wetness just in the other direction so that landscapes looking wet and to do that we are also oh and we forgot to change our specular so let's do that real quick that's really easy it's basically just the same thing we did for the roughness side alert so our alpha so once again our puddle size mask for the alpha hour and here I guess it's a little bit cheating and I'm not using any specular values in this we have a constant so we would take the specular from our material that we get in here so let's add a make material attribute for now or a actually let's and let's let's break it just so that we have something as a preview and let's take our specular as our B value and I know one value we're just gonna and actually let's add in a value for our speculates usually 0.5 so this is just so that we get a preview and it's something like what we're going to end up with and for our puddles we want a really high specular because this is water so something X 0.75 I guess and these values are not physical based by the way I haven't scammed this I just looked at some tables if you want to take a look at what real world values for these are I'm going to link a a blog post right here it's not ours but it's really good it goes through and depth about water and it's its influence on wet surfaces so take a look at that if you actually want to know how these values should be in a I guess reword physics based scenario I just I bought these so let's plug this into our speculum and there we go now we have some really nice paddles right so let's do what I already promised let's shift this wetness into the landscape so to do this we're actually going to change a little bit here because what we want to use is the mask we have up here so up here we have the mask for our color and let's use that tool herb and let's use this a and s this at ta s da and for the B you want zero and we're going to create a constant look that into our alpha let's give it a value of and say what's up it's prevalence so what this does is it slurping between this mask and a value of zero depending on this scalloped parameter and let's call this our wetness shift because for the wetness shift once again I don't want a I don't want a pixel perfect selection because that's going to look really strange on the wetness this is why I use this value up here let's clamp this and we're basically going to do the same thing we did for the color where we kind of prevented the landscape from being influenced just the other way around so into the max you're going to put our our puddle selection a puddle mask this is going to make sure that we don't change anything on the roughness of our puddles because they should always be perfectly rough right and now we can see here how we get around the puddles this darker area and that's exactly what we want because this darker area is going to be the area that's kind of wetter now to control this effect what we're going to do is we're going to add another power node let me move this over a little bit more and now as you can see if we if you double the power this area gets even darker so it's going to end up even wetter so let's create a scalar parameter let's call this wetness and I guess a value of 0.5 is fine so we're actually reducing how wet it is now and that's also really nice because now we can also completely remove this effect if we want to now for roughness which is this value right here let's just use the clamp value over here without the power that's a new alpha because the roughness is way more hard to notice so that should be fine but for it is specular you want that additional control so let's use that one reprieve ulis we're going to end up with something like this where we have our our specular for the puddles now a specular for the landscape and then around the edge we're going to increase this value so that's what we want but I'm not sure if it's necessary so just for good measure I like to add another clamp node right here I just clamp this value between 1 and 0 put into the specular the same for the roughness this might not even be necessary because I'm not sure if the load node is actually going to output values between editar higher than 1 now we're sure they're always between 1 and 0 so let's pray with us and also there we go so as you can see we have noticed it's really really cool it's nice wetness around the edge of our puddles and even in some areas where the puddle didn't reach I think that's really cool we're almost done with our puddles let's add some comments so this or specular down here all of this or roughness and yeah so now what we got to do is change so that we can actually apply it to our landscape material right so let's do that actually let's apply and save this because we haven't saved yet and we don't want to lose everything we've done so to make this work with our landscape material you have to change a few things and one of them is adding inputs so let's do it add an input function input and this time we're going to set the input type to a material attribute because we're going to feed our whole landscape material into here and so that it but it doesn't complain let's just add something like this in here now we can break this and take our values from here so we have our spec you know we also have our color and we have our normal map and let's rip increase our input so it covers all of these and this is going to start getting really messed up our preview right here because it's now it doesn't have any values that you can use so we don't need these anymore but if you want to change something or check something rewire this to these so that you can actually see what's going on and we have our roughness versus roughness there's the roughness and far height if you remembered we're actually doing our height in a different way so we have these extra height outputs and we're gonna have another input for that so let's get an input let's call it height and this is going to be a scalar input let's put these over here let's get rid of this one you'll need it anymore and let's put in a preview value so it doesn't complain move this over here and rewire its height so these are now obsolete I'm just going to leave the name in case I need to check something and now we can see that our privates it's basically just the perfect puddle because doesn't have any values whatsoever so the other the next thing we need to change is we actually need to make this a output wrestle and we need another output result for our Heitmann so that's another adds let's add another function output call it type and to actually have height value there are a few steps we still need to take into our landscape mature so let's save those let's go into a landscape material and since we don't use the material attributes for our height map I kinda need to learn these by hand and that's actually really easy we just take the side output orbit it's going to be our B Oh a is just basically the value for everything that's not covered by any of these material layers which should never be the case anyway but so you can just leave it at zero point put it at point five or whatever doesn't really matter now how do we mask this and for that we have a a note in unreal which is the landscape player sample so here we can put in the name of our material layer and in this case it's third so this is if we take a look at our own our landscape material we have these target layers right dirt and mud so these are the names you're looking for because the information we paint in here you can actually sample that in our material that's what we're doing right here so the dirt height is only apply it where dirt is painted in and then we do the same for the height of our mud add another sample note landscape layer simple let's call it mud so now it's going to what Evers gets output here or the matte layer depending on the alpha of that layer we painted and just do that for all the layers that you have just add them this is everything that I have so let's comment this and call it in right plant or is more like the height mask run smooth this up a bit so it stays clean and this is what we're going to put into our input on the puddles which is too high because it's the blended value between the eyes of all these material layers so what we can do is you can loop the height did you get here and we're going to learn it with the alpha of the Selective of the the mask of our pond and so what we get form our material and landscape material it's actually going to be the B value and in the au value we're just going to put our puddle size the reason we do this is our puddle size this is basically a a gray color right and it's the gray color that we use to select the starting point of our puddle selection reefs or a cannery previewed anymore because we already moved on from these textures but this is the perfect center of our puddle so this is also where we want our height of the puddle to be that's why we use it as our a value and that gives us a a perfect and perfect height for our puddle so this is going to be the output I hide my let's move this down a bit space organized call this something like right and let's call these our outputs save it and now we are only missing a few things some of them being we need to convert these into at the moment their parameters which is cool but we need inputs of course because this is going to end up as a material layer so let's create more inputs this one is the puddle sighs that's 0.05 let's rewire all of that to this one and this actually a scalar parameter let's not forget that and for the other ones I'm just going to copy or place this one so ctrl C to copy it and actually we want to use the preview value as default so that we don't need to wire this if we don't want to now we have more parameters over here if it depth we have a value of 5 further also it's called that roof this and a death the passer T the value of 2 we have the wetness shift the value of 0.7 and the wetness the value of 0.5 you can create inputs for your base specular and roughness value if you want to no I don't want to change them so I just leave them the way they are same for normal intensity and stuff like that I do want one for the normal shift so I rewire this that's all of them it saved us and one more thing that we need to do way this is done at the moment it's just going to apply over all of our materials so we're going to end up having puddles everywhere and of course we don't want that we want to be able to have some control being able to paint them in using our landscape material layers right so you're going to add one more thing which is a input and this input we're just going to call a layer mask and it's a scatter input and for now let's use this with a preview value as default and set it to 1 actually let's salute us here so this we are going to feed later on via another layer simple which we then use to paint in these puddles so what we're going to do change a little bit of them instead of just feeding all of these values into our make material we're going to loop them or starting with our base color let's plug our result until B and our input value over here into a and then just rub that with the Alpha from all a and now we're basically going to do this exact same thing all of them so now the load node we're going to be go Mattel into the a this is why this looks so messy because you no need to do this fall of them I tried this with a material blend before a tutor where is it material a a blend and I I used try to stand it I didn't give to proper wrestled I'm not really sure why because if you look at this it's it's basically doing the exact same thing that we're setting up right now but I didn't look too deep into it so who knows what's going on there I just put my hand actually why we're doing that let's then plug these back into their appropriate slot so do the same for the specular and this all our wrestled always goes into the B while the basic value goes into a don't forget the Alpha go into the specular that's sorta same for the roughness when over map it to be default normal map the a it's all for masks on Britain either for the ambient occlusion because we're not doing anything with that and we also need to do this for a height map down here should let's bring this up because we solar power height map and get a default value from a height map not from our make material of course but from our input and use the layer mask is our alpha put this into our output I guess we might as well put it into a word displacement so there we go now we can comment this so do it we don't forget what's going on here and this is our am mask let's apply this and lo to comply okay so the materials now compiled and you can add it into our and then scape material so let's move this over and find our puddles cheer function in the content browser actually I haven't saved this so make sure you save it before now let's drag and drop it enjoy landscape material now we need some inputs here first our material attributes then our height map remember that we blend our height map down here and then we have a bunch of parameters that we can connect but for now let's leave the way down we can connect wrestled with our output also let's create a and skip layer sample let's call it puddles and connect this to our layer mask let's create a comment for this and apply it once again just going to compile ok compiling this down so let's take a look and this is what the material looks like really look correct but anyway let's go in let's go into selected go into landscape mode paint mode or we can see you so we have this new puddle layer so let's create some layer information further and this is going to be non weight blended because we want to add it on top of the other weight blended layers so I'm going to add this my target layer tutorial for us you can add this where we want and then let's see if we can paint in some puddles so it still needs to compile some shaders so let's wait a second until it's done so let's done compiling shaders and as you can see you can now paint in some puddles which is exactly what we want where oh I'm noticing that our normal information isn't applied anymore going to take a quick look and see what's wrong so the mistake was a pretty obvious one looking at our puddles forgot to connect the rope from our normal map material I mean that's that's one big mistake right here let's applied it and compile and then we should be done with our puddles okay so it's compiled let's save it and oh there we go now we have our normal information back we have our models and this is looking fine so we're just ready let's go back into our landscape material and add our parameters let's create a constant convert it to a parameter and for death peso to devalue is to give it a name and I'm just going to do this for all of them and then get back to the tutorial so I added all of the parameters and now let's group them under part again the values that I have here are just the default values that we set up before it's a plot and save it now we can go under and open up the instance for our material let me drag this over here and to make it more obvious let me change the specular on my mod 0 and it's going to be change on the paddles is going to be more obvious so we have or actually that I forget or add the color of the bottle as I'm an input I totally did so let's do that real quick so let's add another input in here this input we want a 3 vector exactly and let's take the colors we set up here so let's just copy these values go use the private value as default and call it color let's put that in here move this one ply it compile it save it on the drill so while this is still compiling we can already add our free vector in here let's well let's just do this by hand it would be something like that we'll get right in here convert it to a parameter let's call it I will color and let's put it into the palace group supply this and save it okay let's go back to our showcase open up our instance again and there we go we have all our puddles if the color let's change it to something crazy so that we can seed like that and yeah now we can adjust the depth which is going to adjust how much of it is colored let's change the color back to something a little bit more reasonable this might be a bit too bright for my taste you know something like that and can of course change the puddle size make it bigger make it smaller and we can also adjust the wetness and wetness shift make it completely gone kind of a little bit in there add a little bit in there or make it cover everything and of course everything in between so that's it for the puddles I think this is looking pretty cool it saved us and the other thing we want to do now is add some tessellation to this so since this videos been going on for quite a while now I decided to move the tessellation part into a third part in this series so I'm going to make another video covering how to add tessellation to this material so that's it for this video if you like the video please like and subscribe also if you want to see more videos like this and feel free to check out our website let's send again that and yeah I'll see you in the next video bye [Music] you [Music]
Info
Channel: Lukas Kölz
Views: 85,354
Rating: undefined out of 5
Keywords: Unreal Engine, UE4, Tutorial, Gamedev, Landscape, Material, Procedural
Id: nERpEOABJJo
Channel Id: undefined
Length: 54min 30sec (3270 seconds)
Published: Sat Dec 10 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.