Join Craig Barr for an in-depth discussion in this video Advanced material: Water, part of Unreal Essential Training.
- Creating water environments in Unreal Engine 4 can become quite a complicated process, but utilizing some of the example scenes or example files available within the library we can actually dial in some really nice looking water effects. So, we've seen how we can take a sample effect or a sample blueprint water set up with our sample material and dial that into our needs to build a very simple ocean environment for our landscape here. But, we might want to take this a step further and add in something that has a little bit more of a dynamic impact.
In this lesson here, we're going to take a look at applying advanced materials to create a more advanced water. So, we're going to create something that's more of an ocean environment that has things like sea foam and how we can control that to give it the appearance that's interacting with the shoreline of our scene. So, the first thing that I'm going to do is actually come out of here and remove our previous water example that we've create here. So, I'm just going to hit Edit and Delete that water. And, if we zoom right back out, hit S and right mouse button you'll see that we don't have anything now as far as water goes in our scene.
Well, this is because we're going to come right out of this water plane example that we grab from the Library. We'll go into our Content Project directory and go underneath Models. Now, in here we have this Ocean test node, or Ocean test mesh. If we can just select that and grab that and bring this into the scene file you'll see that we now have something that represents, it's kind of a brownish kind of rust color. We're going to adjust that in a moment, but we do want to adjust the overall scale or size of this here.
Now, before I do that we're going to be working quite a bit with this Ocean test static mesh. So, in the Search Field in the World Outliner simply type in Ocean, and what that's going to do is just isolate that for us. It's going to be very simple for us just to come back and grab that so we don't lose it in the Outliner. Now that we've done that let's zero out the location and we'll find that with that we have our water maybe a little bit too deep so we definitely we want to adjust that maybe down to a depth of around this. Something around maybe minus 445 should work just fine.
Now, the next thing we want to do is we want to scale up the overall water effect. We're going to scale this up to around a eight by eight by eight water effect because in dialing this in previously I found that this actually produces a pretty decent overall look for the sea foam that we want to work with. Right now we have this noisy brown environment and this is because we haven't defined how the textures going to be working within our environment as it is hooked up in the materials. So, we have this ocean test static mesh and you'll see underneath Materials if we go under our Materials folder in the Content Browser there is this Ocean material and that's what's simply applied here that I can either drag that over and drop that in or with it highlighted in my content browser I could simply click this arrow and make sure that that is assignedthere.
So, now we want to work with this material. Well, this is quite an advanced water material here so if I double-click on that and bring this up, let's take a look at what we have as far as a network structure goes. So, I'm just simply using my right mouse button to pan and track around, and my middle mouse button to zoom in and out. You can see that this is all grouped into definitions so we have an area that's controlling our normal maps, and area controlling reflection, or base reflection, and an area that's controlling opacity and refraction. Displacement, this is controlling the waves and any fine details and an overall color area.
Now, something special is happening in this area here where down below if we come down to the very bottom driving into the base color as well as the opacity is a simple little sea foam texture map here, or water foam for that matter. And, this water foam texture, if we go out back to our Content Browser and look at our Textures directory exists in here. In fact, all of these textures are being utilized by this ocean set up here, the turbulence, the RGB clouds, even the sky texture for reflection, and this water foam texture.
Now, we don't need to get too specific into all of the details in the hook ups of this, but we do need to understand some basic things so that we can control how we have the sea foam, or the foam on the water on the surface. Now, we have these water foam texture maps coming in here. They're going to a bunch of different math functions which at the end of all of these chains most important to understand is they're coming into the base color by mulitplying with the overall ocean color and the opacity by doing something very similar to control the overall translucency of the water there as well.
But, we do have something special going on here and that is with something here called a vertex color. Now, this vertex color if I just click on that arrow is going to show us something solid white, nothing very special going on there but they're actually is a powerful use for this vertex color. Now, this is a put at the top of a node here, top of a chain and it's driving through a multiplier which goes through several different other math functions. And, as I mentioned we're not going to dive deep into all of these different functions here as to what's going on. The basics are to understand that it is multiplying through the chain between this color which we'll define and the sea foam color.
And, this is being mapped into the opacity and the base mesh. Now, why do we want to make this vertex color here? We're going to use a painted color that we paint with our Paint Edit Mode to drive where we want the sea foam to be. And by doing this we can have a definition of how we want it to interact in our scene. So, this vertex color is going to be our sea foam controller. And, I'm going to label that. So, if you hover over top of the node you'll see this little comment bubble come up. So, let's click on that and I'm actually going to type in here Sea Foam Placement.
So, I'm going to call that one Sea Foam Placement and this is where we're going to drive Vertex color in here to define where this sea foam exists. Now, what we want to do is understand what's happening in the hook up before we leave here and go into our scene to paint. We're not driving the RGB into here, we're only driving the red channel. This is important to note, we're going to control the placement of our sea foam by the red channel of this node. So, this is where we'll want to come back to our beginning scene and we want to go into the Mode Panel up on the top left here.
You'll see that we have this Paint Brush mode. So, I'm going to click on that and bring it right inside this mode. Now, we want to work with vertices. So, we're going to paint vertex colors. You can see that Vertices is selected up here. And, we have colors selected and by default it's going to be white and black. That's fine, we want to use that. If we go down to the bottom, this is another important factor here, this is where we're viewing the overall effect here, which right now we're seeing all of this kind of noise structure in here. And, we can view the RGB color of that map.
Right now it's a solid white. Now, this white is actually driving the channel which actually puts in more noise, which is actually driving this kind of overall RGB cloud structure. We want to mask that out so that we just get our foam in here. And, the way that we can do that is come up to our Paint color and our Eraser color and we simply want to click Swap. The only reason I want to do that is I just want the black paint in our paint color here. While we're viewing this in RGB we're going to paint the entire scene here black.
The reason why we want to do that, before I do that, is that we're essentially culling out anywhere that there might be anything resembling foam from this water foam texture, or from this RGB cloud's texture. We're going to mask that right out. So, just to show here we have it everywhere right now in the full view in our scene, but in the RGB color this is where we wanted to find or kill that out. And, just to make sure that at anytime if you get lost in doing this you always want to have what you're painting selected here in the World Outline. So, here we have Ocean Test selected and this is where we're going to be painting.
If I don't have that selected I can't paint it. So, it's important if you lose your brush stroke and you're not sure what's going on, take a look at the Outliner, make sure our Ocean test node is selected. So, let's continue. We're in our RGB view mode, we're seeing solid white but we've switched our colors to paint black. Now, if I do this before I actually do any kind of flooding here what I can do is I can left mouse button, drag across this area here. My strength is quite low as you can see I've got a .2 strength, so we'll bring that up a bit.
And, if just simply drag in here and paint just to show what's happening, it's culling out that area. And, that's important to note because we dont't want all of this noise in here. We want to define the sea foam. Now, before we dive into the full thing here let's just get a little further understanding as to how this works. If we go into our RGB mode let's bring in a little bit of sea foam in this little area that we've masked out. So, we've taken our simple black color and we've held down left mouse button and we've simply painted out this black area so that we see a hole in that noise mess there.
So, we'll go back to RGB and underneath Paint Color here or at Paint Color click that color and let's select a solid red. Okay, so we want to bring everything right up to the top or you could simply type in a one and make sure zero, zero, zero is happening on the rest of the channels there. That's fine, it's going to show us our old color which was black and our new color which is red. Once you have that just simply hit Okay. Now, remember here we want to paint the red channel. We really could use any color we want, but it's safest to work with a solid red to effect that red channel.
I'm just going to leave it in RGB 'cause at the end of the day it's only effecting the red channel anyways. So, in here we want to paint. So, I'm just going to take my left mouse button and we're painting red in this little black hole that we have here. If we go to off in the View mode we'll see that we have something different happening. This is kind of that sea foam effect that we want to see. And, this is what we wanted to find along the shoreline here. So, I just wanted to give a quick understanding as to how we're working with this black to mask out everything and red to define where the sea foam's going to be.
Let's not worry about the color of the water right now we'll be able to dial that in with other environmental factors like lighting and different other things that will happen in the scene here later on. But, for now, let's define where we want this to be. I'm going to go back to my RGB. I'm going to go back to my paint color and I'm going to make sure that I have a solid black again. So, everything is zeroed out, we'll hit Okay. Under the Paint Color mode here, we have our paint color at black I'm going to hit the little fill bucket. And, what I want to do is flood the entire environment here now so that nothing is there related to that RGB Cloud color or that water foam color.
In fact, if we go to the View Off mode everything looks quite opaque, quite black, but if we get into the lighting you'll see that we do have a nice ocean environment going on. But, we're just not seeing any of the details here, you know, no little white caps or anything like that. But, we do still have a really nice ocean working in the scene. Let's define these little white caps or sea foam in our environment here. I think the best way to do that is I'm just going to hit my s key and my right mouse button and come out a little bit so that we can work in this bit of a larger view here.
Let's now paint the red color again where we want it to be. Simply go in and drive in a full solid red, one in the red channel, zero everywhere else and hit Okay. Now, in the RGB mode we could do this in the Off mode, but let's put it to RGB so that we can see what we're working with. Now, let's make our radius here a little bit bigger. Double-click on that and make it something like maybe around 1800. Now, I'm going to leave the strength here at about .74, .75 that's fine. And, I'm going to left-click and just start to drag along in our scene.
Now, if at anytime you have a bit of a difficulty in dragging the paintbrush you can hold down control to kind of initiate that, I've found that's kind of helped there as well. It can be a little bit clunky at times for the painting. This should be fine for what we want. In fact, let's test it out by hitting View off. And there, we're now defining specifically where we might want to have, oops I've lost my selection, you see I hit the Landscape mode, let's make sure we're in Ocean when we're painting here. And now, I'm kind of defining this overall feel of this sea foam.
Everything looks a little bit uniform though, so we want to erase some of that. The way we can do that is hold down our shift. So, in our RGB mode we can come back here, we can take a look at this and we can hold down shift. We don't want our erase color to be white. I do want to change that so I'm going to click on this and make it black. Let's just make that black 'cause we know that we can quickly mask it out. So, everything is zeroed out, we have black here so just hit Okay. And now, in our Erase color, so we can go to Paint color and we can hold down shift to do that. Whoops, that's probably a little bit too much.
This will start to carve in there so we can break up that overall uniform kind of paint that we have along the coast line there. Now, let's hit Off and view that. So, we're starting to break that up a little bit. Now, let's zoom in now that we have a base here we'll hold down w and hold down my right mouse button. And, we might want to work now with defining some more specific areas. So, I'm going to bring my overall value of my brush down to something like 500, so it's a little bit smaller. And maybe bring the strength down just a little bit so we can fade in some different colors.
I want my paint color still on red, and this is where I can start to define some overall sea foam in here. And, if we're not getting it in the actual View mode here go to RGB and simply paint that in a bit. And, just a little tip if you lose the paint I find if you click on the paint color that you're painting with you'll actually get it back live. And, this is kind of a process of switching back and forth. And, you can paint in the RGB color here as well. Whoops, we've lost our Ocean test, let's just make sure that we're working with that here.
And, go to RGB to make sure that we're painting the red color in there. Now, we simply are doing this to break it up. If at any time I want to get rid of an area I can hit my shift or hold down shift and kind of carve or cut in to just break that out to make it look like there might be some rocks, something breaking up the water here. That's a little too much there. I would end the water here so that we get that kind of sea foam happening out as we paint. So, there we go we've looked at how we can quickly effect the overall feel of this sea foam or this water foam in here.
And, you can see that we really get this nice kind of effect of the water kind of effecting the shore. Now, as I mentioned we're going to work with the overall lights here. We have a couple other effects we want to build into this scene. And, that's really going to bring up the overall effect of that water. I should point out that the water, this advance material that we're using, we do actually have some nice translucency going on in here that we can control at the material level. I'm going to turn off the grid so that we're not seeing the grid underneath there. And, we do have this nice kind of water environment that I think will work out quite well for our overall scene.
So, there's a preview of how to work with advanced water materials within Unreal Engine 4.
- Customizing the Unreal UI
- Creating a new project
- Creating landscapes
- Blocking out levels
- Assembling a scene
- Working with materials and lights
- Adding post-processing effects
- Defining bodies of water
- Adding atmospherics, foliage, and wind
- Working with the Blueprint editor
- Creating cinematics
- Monitoring performance
- Packaging a game for distribution