Friday, March 30, 2018

GDC 2018: How To Light A Level, slides and transcript


This post is aimed at beginner / intermediate designers. It's a summary of the talk I gave at the GDC 2018 Level Design Workshop with David Shaver (Naughty Dog) for the "Invisible Intuition" double-feature session.

David's slides on blockmesh / layout are here (PDF) with case studies from The Last of Us / Uncharted. You can also get my full slide deck PDF here, and my speaker notes PDF here... but I don't know when GDC will upload the talk to YouTube, sorry.


A very brief and simple history of light starts with the sun. Then let's not forget about fire, controlled burning in gas lamps, incandescent light bulbs with a filament... and these days, there’s a stronger focus on more energy-efficient fluorescent lights, and LED lighting is also becoming more common.

It’s tempting to think of this as a story about technology and progress and older light sources becoming obsolete... but the light bulb did not make the sun obsolete, and the LED does not make fire obsolete! We still use fire as a light source all the time -- in our birthday candles, in our campfires, in our romantic candle-lit dinners -- in fact, I hate those little fake flickering LED candles, because a real flame has a unique quality to it, you know?

Fire hasn’t disappeared from the world, but rather our culture around fire has changed. That is, fire used to be a common and practical tasklight in Shakespeare's time, but now it feels more like special decoration for a special occasion. As a designer, you need to sensitize yourself to how light feels and conveys these ideas, because this is how you communicate those moods to the player.


Now in real-life, light is part of a complex but coherent system of physics with energy, waves, rays, photons, etc. Expensive lighting effects like real-time shadows, reflections, refractions, or screen space subsurface scattering (SSSSS) all happen for "free" in real-life, because that's how physics works! Meanwhile, in video game land, light is a box of crappy hacks that we must tweak and tune into seeming like an elegant system. Every piece is a layer of detail where you can tell one light to "turn off shadows" or tell another light to "disable reflectivity", which would make zero sense in a physically accurate system. Because it can get so complicated, I'm just going to focus on fundamentals... these 4 light types are in every 3D game engine or 3D toolset, and form a complete domain of basic lighting tools:

3D LIGHT TYPES: Global, affects everything Local, affects nearby things
Shines in one direction Directional light Spotlight
Shines in all directions Ambient light Point light

Ambient light is like the default amount of light you add to the world so that it isn't pitch black. The directional light is like sunlight or moonlight, and casts constant light from a certain direction (usually downwards from the sky). A point light is like a bare light bulb and throws light in all directions, while a spotlight casts a cone of light in a certain direction. (For more info and examples, see "Lighting Theory for 3D Games, part 4")

These are just tools, and you need design theory to imagine how to use these tools. The most common lighting design theory is probably three-point lighting, which is widely used in film, theater, and photography.


Three point lighting refers to three different types of lights: (1) a key light is your main dominant light source, (2) a fill light brightens darker areas, and (3) a rim light highlights edges to pop the foreground from the background. Sometimes there's a (4th) background light that brightens up the backdrop to smooth out awkward shadows from the key and fill.

Notice how the key light and fill light in this example are perpendicular to each other, while the rim/back light is behind the subject. All these lights had different intensities and color temperatures, but for this theory, you should be paying special attention to the light positions and directions. Their placement, relative to other lights, determines their function.

(If you want some more examples of three point lighting, you can read this post from the lighting blog Lighting Pixels.)

However, the big problem with using three point for games is that it assumes you have complete control over the camera... but what if you don't? What if the player controls the camera? Three point light types depend on the light's orientation relative to the camera -- a rim light is a rim light because it grazes the subject, but if you approach from a different angle, now there's no more rimming action -- now the rim light is a key light! If it looks like a dim shadowy silhouette from the front, it'll glow like a deer in headlights from the back. The light placement matters, but the camera placement matters too!

So in order to use three point theory effectively in games, you need to be able to predict the camera angle. In a first person game, that means knowing roughly where the player will be walking and looking. Fortunately, we already have a tool to constrain the player's movement and rotation: it's your level layout! If you frame a subject a certain way, or limit an approach to a certain direction, then you can place lights for that perspective.


OK, now let's just get down to it: how do you light a level? Here's a general suggested workflow, for use in whatever engine or toolset you're using:

1. Graybox / blockout your level layout. You can't light a level if you don't have any floors or walls to light. Also, remember that your level layout is a lighting tool, and you'll want to understand how the player moves through your level. (If you need help, read my primer for How To Graybox A Level, and see David Shaver's slides on blockmesh and layout tips.)

When I'm grayboxing, I like turning off light baking so that I don't get distracted -- in Unreal 4.18, that would involve enabling "Force No Precomputed Lighting", while in Unity 2017 you would disable "Auto-Generate Lighting" at the bottom of the Light Settings tab.


2. Configure global lights (ambient, directional) and figure out the dominant mood. Is this a safe sunny sundrenched place, or is a spooky dangerous moonlit complex? You'll want to setup your basic light levels and time of day because it affects your entire scene.

