Join Craig Barr for an in-depth discussion in this video Environment lighting, part of Unreal Essential Training (2016).
- In Unreal Engine 4, we can take advantage of the power of materials, and certainly the power of lighting to really bring our scene to life. Now, we've populated this scene with some nice, simple, directional point and spotlights to provide some effects with our local assets in the main hero, kind of, section of our environment, but we really need to light the overall scene, and that is, provide kind of a global lighting here so that we get a nice feel of an outdoor environment. Now, we're going to look at two different ways that we can do this here in Unreal Engine 4.
One of them's going to be using the default skylight, and another one's going to be using kind of a canned or built model with a nice textured environment. So let's take a look at how these work here. So we've seen the power of using the simple directional point and spotlights. We have this fourth lighting option here, underneath the "lights" option, which is the skylight, and if I just left click and drag that into my environment here, we'll maybe just place it up in this area right here, we'll see that we get this kind of little half shell object in space, here.
Now, it doesn't really completely matter where I place this in my scene, but I'm going to place it just kind of up and in the middle here so that it's easy to see and easy to work with while we're looking at it, and what we're going to want to do with this is actually dial in a cube map, here, to provide some lighting to it. So the first thing you're going to see when we do that, when we define a cube map, is we're going to see it affect the overall lighting of this environment, the overall, entire landscape of the island.
So I want to define a cube map. Before we do that, I should point out that I am using, underneath view options, I'm exposing, "Show engine content." So when you install Unreal Engine 4, you'll get access to "show engine content", and that's all I have exposed down here, engine content, and if we keep that turned on, here, we can access all of the different sample models, textures, and different environmental settings here, and that's why we're taking advantage with this. We're going to use this SLS specified cube map, and I'm going to dial in on this little pull down menu here a simple daylight texture cube, and if I hover over that, you can see that the path for that is underneath that, "engine map templates".
So we're just going to use this simple daylight. If I just click that, you'll see right away in our scene, we have this kind of global, overall lighting effect happening here. So let's move our details up a bit so that we can take a look at what's happening in this. Now a couple of things that we can see. We have some of the basic settings here that we're familiar with, and this is things like "intensity". So this is where we can dial in the overall intensity of that kind of global sky-lighting that we're using this cube map for.
Of course, by default, you can see something like "effects world" is on, if we click that off, it's going to turn off everything on there. And the light color by default is going to be right in the middle of that white, to provide what the cube map is providing, but we can also color that or tint that, if we wanted to provide a bit of a different mood or theme overall for that lighting. So let's leave it as that. We can dial up the intensity if we wanted to give this a little bit more of an intense, kind of daylight feel, and if we just hit our "w" and right mouse button and zoom in, we can start to see that we're getting a bit of a feel of a daylight scene.
And that's fine. There's the real basic perspective of how we can work with a simple skylight here without diving in too much further to hook up to an overall setup with that skylight. Let's bring this back and take our skylight out of here, and I'm actually going to delete it out. The reason why I'm going to do that is we're going to use something that's a little more dynamic, or a little more powerful for our scene in a couple of ways. We also have in this content directory a models directory. If you go into the "effects" area of that models directory, you will find a skybox sphere.
Now, the skybox sphere is something that, if I drag this into my scene here, you'll see that we get this rather large, or actually, it's kind of small, sphere right now, because we do want to set the size of it in here. I'm just dragging up my details section here so that I can see these attributes here a little bit more. Now, I do want to adjust the overall scale, or size of this here. We can see that the scale is one. Our little environment here is much too small for that, so we're definitely going to need to increase that.
Probably something much higher than what we have, probably in thousands up here, so we adjust this to 2000 across the board, and then we're going to actually position this down a bit. We'll grab that, and let me just hit "f" to see where that is in space. I'm going to move that down a little bit in here. And then if we grab our landscape, and we'll just zoom in on that, that looks like it should work. Let's grab something like the, the lighthouse. This is important for quick ways to get back into your environment.
I'm just grabbing the lighthouse piece, I'm going to hit "f", because we're framing in on that, and we can see now that we have this dynamic environment. We're getting an environment with a nice sky map that's actually animated, or, for that matter, moving in here. Zoom in, and also try it with the "s", and zoom out, just to take a look and see if this environment setting, or height that we have it as, is going to work. And actually, I think it's going to work just fine, because when we put in our ocean environment here, that's going to fill in that world really nicely.
So let's just zoom back in. And I'm just using the "alt" hot key here to kind of position our view port a little bit more in the middle. Now the important thing to note here, I'm just going to hit "escape" so that we're not selecting anything. Look at our scene now. It's starting to come to life with some nice overall lighting effects in here. Now, we have this simple little skybox sphere that I've dragged in, and this is being driven by two things here. We have a simple static mesh, which is essentially just this half skybox sphere, it's just this half little sphere model, but we also have this interesting material, which is this sky material.
If I double click on that, you'll see that a couple of things are going on here. This is taking in a simple texture map. It's taking in a simple color, multiplying that in there with it as well, and we have a bunch of different effects that are driving overall the emissive color of that sky, and that's important because that emissive color is really what's going to provide our overall lighting for this. But we need something else in here to really provide the overall effect of an environment lighting.
And that is what we're going to want to apply or add to this, is a source light, and typically, what we want is a directional light for that. So I'm just going to left-click underneath my "modes" panel, underneath the "lights" subset, going to left-click and drag in a simple, directional light. Now by default, if you recall, it's going to come in really bright, at an intensity here of around 10. We certainly don't want it to be that bright, so we might want to dial this back a little bit. For now, let's leave it like this.
We're going to adjust things like color and the direction that it's facing in, so we'll just kind of bring it down to maybe something in the middle there, something like that is fine. Now, I want to point out one more thing here while we're working. By default, this view port is into "lit" mode. If I turn it to "unlit", it's going to turn off all of our lights, and at any time, we can see this flat lit scene. This is kind of like diffused lighting, or RGB lighting, where we're just going to get flat lighting right across. We're not really seeing any shadows, we're not seeing any lighting effects, we're just seeing, essentially, a flat, uniform lighting across all of the texture maps.
So this is good and easy to work with. If we're working with our lighting, and if things get a little dark and we can't see what we're doing, put it to "unlit", and you're going to find that it's much easier to work with, at least for placing objects or maybe just working with an area of the scene so you can at least see what you're doing in there. Now that we have lots of lights in our scene now, of course, we can hit alt+4 or come to our little lighting mode up here, view mode, in the view port, and just click "lit" to get that back into our lighting. So we now want to adjust how this light source, and I'm going to rename that directional light to just that.
I'm going to call this "light source", so I'll just quickly rename that. And it's actually dropped down by alphabetical order here, there it is, "light source". Now, I'm going to actually make this light a movable light, and the reason why I want to do that is, in our project, we may want to animate this light. For example, daylight, coming up or going down, and affecting the overall shadows and the lighting on this. So that's fine. We'll leave that at movable for now. But a couple other things that we want to do.
We may want to adjust the overall setting of how this light is affecting the shadows on here, so if we bring this down here, we can see that we have the ability to cast shadows. So by default, "cast shadows" is on. If I turn that off, you'll see the effect of that. So we are casting shadows, but we might want to affect how we're casting those shadows, or, for that matter, the direction that we're casting those shadows in. So we might want to affect things like the direction that we're casting it in from here, and we're looking at the shadows as we dial this in here so that we can get this feel that we want for the time of day, or the lighting that we want to get in there as well.
Now let's see if we kind of bring that up, that might be a little bit too much for what we want. This is starting to look pretty good. So I'm looking at the overall shadow quality that we're working with there, and that's probably going to be pretty good. We're really going to load this scene up with some foliage and trees and things like that as well, so we want our lighting to work in our kind of hero area as we apply that color, or overall light, and speaking of colors, actually what I want to do here, I want to come in and actually assign a little bit of a color to this.
Right now, it's a very default white, and that's fine, but we may want to add some mood to this. And an excellent way to add that mood is by adding some color to your, your lights or your scene. Putting in something like, maybe towards an orange-y kind of red really gives this idea of a dusk setting in here. And we'll simply hit "okay" on that. Now what we might want to do is make sure that we come down and check a couple of our settings here. We have our nice sky applied here, that's providing some nice global illumination on there, and we have this light that's going to provide our simple daylight, or be kind of our sunlight.
But we really want to define that as our atmosphere sunlight, so if we go in our details of our light, and we drag all the way down, you're going to find "atmosphere sunlight". And we're just going to click that on. And we've defined that now as our atmosphere sunlight, and then what we're going to want to do here is just check out our overall shadow quality of what we're getting here. I think it's going to be okay, but what we might want to do is make sure that it's small enough that we're getting the proper shadow bias on there, so we're going to zoom in to check this out.
Now, shadow bias, let's focus in on the car by selecting the car and hitting "f", and I'm going to turn down my camera speed. There we go. Turn that car, just select the car, and we'll just right, I'm just using "w" and right mouse button, and we're just coming in here a little bit, and I can certainly go a little bit faster than that. There we go. So with our light that we wanted to affect here, let's go back and make sure that we're selecting our light source as we've called it, and go back down in here and just make sure that our shadow bias, if we start to dial that in, and see how that's affecting the overall shadow quality, we can see that this in these rocks in the background here.
We want to make sure that we're getting the proper shadow effect up close here, where we're going to be a little bit up close on the scene. We can see it affecting the car there as well as I kind of dial that down. So something maybe in this kind of area around there is probably going to work, something, .16 to about .18 will probably work just fine. And then we might want to sharpen the overall shadows a little bit. Maybe not that much. That's fine, that's just going to give us a little bit more of a sharpened edge of our shadow there as well.
So there we go. We've set up our scene, let's hit "s" and right mouse button, click out. Let's actually adjust our camera, speed out a little bit faster. And you can see now that our scene is really starting to come to life. We have nice environment lighting in here. We have some nice lighting effects happening on our overall scene, but we may want to come back in here at some point as we add more effects to this and adjust the overall light quality. Maybe we want this to be a little bit darker or something that is more into the night, but we'll affect that lighting as we go and as we add in more post-effects here as well.
- 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