Learning Unreal Engine 3 – UE3 Editor

Lighting

This section covers lighting in Unreal.  Since this is just an editor tutorial, I won’t go into much depth on good lighting (entire books have been written on the subject!)  But I will talk about how Unreal’s tools in specific can be used to achieve good effects.

1) Previewing Lighting

One of the coolest features of the Unreal editor is that you can see the effects of changing your lights in realtime.  This lets you work pretty effectively in a small area, tuning your lights as needed.  Once you’re pretty sure the light looks how you want it, you can bake lighting and see the final optimized result.  Sometimes the look will change slightly, but it’s easy enough to tweak the light again to get the look you want.

 

For most of these exercises we’ll place a new light and work with it in dynamic mode, then bake when we’re all done editing.

2) Types of Light Objects

There are four basic types of light objects in Unreal – Point Lights, Spot Lights, Directional Lights, and Sky Lights. 

 

Point Lights can be thought of as a light bulb – they radiate in all directions.

Spot Lights are like a flashlight, or the headlight of a car.  They radiate out in a cone shape in a specific direction.

Directional Lights are most like the sun – they fill the entire scene with light coming from a uniform direction.

Sky Lights are kind of like the uniform gray lighting you get on a cloudy day.

 

All four light types have a lot of properties in common (like brightness and color), so we’ll dive into the properties of a point light first, and then just discuss what’s different about the others. 

3) Point Lights

Open an existing test map, or create one.  For now, we’ll start in Unlit mode.

 

Placing a point light is easy – right-click on a surface and choose Add Actor->Add Light (Point).  Or just hold down the “l” key (for “light”) and click on a surface.  A point light will appear. 

 

Go into Lit mode, and press F4 to bring up the light’s properties, then open up the “Light” category and the “LightComponent” subcategory.

 

There are some pretty cool controls here if you know how to look for them.  For instance, if you want to change the Brightness of the light, you can type in a new number in place of “1.000000”.  Or, if you hold the mouse between the two black arrows on the right, you’ll see it change to a double-arrow icon.  Click and drag up and down and you’ll change the brightness dynamically.

 

Next to the LightColor field, you can click the magnifying glass to bring up a color palette display.  You can also click on the mouse pointer icon to get a color picker (click in the scene to sample the surface’s color.)  Try both of those now.

 

I’ll list the most important properties here.  Be sure to try each one on your own.

Brightness – pretty obvious, it’s how bright the light appears. 

FalloffExponent – how sharp or soft the light’s falloff appears within its radius.  Move your light close to a wall and adjust this value, and you’ll see how it works.

LightColor – the color of the light.  Multiplies against the Brightness setting – so if you pick a bright color but a low brightness, it’ll look dark in the scene.

Radius – how large of an area the light affects.  A wireframe sphere is drawn around the light in the level to help you visualize.  (You can also adjust this by using the scale tool on the light in the scene.)

 

Other properties are generally best left at their default values, though we’ll discuss some of them later.

 

For now, make your light a rich orange color with a fairly high brightness and a radius large enough to fill your room.  Be sure to bake lighting to get the final effect.

4) Spot Lights

Placing a spotlight is a little harder than placing a point light – they can be found under the Actor Classes browser.  So open your Generic Browser and go to the Actor Classes tab.  Open up the “Light” category and select Spot Light.  (You’ll notice two sub-categories, SpotLightMovable and SpotLightToggleable.  These are mainly used in animation sequences or hooked up to gameplay, so ignore them for now.)

 

Right-click in your scene and select “Add SpotLight Here”.  A white spotlight appears pointing down.  Move it so that it’s casting a circle of light on the ground.

 

Spotlights have all of the same important properties as point lights (color, brightness, radius, falloff) but they have a few additional properties as well.  Make sure your spotlight is selected and open up its properties.  Look for two new properties.

OuterConeAngle – how wide of an angle the cone covers. 

InnerConeAngle – controls the hotspot in the middle of the cone.  If it’s 0, it’ll cast a very soft circle of light.  If this is the same radius as the OuterConeAngle, the spotlight will cast a hard-edged circle of light.  (But you may lose detail when you bake lighting.)

 

You can rotate a spotlight using the standard rotation tool in the editor.  You can also control it in first-person mode (like holding a flashlight) by clicking on “Lock Selected Actors To The Camera” on top of your perspective viewport.

 

 

Update your spotlight’s cone angle to cover a wider area, and point it at a wall.  Bake lighting to see the final effect.

5) Directional Lights