In Unreal 4.18, this means playing with the DirectionalLight, SkyLight, and Lightmass bounce values in the World Settings. In Unity 2017, you should tweak the Directional Light as well as the ambient values in the Environmental Light section at the top of the Light Settings tab.

If you're not baking lights or using global illumination, you might need to hand-place some faint point lights to simulate the bounced "fill" effect that would come from sunlight. I've even heard a particularly scary rumor that Fallout 4 didn't have any GI or light baking, so some poor soul had to go and place little point lights everywhere to simulate sun rays washing through a room. Yikes! Unless you're making a mobile game or have harsh memory limits, I'd just do some baking. It's worth it.

(TIP: For those kinds of "invisible" faint subtle fill lights, you should usually turn off their specular contribution / flatten them. So in Unity, I'll often set these lights to "Not Important", and in Unreal I'll set the Min Roughness to a higher value.)


3. Light for player progression, and highlight exits / critical path. This part mostly involves using point lights and spotlights to draw more attention to where the player might want to go in your game. My example above is pretty exaggerated, with bright red doors and bright warm spotlights, but you get the idea -- you want to create contrast with these key lights, and suggest where the player can go in a pretty obvious way.

One important concept here is hierarchy. If your room has multiple entrances, exits, or routes, you should try to light them according to their context. Don't light everything the same, but rather, create some differentiation. Maybe some key lights should be brighter than other key lights, maybe a main entrance deserves more lighting than a sneaky side exit, etc.


4. Light setpieces and encounters. If you have big puzzle areas, or battles or enemies in your game, you'll want the player to notice these features and form a plan to tackle these setpieces. That means your lighting needs to help the player read the situation. In these instances, a key light might get lost -- so here I often like using rim lights and background lights instead, to help silhouettes and shapes pop out from the background.

You can see in the example above I use blue-green teal flood lights to draw attention to the Almighty Orb and the various henchmen. The enemies themselves remain dark silhouettes, but that's OK if the game is about eliminating them. Notice the light direction (teal arrow) is roughly perpendicular to the player's critical path (orange arrow), that's different is what makes it function like a rim light. If I hadn't playtested my level, and I hadn't known where the player would approach from, then it would make it difficult to design this lighting scheme!

Again, it's a very exaggerated example, but it helps you see the difference between the NPCs and the environment, even from a faraway distance. As you do this, try to keep your lighting language consistent. If you light one type of thing in one way, then try to keep lighting it that way.


5. Do a texturing / color / albedo pass. At this point, you should maybe do a texturing pass or a base color pass on your level geometry. Light color might mix with your diffuse color to produce strange or unpleasant color combinations, especially if the colors happen to clash.

If you're using baked lighting or GI, then the albedo color value matters even more, since both Unity and Unreal use the albedo's luminance to calculate light reflectance. Darker albedos produce much darker rooms than you'd think, while lighter albedos tend to produce more plausible results. In general, try to err on the side of brighter albedos near the upper midtone range of a histogram. (You can check your texture's histogram in Photoshop with Image > Adjust > Levels.) (For more info, see Epic's UDK texturing guidelines, which are old but still relevant.)

Calibrating your brightness and darkness tones is important. When you light something prominently or hide something in shadow, you're sort of making a statement about how you feel about it...


6. Take responsibility for your art and be considerate. In the article "Black Skin Is Still A Radical Concept In Video Games", Yussef Cole and Tanya DePass feature this unfortunate example from Skyrim: the white woman on the right is lit evenly and we can read all the different contours of her face... while the black woman on the left is lit poorly, and basically the bottom half of her head is missing. The black woman is lit so strangely that it's as if she doesn't even belong there!

This is why lighting is worth spending time on! The cost of thoughtless lighting is heavy: you'll end up making a game that doesn't care about black people.

Now, I doubt an evil mustache-twirling racist developer sabotaged the lighting in Skyrim. However, this is a clear case of institutional racism -- it wasn't intentional, but the predominantly white dev team at Bethesda probably playtested with lighter-skinned characters as the "default", and never stopped to do a lighting pass for the darker skinned characters... otherwise they would've noticed the black woman's albedo tint is way too dark, or that she needs stronger specular values, or that the game world's spheric harmonics bake needs to be recalibrated. Lighting matters and workflow matters!

If a bunch of professionals (making an otherwise awesome game) can fall into this trap, then so can all of us. So the big takeaway of this entire talk is basically just: think critically about what your light is doing.

Light adds depth, mood, meaning, and context to your game. Don't leave it until the last minute, don't treat it as an afterthought, and don't be scared of it -- you just gotta put the time and work into it. Try different variations, and experiment with different lighting schemes. If you're ever in doubt, ask diverse collaborators for feedback. I believe in you!

Anyway. I hope you learned a little bit about light today. Thanks for listening.

This is just a summary. You can also download the full slides PDF (with bonus slides at the end) or the speakers notes PDF.