Rain Wetness Shader - UE4 Materials 101 - Episode 13

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] for the next six weeks I'm gonna do a series of training videos talking about how to create the effects of rain on surfaces and so this week we're gonna talk about making surfaces look wet next week we're gonna talk about creating raindrops and then we're gonna go on and talk about several other rain effects as well so the first thing that I wanted to do is show this video this is some footage that I took of rain falling at my house and what we're looking at is the effects of rain and the kinds of things that it does so in these videos you can see that rain makes things wet rain has drops that collect on the surfaces of objects rain creates puddles and the puddles have raindrop ripples in them rain slides down the sides of surfaces and rain does all kinds of different things so as I said we're gonna take a look at rain and the effects of rain for the next six weeks on this channel and i'm gonna create several different shaders that recreate these rain events so today we're gonna focus on what it takes to make surfaces look wet so let's jump right into the Unreal material editor and get started alright so here we have a material that ships with unreal it's called M brick clay old and I duplicated it and called it M brick clay old wet in this version of the material we're going to add a couple of couple of features that allow us to make the surface look wet so what makes a surface look wet well there are a couple of different things surfaces that are poor that absorb water get darker so here we have the base color of the surface and the base color of the surface gets darker and more saturated so let's go ahead and do that just to start with so I'm going to right click here and add a deeps desaturation node and if I plug my base color into the desaturation node what you're gonna see is that it just completely desaturates the color and we end up with a color that's grayscale instead of color and actually what we want is the opposite of that we want to saturate it well there's a little trick with this desaturation node and that is if you pass it a negative value for how much D saturation you want it actually saturates instead of desaturating so I'm gonna add a constant here and I'm gonna give it a value of negative 0.5 and then I'm gonna wire that into the fraction that's the amount of desaturation that I'm doing and what you're gonna notice here is instead of the surface being D saturated now it's actually more colorful than it was before and that's what happens to surfaces that get wet they get darker and they get more saturated alright so I'm going to add a just to confuse you I'm gonna add a saturate node here at the end and this meaning of saturate is actually completely different than this meaning this node here clamps our value between 0 and 1 it doesn't make the surface more vibrant or brighter it just clamps our value between 0 & 1 so we're going to clamp our value and then we're gonna add a multiply and this multiply is going to darken this surface and I'm so I'm going to add another constant value of 0.5 so here is my constant of 0.5 and I'll plug that into my multiplied and then I'll plug the result of that back into base color and so what what we're gonna get here is a surface that is darker and more saturated than it was to begin with and so this is what happens to surfaces when they absorb water they get slightly more saturated and they get slightly darker but what about surfaces that are porous when water builds up on the surface of a material it actually gets more smooth and it gets slightly less specular and so we're gonna mimic that effect next so I'm going to I'll just move my root node over here to give myself a little bit more space here is the roughness node that's coming in and what we want to do is I'm gonna add a constant to vector and this node here is going to control my roughness and my specular values for water so these are the roughness and specular values for the water that's pooling up on the surface now water is really smooth and so I'm just going to give it a roughness value of zero point zero seven and I'm going to give it a specular value of zero point three most surfaces have a specular value of zero point five but water is slightly less reflective than most surfaces believe it or not most people think that water is more reflective but in actuality it's just slightly darker less reflective than most surfaces it's just that when you look at water at a glancing angle you see reflection but when you look at it straight on it's like less reflective okay so what we want to do is take our specular value and our roughness value of our original surface and we don't actually don't have a specular value for the original surface which means it's using the default 0.5 and so I'm just going to add a constant here to allow us to use that explicitly specify 0.5 and then for roughness we're going to take this guy here and I'm going to append these two values together using a pen vector and so we're gonna put the roughness value into a and the specular value into B so these are our original values and these are our water values and we want to blend between these two depending on how wet the surface is so I'm gonna add a linear interpolate node and we're gonna blend between our original values and our wet values based on this alpha value and this alpha value is gonna be how wet is the surface I'm gonna do the same thing with base color so I'm going to add another linear interpolate node and we're gonna blend between the original value and the wet value depending on how wet the surface is so here I have two lips that both need a wetness value so let's just create a constant and this is gonna be how wet the surface is I'm just going to make it one for now and then I'm going to pass this in to both of our lips and then this guy can go into base color but this one needs to go into both roughness and specular so I need to add a mask node I'm gonna use a component mask and I'm gonna mask out the X component for our roughness and I'm gonna max mask out the Y component for our specular all right so now let's take a look at what we get with our brick clay old so now you can see that the surface is shiny and more saturated and nice and wet so this value here controls how wet the surface is and if I give it a value of zero and update now you can see that it's dry and if I set my value back to one it'll be wet yeah so there you go so pretty easy to create material that has a wetness control now the problem with this is I just added a whole ton of nodes to my material and if I have to go through and add all of this to every material it's gonna be a lot of work and so the next thing that I want to do now that we've achieved the look of our wetness is I want to show you how to make a material function so I'm gonna put all of these nodes into a single function and then we're gonna use and so that becomes a single node then I just have one node that I can drop into my materials instead of a whole bunch of them it's gonna make it a whole lot easier alright so I'm just gonna go ahead and minimize my material here and come back to my content browser and here in my content browser materials I've created this new node called wetness and you'll notice that there's this light blue line under it instead of a green line and what's what that is indicating is that this is a material function it's not a material it's a material function I can create a new function if I right click here and pick under the materials and textures category if I pick material function now I've already made this one so I'm not gonna do that right now but this is how you create a new function so I'm just gonna go ahead and open up this one and here it is and let me just resize it here so that you can see what's going on so the main difference between a material function and a standard material is that a standard material has a base node over here that everything plugs into and a material function instead of a base node it has outputs and it has inputs so my inputs here are red and my outputs over here are brown so data comes in on the left side and it goes out on the right side so here in my function you can see that we're doing the exact same thing that we did in the shader just a minute ago we have inputs for roughness and also for specular let me just resize this here so you can see the settings over here so I added a new input and I named it roughness I had an another one and a named it specular then we have penned those together and lerp between that and the values for our wetness based on how wet things are and then we split them up just like we did before and then we output the roughness and the specular values for our base color you can see that we have our base color coming in and then we desaturate it with a value of negative 0.5 and then we multiply it by 0.5 to darken it we blend between our original base color and our adjusted wet base color based on how wet things in things are rather now you can see I have a wetness mask coming in this defines what part of the surface is wet and I also have this other factor called porousness so here I can decide is the surface porous or not if a surface is absorbent meaning the water can soak into it then it's going to become more saturated and dark but if it's not then it's just going to become more smooth and slightly less specular so I can define if my surface is absorbent or impermeable porous or not for us all right so this defines a single node a material function and then I can add that to my shader instead of adding all of these nodes I can just add a single node so let's go ahead and do that I'm gonna minimize my function and here it is and then I'm gonna bring up the material that I was working on before and now what I can do is grab this function from my content browser and drag it in and you can see that it shows up as a single node instead of all of this spaghetti now I just have one single node with my inputs and my outputs that make this surface wet pretty cool there's one more thing that I want to show you and that is the order that these inputs and outputs show up in you'll notice that base color specular and roughness are in the same order that they are here on the base base node base color specular and roughness and there's a nice little way that you can define what order these inputs and outputs are in when they're on the the individual node in it so I want to show you that just really quickly before we move on so here I have roughness specular base color they're not in the right order from top to bottom but if I select one you can see there this there's this box over here called sort priority so what I've done is I've gone through these nodes and I've decided what order do I want them to show up in when I add this node into my material so I want base color to be first so I've given it a zero and then I want specular to be next so I've given it a one and then I want roughness to be next so I've given it a two and so on and it works the same way with my outputs I can give them sort priority two one and zero so that they come out in this order and that way I don't have to cross wires when I'm wiring things together if base color and specular and roughness were in a different order the wires would be crossed and that's just not quite as organized okay so now instead of all of this what I can do is wire my base color in to here wire my specular into here wire my roughness into here and then I can take my base color going out here my specular going out here and my roughness going out here now here is my wetness mask and if I wire this wetness mask into there I should end up with the same result so let's take a look all right there's one last thing that we need to do and that is define our porousness I'm just going to go ahead and delete all of this because it's basically just a duplicate of what we've got here in our wetness node so we have we're defining the entire surface as wet and I'm also going to add a constant and define my porousness so with a value of zero for porousness what this means is that this surface is completely impermeable but actually stone is quite porous and it lets things soak in so I'm just gonna change this to a value of one and what you'll see is the surface remains shiny but it now becomes slightly darker and more saturated like we are talking about before yeah so now I've got a nice wet stone wall and I created this function for defining the wetness so I'm able to hide all of the complexity of what it takes to make a surface look wet inside this one single node all right I hope you enjoyed this first video in the series of how to create rain effects next week like I said we're going to talk about doing raindrops and then the following weeks we're going to do additional rain effects as well so this idea of putting material nodes into a single function is something that we're going to use a lot we're going to create a function for the raindrops functions for all of the rest of the rain effects and then why are those functions together to create a single function that does all of our rain it's going to be pretty cool so I hope you stick around be sure to subscribe and ring the notification bells so that you'll know when new videos come out we're gonna try to get a new one out every Thursday alright thanks and see you next time [Music]
Info
Channel: Ben Cloward
Views: 18,687
Rating: undefined out of 5
Keywords: UE4, Unreal, Unreal Engine, shader, material, material editor, game development, real-time, tutorial, training, Unity, graphics, 3d, GPU, tech art, computer graphics, fundamentals, basics, beginning, learning, wet surface, wetness, rain, water
Id: fYGOZYST-oQ
Channel Id: undefined
Length: 18min 45sec (1125 seconds)
Published: Wed Feb 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.