As I mentioned before, a directional light is like the sun.  So what’s going to happen if I place one in this room?  After all, there are no windows.  Place a directional light now (the same way you paced a spot light – select it under the Actor Classes browser.)

 

It doesn’t really seem to be affecting the scene, except for a weird shimmering effect on the walls.  And if you bake lighting or rotate the light, the shimmering goes away. 

 

Aha!  Even though the icon for the light is inside the room, the light is only affecting the outside of the level.  Much like the sun, the walls of the rooms are casting a shadow on the interior of the rooms.  So a directional light is really only useful in an outdoor scene.  (And even then, you have to turn off “Cast Shadows” on any skydome object you’ve placed.)  Rotate the light slightly so that it’s not facing straight down.

 

Rotating a directional light works the same way as rotating a spot light.  But instead of having a light cone to indicate the direction, you’ve got a little blue arrow.  Works well enough!

 

6) Sky Lights

Skylights are a good way to add a small amount of ambient light to your level.  They’re also great during the prototyping phase, since they cast light on everything in the scene and they don’t slow down your framerate much.  Their big disadvantage is that they don’t cast shadows – so even interiors will receive light from a skylight. 

 

Let’s place one now (same method as the other light types.)

 

Immediately the scene gets much brighter (except for the ceiling, which is unaffected.)  The light is brightening up every surface based on the angle relative to “up”.  (So the floor gets a lot of light, walls get a medium amount of light, and the ceiling gets no light.)  We can adjust the brightness and color of this light, and in fact we can add in “bounce” light that affects the ceiling as well.  Open up the properties for your skylight now, and play with the settings.  There are only two new ones you haven’t seen yet.

LowerBrightnessthe brightness of the “under” light (default to 0)

LowerColorthe color of the “under” light.

 

Adjust the skylight’s properties so that the color from above is bright red, and the color from below is bright blue (with a bright enough LowerBrightness that it’s visible.)

 

Ok, that’s pretty hideous, but notice how the red and the blue are combining to make a purple color on the walls.  It should be especially obvious if you delete your point light.

 

One last thing – the icon for that skylight is very small, and it’s likely to get lost in a large level.  In the properties, under the Display category, change the DrawScale to 10.  It’s much easier to find now.

7) Putting it all together

Let’s look at how these different light types are actually used in a scene.

 

I’ve stripped out a small section of one of the Unreal Tournament 3 levels (DM-RisingSun) so that you can see how Epic used these light types in a practical setting.  Download this file and unzip it to My Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\CustomMaps

http://waylon-art.com/LearningUnreal/DM-LightingTest.zip

 

Load up the map, and you should see something that looks like this:

 

Look around in the scene and see if you can get a sense for what lights affect what.  There are a bunch of point lights and spotlights placed near light fixtures and that glowing door.  But what’s lighting up the cliffs in the background?  Let’s find out.

 

Click on the “Toggle Show Flags” button and turn on “Light Influences”.  Select a cliff mesh and you’ll see two blue lines coming out of it.   

 

If you zoom out, you can see that the lines lead to the two directional lights in the scene.

 

You can see that the lights point in roughly opposite directions.  And if you bring up the properties you’ll get a sense for what they do for the scene.  One has a brightness of 2.5 and sort of an off yellow color – that acts as the sun.  The other’s brightness is 0.25 and is a dull blue color – that functions as the fill from the sky.  If you deleted all of the lights in the level except for these two, the exterior spaces would still look pretty good.

 

8) The Search for Actors tool

You can select lights in the 2D or perspective views to figure out what they do, but let’s look at a new tool – the “Search for Actors” tool.  You can open it up by clicking on the binoculars icon at the top of the window – do that now.

 

The Search for Actors window opens up, listing all brushes, static meshes, lights, and other objects in the world.  But we just want to look at lights.  Click on the “Containing” radio button, then in the “Search For” field, type “light”.  The bottom of the display should say “11 objects found”. 

 

So what do we have?  Two directional lights, five point lights, and four spotlights.  Notice there aren’t any skylights in the scene.  If you double-click on a light in the list, it highlights it in the scene and focuses the camera on it. 

 

Spend a few minutes and look at the properties of each of the lights, and get a sense for what role each one fills in the scene.

9) The PostProcess volume

There’s one last thing that’s affecting the look of the lighting in the level.  There’s a PostProcess volume surrounding the corridor.  If you zoom the camera out in the perspective view, you’ll notice a subtle change in the colors of the scene.  A postprocess volume controls tinting, brightness, and a bunch of other effects as long as the camera is inside of it.

 

