#3 How to Create Water in Unreal Engine 4 | Unreal Engine 4 for Beginners Tutorial Bonus Step

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there beautiful people so in what is going to be this final step of the bonus steps we're going to put together a watt shader and we're going to create a little lake so you can see the outcome on screen in front of you and the way that I've built this so this is the shader and this is the material that I put together to be able to get that so what we'll be doing in this video is rebuilding this talking about what the different things do and then we'll build this little lake and we'll just show you how the lake looks when you have a kind of run around it so you can see that the the water looks kind of like it's got all the ripples on it's a nice calm Lake it's doing its thing but I've also got a post-processing volume sitting just underneath it as well so that when we jump in the water it kind of makes it go all blue in a bit dark and a bit blurry so if we kind of jump in and out drag them so if we jump in and out you'll be able to see that kind of turning on enough as well so we're gonna set about creating that in this video it's gonna be a fairly long one there's a lot to get through so I'm not going to explain absolutely everything I just want to kind of rattle through it as it is a bonus step so stick with it and if you do have any questions drop them below and I'll answer them if I can okay so the first thing I want to do is just create somewhere for this lake to be so I've already got one just here as you can see so I'm gonna put another lake and just over here somewhere see you can choose wherever you want to put yours so in order to do that I need to be back in my landscape editing mode I'm gonna use my sculpt tool yeah I've got a nice big brush let's just find where I want it to be and I'm gonna hold shift on my keyboard just to make sure that I'm pulling that down like that so there we go this is really gonna anger my light Maps okay and I just want to have a look at how deep that is make sure have not overdone it that's pretty good nice and dark in there yeah that'll do it so I'm not too concerned with the shape because this is just to demonstrate and if I was doing this in a real project I'd take a lot of the grass out as well and probably change you the light under watery weeds and stuff like that but for what I want now I just created myself a little air before the lake and I can now get on to filling that with some water so the next thing we need is the the mesh that we're going to apply the water shader to and there is one included let's just go back into place mode and if I search here for plain this shape plane is literally just a polygon square so I'm going to drop this into the scene into the level rather and you can see it's pretty small and it needs to be bigger so let me just scale this bad boy up wrong way yeah that's it so I want this to fill the area where my water's gonna be and then I'm just gonna move into place so you should be able to see how I'm doing this okay and then I just want to get the height of it right as well so I think something like that so that's my mesh that's in place there are no collisions on it because I want to be able to go under the water so if I just hit play again I'm running to this I should be able to just get under it and no I can't I need to turn collisions off so let's do that okay so the way that we're gonna turn collisions off on this is just click on the mesh itself we're gonna scroll down in the details panel and we're looking for this collision area and the collision presets at the moment is set to default and I'm gonna set that to nil collision and then I'll just give that a little test to make sure that I can run beneath it wonderful okay so that is now ready for our shader which we'll start building now okay so the first thing I'll do is go into my materials folder I'm gonna right-click create a new material I'm gonna call this M underscore Lake water seems as good a name as any I'll get that bad boy open there it is just swap these around and this is what we have to begin with and we're going to need to make some changes to it because as you can see one of the things that we'll need for water is refraction which is not available to us so let's make sure that all the things that we need for water are turned on straight away so the first changes we'll make is we've got this material domain at surface we're going to keep that as it is but the blend mode is set to opaque which means it can't be translucent and water is of course translucent so we're going to change that to the translucent option and you'll see at that point refraction becomes available but there's some others that we'll need such as the metallic specular that are still unavailable so we also need to make those available so to do that we're going to scroll down a little bit further to this translucency section I'm going to turn on this screen space reflections and this lighting mode which is currently set to this I'm going to change to surface translucency volume and you'll see most of these are now available to us so that we can plug in all the imports that we meet ok so I want to set this material up so that I can edit it within the actual editor so I love these will be parameters that I can use in an instance so I'm going to start with the opacity and I'm just going to put a scalar into this like so scalar parameter I'm going to set this off so I'm going to call it opacity and we're gonna have a default value are 0.5 the minimum will be zero and the maximum will be one okay so it's either going to be fully opaque or fully transparent and I'm going to start it somewhere in between and then I'll tweak it to my needs once it's actually on the mesh so that's the opacity taken care of the next thing I like to do because it's a nice easy one it's the same for roughness so I'm going to put another scalar into here lovely and I'm gonna set this up in the same way so I'm gonna call it roughness and I'm going to start the default at 0.2 not very rough at all and the minimum is going to be zero and the max is going to be one happy with that so that's two parameters set up so far so good well done Shane now I'm gonna repeat this for the specular and the metallic as well now normally I wouldn't use metallic on any material that wasn't actually metallic but it can give a really nice sort of reflection to the water that really helps so let's get a scanner into the spec and I might choose not to use this but I still want it there oh that's a letter well now it's gonna drive me crazy there we go and we'll start at zero and one of a max I'm gonna leave actually because I might want to go higher so we'll go for that one and I'm you could also change the specular for a vector parameter as well which gives you colors that you could mess with okay so let's go into metallic and generally your metallic would just be zero or one it's either metallic or it's not but I quite like an in-between value on the water nope not scaler metallic there we go it's gonna start a value of 0.5 I'll change if I want to and the max is gonna be 1 okay so that's pretty much all the easy inputs sorted now I'll move on to the stuff that's a little bit more complex so most of the rippling effects that you get on the water is is handled by your normal map so that's going to be making it look that even though it's a flat plane little pudding on like it's got these ripples going up and they're going to go into the normal channel and I'm gonna blend together two of the same normal map that are going in different directions to make it look a little bit like water so to do that I need to texture sample nodes so I'm just gonna hold T and left-click to get those okay I'm just gonna put the normal stuff over here for now okay and I want both of these texture samples to have the same normal map applied so I'm gonna select this and I'm going to choose water and I'm going to use the one that's included in the engine you can find your own online so I also experimented with another one here lake water and so you can find any water normal map to get different results or you can make your own I'm just going to use the one that's built in the engine which is T underscore water underscore n so I'll select it there and they'll also select it here now what I will need to do is get these to blend together and I'm going to do that with a lip node which is a linear interpolate node so linear interpolate there it is you see that shows up as a lip and what I'm gonna do is put one of these into a one of these into B and the result is going to go into the normal of my main material node because they've loaded in sync see what they're doing what I need to do is get them moving and I'm gonna use a pan a node so like in the video where we made the the window flicker we use the panel node there it's the same node we're gonna use it for a slightly different purpose so we need a panel going into each so I put a panel in here and that's going to go into the UVs and another panner just here and that's gonna go into the UVs there I'm gonna use that to get these textures moving okay so we need to set some some parameters up on this so I'm gonna go for a very small value here so 0.008 is one that I know I like for this and I'm gonna go 0.016 on the speed y-direction and that will just make that texture move quite slow and on this one I want it to move in the other direction so that's gonna be - at the beginning and I'm going to do a 0.03 and on this one I'm going to do zero sorry - zero point zero seven okay and I'm gonna give this a chance to catch up so you can see that preview here and show you that they're moving okay so that's caught up you can see it more on this one which is moving faster but you can see that that's now moving across this one's moving slower but in the other direction so that's now going to be blended together will give us a ripoli look what we also want to do though is control how these are tiling to make sure they look the way we want them to look so we're going to put a few more nodes on this side to get all that happening so the first thing we'll need is a couple of texture coordinate' notes so text yeah coordinate nodes okay and we'll put a copy of that one in and what these control is how many times your your textures are tiled so this one here I'm going to leave it one and for now I'm going to change this in a second but for now I'm going to put it into coordinate and this one I want to be slightly bigger so I'm gonna change these to 0.5 and a 0.5 and that means that your tile half as much as the other one so I'll pop that into the corner as well and then when these finish loading up you'll see the differences in size which will add to the random look of the water we're trying to create so they've loaded in now and you can see that it's the same normal map we're using but the size looks very different so that's going to give us a nice different look okay so there's one more thing that I want to put into this before we call it done and that is making sure that we can control the tiling of the water so it'll be end up looking like the size of the ripples really and I want to control that from the material instance as well so we're going to need another parameter which we'll call tiling and we're going to need to use that to control these so I'm just going to put that here it's going to be another scalar and I'm gonna call it tiling okay so the default value is going to be one on this and there's gonna be no min and Max because I might want to just go crazy with these and then what I'll do to get this to work is I need two multipliers one there and one there I just need to make a little bit more space for this what we'll do is this tiling parameters going to go into B of both of these the original value is going to go into a and then the output is going to go into co-ordinate and what that means is that using this parameter here we can now control that the values are in here we're going to use that and multiply so that's pretty much done so what I'll do just so that I don't get lost is I'll select all that and I'll comment it I'm just gonna call this oh yeah normal and I'll also put in there plus tiling just so I don't forget so that's that bit done that beautiful what we'll do next is we're going to put a value into this refraction so what I would like it to do so at the moment we're looking at this value here and we can see straight through it now with water it refract when you look through it and it kind of makes what you see through the water sort of wobble around and we want to get the same effect so we're going to put something into refraction so that will happen on our shader and for that we're just gonna use another scalar use a lot of scalars today okay we're going to pop that into refraction like so and we are going to call it refraction and straight away without having to do anything else you can see that when we look through this shader now it is refracting the background behind it so that's beautiful so I'm gonna leave all these values alone for now and I can change them on the material instance later but that's the refraction setup so I'll just pop that over there and so now the last thing that we really need to worry about is the color and again we're gonna use a parameter for this or multiple parameters but one thing that's really important here is that we use what's called a free now node and what free Nelly's is it's that it simulates the phenomenon where if you're standing in watching you look down at your feet you can pretty much see through the water but if you look out towards the horizon let's say standing in the sea the water stops being Sifu and you can't you all you can see is what's been reflected on the surface and your you're free now will allow that to happen as well so we'll set the open that's all going to go into base color so the first thing we need is a vector per amp that says vector dot spelly right O'Shay me okay there's your vector per m by default I want this to be white otherwise it's gonna make it look all crazy and I think I've done it wrong so click on OK there and what I want to do is push this through another lip node so alert like so where is look there it is okay now at this point I'm copying the way that I saw someone else do it so I'm putting this in to be the reason point into base because that's what the other person did I can't tell you anything other than that okay and then what I'm gonna do is just put the result into base color and then the finale's going to feed the alpha and it's the Alpha that that lurks between the color so let's set up that alpha so the first thing that's going to go in is this for an L node which is spelt Fresnel there it is it's the utility that's good to know and the result of the for now is going to go into the Alpha and then we're going to put some parameters into the impulse so these are going to be just two scalars again so it's Gala and we'll just copy that and put another one into these okay so we're just gonna call this first one exponent in exponent in and the other one is gonna be called base reflect okay and then we can change those in the material instance at will to get the result that we're looking for okay so now what I'll do is just quickly change or just tweak a couple of these parameters just to get into something I'm happier with so I want the metallic to be set to one which it is I also want the roughness I'm just gonna bring that now slightly to 0.1 and the opacity I actually want to take all the way up to one and then we'll wait for this to come out and that should give us a pretty nice watery look okay so that's now finished doing that and you can see that actually looks pretty nice so the stuff that's been reflected behind it looks kind of watery I like it so let's save this and then we'll put it onto the mesh in a sec after we've created our material instance okay so we're going to go back into the main level editor here we are and there's the hello there's the lake water that I've created so on the right click on that and create material instance I'm just going to leave the name at the default here it is and I'm gonna open that up in fact know before I do anything with it I'm going to add it to there so that's selected and I'm gonna go to there you go so it's got the basic wall material in it for now I'm gonna swap that with the what share that we've created and you can see straight away there are problems with it it does not look quite right let's just frame that up so that we can get a good look at it so yeah they're definitely things about it that I don't like but some things that are doing you see actually when it catches the light it looks pretty nice so we need to do some tweaking let's open up the instance here it is I'm just gonna tear that away so that I can see what I'm doing as well right so the the main thing that I need to change is the tiling so the ripples are far too big so I'm just gonna knock that up to ten to get me started oh I might leave it and that was pretty nice maybe twelve oh it looks good doesn't it right so we've got that one set up now I need to have a plate with a few other things so we've got our color and we can mess around with this so let's have a lot of do I want to add a bit of blue to it I might do a bit of bluey green yeah that's pretty nice let's go back a bit more into the green spectrum bit-bit pond watery then isn't it I don't have it it'd be too strong so got a bit of color in there I also need to play with this base reflection and this exponent in to get the free nail effect and you'll see that happening more in the preview here then on the water but you'll get the idea so let's turn them both on and then we'll change the values so on the base reflect I actually like to go about minus 0.5 to get me started on this and the exponent in I'm gonna go to about 1.2 and then you can see that you get this kind of haloed effect which is what I'm going for I'm gonna have a little play with the metallic and you see that's having an effect on this as well so I'm gonna bring this down a touch maybe it's just something like a 0.2 ish pretty good the opacity I'm gonna have a little play with that so I want it to be fairly strong and you can see here it's giving that really good for Intel effect so it'd be it's more see-through in the middle now we're looking straight on but when it kind of goes at an angle it gets less see-through which is good that's what you want so I'm gonna go for something like 0.85 pretty good the refraction is how much this wobbles the things below the surface of the water so if we have a look down you can see that beneath the water things are all Wibbly which is good and we can change how much that happens so if we op the refraction you can see that that that refract pretty cool so I don't want to overdo this something like that should be nice okay and I can now see I'm sure you saw this earlier in the video but instead of calling this one speck I called it scaler what a mug so I'll change that in a sec but for now let's see if I want to change this at all yeah I'll try it about zero point that makes it a little bit brighter when the light hits it doesn't it nice so I don't really want it to show up as black when that happens so that it's pretty nice and you can see that it's changing its values depending on what angle we're looking at it okay so let's go back into the main material make some changes oh I want to save this oh I'm gonna go to my lake water I'll just move that out of my way for a minute right that's called scalar that will not do specular okay I also want to comment this as Fresnel free now not Fresnel but it's Fresnel on tip okay and this one I'm just gonna name color cuz I didn't name that okay I'm gonna save that and we'll call that material dot so what you could do now we spend hours playing with all the different properties of it to get it looking the way that you want but I'm fairly happy with it on my lake as it is and just want to make some changes to what happens when you get in the water next okay that took a little bit of saving but it's finished now so let's go back out into our level and see if we like it so I'm pretty happy with it let me just hit the play ball so if we get closer to it and I need to have a look at what the Fornells doing might feel about down to zero it's kind of bit strange what the refractions doing not for now refraction so sir back to zero zero point one okay I'm just got my opacity a little bit as well right so that will do for now one other thing that's looking a bit strange is when we lock up like that the reflections are pretty good but when we lock down we're losing us because we're doing screen space reflections and I want to pair this with reflection capture as well so I'll just close this for now and we're gonna look in here for reflection capture and we'll do a box reflection I think you see as soon as I place that over the water looks a lot nicer because it's now using precomputed reflections and when I look up and down I get a much more result there is a point where it swaps between the reflection capture and screen-space reflections which is a little bit noticeable but it doesn't look as bad as it did before so now if we have a little run towards this water you can see that that's not bad at all and when we lock down we can see through it that when we look further out we can so everything is looking pretty good so far but we've got two problems with the under the water first of all the shades one-sided which means that when we look up nothing happens and everything underneath the water just looks the same so what we'll do first of all is get this water to be not one-sided so in order to do that I'm just going to be quite lazy okay so I need to select the plane which I can't do by clicking on it apparently so I'll do that and I'm going to copy and paste it or duplicate it so there you go I just copied and paste of ctrl-c and ctrl-v to get playing for and what I'm going to do is the scale on the z-axis which in unreal engine is the up and down axis I'm going to set to minus and what that should do is invert it so if I just now look up you can see it's having the effect it's not quite working as I had hoped but it is working so let's just move it down a touch and we'll try that again yeah that looks okay I might need to just adjust the parameters in the instance a little bit more to get it to look good for underneath as well I'll create a separate shader for it but that looks okay so the next thing I want to do is get another post-processing volume in this level and it's going to create the sort of underwater look that I want so we'll get a post-process volume maybe these and we're gonna drop it just on top of the water for now and we're gonna get a better view of this there we go and we're just gonna put it roughly in the middle and we're gonna scale it up so let's scale it in this direction first and then we'll scale it in this direction too so it's covering it in both directions and I'm gonna add just a little bit of height to it to make sure that I will always be contained when I'm within it and then I want to drop it to about there and then I'm gonna try and put my camera just that kind of where the water is just above me about there to make sure that I can see what I want to see something like that right so now with that post-process volume selected we've got everything here that we want but what I need to make sure happens is that whenever we're in this post process volume it shows us the post-processing from it and not the unbound one that's doing the rest of the level and in order to do that if I can find it I think I've got things expander that I didn't need an expander where is it there it is this priority section so whichever post-process volume has the highest priority when they're overlapping will be the one it shows so my other one set to zero so I'm just going to set this one to one and now this will be the one that is most important when I'm in both and I'm also going to drop the blend radius to five and then it won't it won't blend it'll just kind of happen instantly when we when we enter or instantly enough okay so now what I want to do is pretty much just set a collar on this that's the main thing I want to do okay so to get the sort of bluey Cole that makes us feel that we're in water with the post process for selected I'm gonna go to global there's this scene color tint that I can do I'm gonna first of all turn it on and then click on the color picker here and you can see that as I move around with this it started to tint the scene so I want it to be quite a deep blue like that and there may be quite dark as well so something like that straightaway what I also want to do is add something which is like a an image effect so I'm going to do this chromatic aberration and what that does it just kind of blurs things out a little bit by that what should look kind of nice okay so now I need to do is get this a change at the right time so you can see the post process at the moments too high so I wanted to change about there so I need to move it so let's move it down okay move it down a little bit more okay well try that yeah that's pretty close so you can see now it's changing now pretty much when I dip below the water so let's see what that looks like as we run towards it there's my water it looks so pretty nice enough to swimming got reflections it's all wobbly and when I go below it it goes a bit blue and at this stage if you really wanted to make it look cool you could add more effects to make things look wavy some water sound effects or kind of crazy crap to make this feel like water you could also add some physics to slow your play down as well or add some swimming but overall I'm fairly happy with that so I think the only problem I've got is with what this water's doing when I look at it from underneath but I'm pretty sure I can fix that by changing some of these options because when I built this water previously I didn't actually have this issue so I don't think it's a huge one so probably by changing things like the base reflectivity nope or this one nope ah the opacity might do it so yeah I think what I would probably be tempted to do is when I was under the water to have a separate instance where the opacity set all the way up or change the refraction value that's a lot better oh yes it was refraction look at that beautiful so I've got a what I'm at one point to wish for the refraction which at least from underneath looks much nicer so let's just try running into there again yeah so the water looks pretty nice we've got reflections I run in and then I look up and everything looks kind of wobbly so we get any reflections from underneath that was beautiful okay so that brings us to the end of the bonus steps as I said early if you've got any questions about this that we've made here this beautiful water mm-hm then drop them in the comments and I will do my answer them I've also promised that I will be leaving this project alone unless for some reason inspiration strikes I'll be working on new things going forward but maybe you know if I decide that I need to do something in this one I might come back to it I can't completely rule it out but I'm fairly sure I'm done so there are other things coming soon if you've got any requests stick them in the comments if you really want to help me continue making tutorials like these then please consider checking out the patreon campaign you can pledge a little bit a lot you can do it for one month you can do it forever you can not do it all it's completely up to you but it does help me keep doing this and it is very much appreciated if you want to make sure that you're really really good Unreal Engine 4 in game art in general then check out the link in the description to Pluralsight they have hours and hours and hours of content you can learn so much as I've said before that's where I do most of my learning at the moment and I really enjoy it as a platform if you do sign up for the free trial using that they send me a little bit of money for that happening about 3 quid and if you decide you don't like it after the 10 day trial just cancel it no bother so the last thing for me to do in this video is to thank you very much for watching if you made it to this video it means you probably watch the previous 40 steps plus these three bonus steps which is a hell of an achievement that's like what over five hours worth of unreal engine stuff you're clearly very committed so well done thanks for watching and I sincerely hope I will see you in my next video bye thanks for watching if you really want to take your learning further than I can cover in this series then I highly recommend checking out Pluralsight they have loads of really detailed video courses covering gamer and game development using Unreal Engine 4 when I learned how to use Unreal a couple of years ago this is where I went and I log in regularly to take a new course and improve my skills I recommend checking out the introduction to Unreal Engine 4 course by Joshua Kinning this is really good enough as a good overview of what you can do in unreal you can get a free 10-day trial by using my link in the video description and you get full access to all of their courses for that time at the end of your 10 days you can either subscribe for more or cancel totally you it's gotta be worth a free trial though right I'd like to say a massive thank you to my patrons your support helps me to keep making videos like this one and I really appreciate each and every one of you it really blows my mind that people will support my channel and my work by pledging their money through patreon so again thank you all so so much if you aren't already a patron and you'd like to offer your support then please go to patreon.com/scishow
Info
Channel: Game Dev Academy
Views: 97,518
Rating: undefined out of 5
Keywords: Unreal Engine 4 water Tutorial, UE4 tutorial, beginners, basics, Unreal Engine, Unreal Tutorial, learn, how to make a game, game art, level, unreal for beginners, unreal engine for beginners, unreal, engine, tutorial, unreal engine 4, ue4, create, game development, basic, make a game, landscape, gamedev, video games, UE4, environment, introduction, game engine, game design, Unreal Engine 4 tutorial for beginners, water, material, shader, how to make water, lake, ocean, pond, simple, easy
Id: XyBfsVF6y0Q
Channel Id: undefined
Length: 34min 18sec (2058 seconds)
Published: Tue Aug 28 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.