Thursday, March 19, 2015

Lighting theory for 3D games, part 2: a formal approach to light design, and light as depth

Here's how I generally, theoretically, approach lighting in my games and game worlds. Part 2 is about light and function, mostly for level design.

In part 1, I talked about how different light sources have different connotations to the viewer, and these meanings are culturally constructed. In New York City today, an antique Edison bulb connotes trendy bourgeois expense, but 50 years ago it might've been merely eccentric, and 150 years ago it would've been a thrilling phenomenological novelty.

But people rarely intellectualize lighting this way, in, like, your own bedroom. In your daily middle class Western life you don't usually agonize over the existential quandaries of electricity, you just flip the light switch without looking. When in familiar places, we experience light as a resource or tool and take it for granted. So much of our everyday relationship with light concerns its functionality and what it enables us to do.


Lighting intended for a specific purpose is called task lighting, as opposed to merely cosmetic or decorative lighting. My thinking is that it's NOT about establishing a rigid binary of which lights are what, but rather it's to get you to imagine what particular tasks a particular light lets you do. Many lights can be both functional and decorative -- for instance, a candle flickering on a restaurant table is moodily dim and romantic, but it also helps you discern different tables and see your food.

In games, we are concerned with making the world readable (or selectively unreadable) for the player, to help them navigate and wayfind through a space, as well as discern different game objects. We also want to reassure the player that the world was competently constructed with some sort of intent, and that they aren't wasting their time and/or money.

For now, let's try thinking about light more formally. How does light let us read a game more easily, and what are some common patterns?

from Magnar Jenssen's excellent "Functional Lighting"
In 3D games, light gives us crucial depth cues and allows us to read the surface of an object. Without lighting, every square inch of an object will appear to have the same "value", which flattens the entire shape and emphasizes its silhouette instead of its surface.

Sometimes this flatness is a good thing that can simplify our scenes and make them easier to read, or sometimes we'll want to trick the player, but much of the time this is a distraction that prevents a player from understanding what they are seeing and interacting with your game -- and because we are trying to depict a 3D object on a flat 2D screen, we often need all the depth cues we can get.

Look at the round shapes below, and look at how relying only on silhouettes means they will LIE TO YOU:


(Again, lying to the player or viewer is great if you have a purpose in doing so... but purposeless lying is just some trolling bullshit.)

At "fullbright", or when a game engine renders models unlit at default 100% brightness, it is difficult to tell the difference between the cylinder and the sphere. To help read 3D depth into a 2D image, we need to use texture, fog, similar objects near us and far from us -- we need spatial context.

Light is the main tool for creating this context. With light, we can read the contour and a mesh's surface normals -- the direction(s) that a given 3D surface is pointing, whether it is concave / convex, round or flat, etc.

Reading this surface topology is often very important for playing 3D games. Is this hill too steep to climb, am I supposed to go here? If I throw a grenade, which way will it roll down, and how quickly? How far is it to the top or bottom of the room, can I jump up or fall down safely? A lot of this type of lighting is about signposting for the player to help them understand their surroundings.


The image above is a scene from Residue Processing in Half-Life 1. Note the hanging ceiling spotlights focus on the floor, leaving the wall relatively dim -- this helps emphasize the neon green splashes from the toxic sludge, which is an important hazard throughout this chapter. It also establishes visual hierarchy; the bottom of the room is much more important than the top of the room. (One criticism: the hidden light strips along the ceiling edges are lazy and thoughtless, and don't feel industrial to me. If they wanted to isolate the metal ceiling from the concrete shell, they should've used geometry to do that. And there's already a trim! As it stands, it's just a mostly flat plane separated for no reason.)

On the left, the exit out of this room is lit prominently, so we know where we're going and don't linger for too long. (The NPC also shoots the headcrab monsters and runs out that exit. Valve really wanted you to follow.) The simplest way to light a space is to light every crucial game object / affordance, and make sure the player can see where they want to go. If something isn't important, then don't bother lighting it.

The point of the Residue Processing chapter is low-combat platforming and weapon inventory build-up in an industrial setting that re-uses the silo art assets from Blast Pit -- the point is not to fumble in shadows or to stage elaborate story events where you're locked in a room as NPCs talk. Fittingly, the lighting is very functional and utilitarian, and you don't really stay still for too long.


In this scene from Half-Life 2 (d3_c17_03.bsp), most of the courtyard is in shadow except for a neon teal Combine spotlight, an orange fire giving off lots of smoke, and a friendly NPC shooting at nearby enemies. Gee, Batman, I wonder where we're supposed to go?