Select the postprocess volume now and open up its properties.  (It shows up as a purple box in the 2D views, or you can search for “post” in the Search for Actors tool.)

 

We’ll go into more detail in a later tutorial, but try playing with some of the settings and see what affect they have.  The controls aren’t very intuitive, but the color tinting comes from the Scene_Desaturation, Scene_Highlights, and Scene_MidTones parameters.

10) Lighting Channels

You may have noticed that the directional lights have slightly different icons – one has a “U” on it, the other has an “S”.  (The one colored like the sun is the “U”.)  If you compare the properties of the two, and look under the “LightingChannels” category, you’ll see that the sun has the “Dynamic” flag checked while the blue light doesn’t.  Both of them have BSP and Static checked, which means they’ll affect BSP (CSG) surfaces and Static meshes.  But what do the other flags mean?  What does CompositeDynamic affect, and what does Dynamic affect? 

 

CompositeDynamic just means that the light affects characters.  (Yeah, not the most intuitive, but the name is based on the technology that drives character lighting.) 

 

Dynamic is sort of a special flag – it’s the most expensive type of lighting, and in the case of DM-RisingSun, it’s used on the door that opens up as a part of the scripted opening sequence of the game.  Because the door moves, it can’t use static lighting, so it’s tagged so that only certain (dynamic) lights affect it. 

 

There are lots of other flags though, and you’re free to use these as you need.  For instance – say you wanted a spotlight to affect a floor, but not the walls next to it.  You could set up the spotlight so that only “Unnamed_1” is checked, then make sure “Unnamed_1” is also checked in the properties of that floor mesh. 

 

Knowing how to manipulate light channels isn’t critical, but in special circumstances they give you that little bit of extra control you might need.

11) Pickup Lights

Pickup lights are a special gameplay construct handled automatically by the tools.  They’re covered in the “Adding Gameplay” section.

http://waylon-art.com/LearningUnreal/UE3-04-AddingGameplay.htm

12) Lighting a scene

Now that you’ve seen how Epic lights one of their scenes, a good exercise would be to delete their lights and re-light the scene on your own.  So try that now.  (You can select all of the lights and delete them via the Search for Actors dialog.)  You don’t necessarily need to duplicate Epic’s scene exactly – be a little creative, and see if you can take things in a different direction.  Be sure to bake often, since the look changes quite a bit when you bake.

 

To get you started, here are some of the “roles” a light can fill in your scene.

Directional Lights

-         The Sun

-         Ambient sky light (try placing multiple lights, all with a low brightness and bluish color, facing downward in the four cardinal directions)

 

Point Lights

-         Area lights (dim, filling a corridor with bounce light)

-         Highlights (small radius, probably near the spotlight meshes.)

-         Bounce lights (if a bright light hits the floor, it’ll bounce up and light up the walls and ceiling a little too)

 

Spotlights

-         Spotlights (a cone of light projecting from a spotlight mesh.)

-         Fill lights (blue light pouring in between the arches, hitting mostly the floor)

-         Bounce lights (similar to point lights, but a little more control)

 

Skylights

-         You may want to add some additional ambient light to the scene using a skylight.

 

Postprocess Volumes

-         If you leave the existing postprocess volume in place, it’ll tint your scene slightly with a warm color.  Try playing with the values to change the look.

 

You can see in my before & after screenshots below, most of the difference comes in the postprocess effects, but I’ve got a lot more light spilling in from outside and a lot less being cast from the interior light sources. 

 

13) Reducing bake times / saving memory

It’s important to keep your map as small as possible.  There’s a direct correlation between map size and how many people download it.  Overly-high lightmap resolution is a major contributor to map size, and it also causes your map to take longer to bake.  So kill two birds with one stone, and optimize your lightmaps.

 

-         Optimize hidden BSP surfaces.  Set the resolution to 65536, and uncheck “Accepts Lights”, “Accepts Dynamic Lights”, and “Force Lightmap”.  Also apply the material “RemoveSurfaceMaterial” from the EngineMaterials package.

-         Reduce lightmap resolution on surfaces that don’t need it.  If a surface has a sharp shadow across it it’s ok to leave the resolution high, but lots of surfaces that don’t receive direct lighting look fine with a resolution of 64, 128, or even higher.

-         If you assign lightmaps to static meshes, keep their resolution low.

-         If possible, assign low-res lightmaps to static meshes that have a high polygon count.  (Lightmaps may be cheaper than calculating lighting for every vertex.)  More information can be found here: http://forums.epicgames.com/showthread.php?t=589900

 

Next: LightMaps

Back to the Topic Index

 


other tutorials