Traditional thinking about game lighting is that it is garnish on top of a strong floorplan, but I think lighting is so powerful that it can help compensate for an unclear floorplan too. This is technically just a long room that ends in a blind corner; this is the textbook wayfinding problem that Brendon Chung refers to in his wayfinding talk at GDC 2015. In cases of equal value and flat lighting, as in the fullbright frame above, you won't see anything. But if you put a light around the corner, then we can easily discern the corner. Valve's consistent use of Combine spotlights even lets players estimate how far the blind light source is, based on its intensity and falloff.

The keyword here is "contrast", between shadow and not-shadow, between static lighting and flickering lighting -- between complementary colors blue and orange which are opposite each other on a color wheel and help emphasize each other.

A master class in how NOT to light a game? Note the blorange, note lazy glowy bits everywhere, etc.
Note that these kinds of rules and guidelines can easily be abused, and so they often are. Blue-orange, or "blorange", is a mark of laziness in CG and video games. (Video games tend to avoid red-green contrast for weird Christmas connotations in the West / players with red-green color blindness.)

Similarly, "follow the flickering light" or "follow the perpetually burning trash fires" or "follow the red glowing thing" is barely a step up from "follow this giant glowing arrow" or "follow the word FOLLOW." These are not novel nor compelling ways to explore a world.

Don't get me wrong. I'm a big fan of tackiness and tastelessness.

... Except when I've seen that same kind of tastelessness over and over.

the evolution of video games; from Jack Monahan's "Visual Clarity in Character Design"
These same ideas about lighting spaces also apply to lighting characters and their gameplay affordances. Which way is the NPC looking? Where is its head, so I can headshot it? How can I headshoot it even when we're in the dark? The laziest solution is to make things glow and add lots of color contrast.

Sure, now we'll notice this thing, but at what cost?

When we focus too strongly on the functional aspects of lighting. and apply guidelines blindly, the result is often overly instrumental, emotionally hollow, and basically artless. This is the danger of any rule-making in art -- to assume what worked in what situation will work flawlessly in another situation and produce similar results.


For instance, players don't always flock toward light.

Thief 1, a first person stealth game about hiding in shadows, makes you afraid of light. Here, light makes you vulnerable to being spotted by hostile NPCs -- it doesn't just signify a hazard, it is also a hazard in itself. Every step toward a light source is a risk. Much of the gameplay in Thief consists of huddling in darkness, anxiously watching the well-lit doorway from a safe distance, wondering if there's a way for you to go around and avoid that lit area entirely. In this game, we gravitate toward shadows instead.

It makes sense that lighting in stealth games, or more broadly, games about avoiding direct conflict and confrontation, would operate very differently from games about fighting and gun battles. If you want to design light for function, you should be aware of what that function actually is.

from "Thief 1's Assassins and environmental storytelling."
Also, bad readability isn't always bad.

In the level "Assassins" from Thief 1, Looking Glass Studios used a raised blind corner on purpose to force you to hang back and rely more on the sound of NPC footsteps. The point of this setpiece was to be visually unreadable, and so make you panic about lingering too far behind the NPCs you're supposed to follow. Instead of following a breadcrumb trail of random trash fires, or red cage lights, or (ugh) bl-orange spotlights, we are instead following an invisible mental abstraction and all this fucking light is really unhelpful.

This is one of the most beautiful moments of that level, and it relies on purposeful, nearly transcendent confusion and uncertainty. If games like challenge so much, why not elevate perceptual challenges?

from "Dark Past, part 4: a valence theory of level design"
Before designer Donald Norman co-opted it, the concept of an "affordance" came from ecological psychology, where James Gibson defined it as "what [an environment] offers an animal, either for good or ill." Here, an affordance is a relationship that depends heavily on context, it is not a matter of internalizing supposed universal laws of good design, as several well-meaning but flawed design bibles might have you believe. For more on this ecological psychology approach to design and affordance, especially as it pertains to games, see Jonas Linderoth's 2011 DIGRA paper, "Beyond the digital divide: An ecological approach to gameplay"

Formal approaches to light help us think about the way we use light, but remember that form does NOT follow function. Rather, form follows worldview; much of the orthodoxy around game aesthetics presumes a certain function, certain player, and a certain type of game. That's why part 1 of this series started conceptually -- if you lose sight of what your thing is to different people, then even all the blorange exit spotlights in the world won't save you.

NEXT TIME: part 3, on three-point lighting and why it kind of sucks for 3D games.