Overview
Lighting plays an extremely important role in 3D scene atmosphere, realism, and guiding player attention. Even with the same models and textures, lighting dramatically changes scene impressions. Unity includes a powerful lighting system enabling diverse expressions from realistic scenes to stylized toon aesthetics.
Unity's lighting broadly divides into Realtime Lighting and Baked Lighting:
- Realtime: Calculates light and shadow every frame during gameplay. Dynamic objects (characters, etc.) can cast dynamic shadows, and light sources can move, but computational cost is high.
- Baked: Calculates all light and shadow for static objects before runtime (during development), saving results to special textures called Lightmaps. Runtime cost is very low, but can't respond to dynamic changes.
The key to efficient, beautiful scenes is wisely combining these two approaches.
This article covers Unity's basic light types and fundamental concepts for illuminating scenes.
Main Light Types
Unity provides various light types accessible via GameObject > Light menu.
Directional Light
Simulates infinitely distant light sources like the sun or moon. Casts parallel light from one direction across the entire scene. Position doesn't matter—only rotation (angle) determines light direction. Typically, one Directional Light serves as the main light source for outdoor scenes.
Point Light
Emits light in all directions from a single point, like a light bulb. Light attenuates with distance. Used for representing localized light sources like bare bulbs, lamps, or explosion flashes.
Spot Light
Projects light in a cone from a single point, like a flashlight or stage spotlight. Adjustable angle (Spot Angle) and range (Range). Effective for highlighting specific objects or guiding player attention.
Area Light
Emits light from a rectangular surface. Suitable for simulating area light sources like windows or ceiling fluorescents. Realtime processing is very expensive, so typically used as bake-only lights. Produces more natural, soft shadows and reflections.
Global Illumination (GI)
In the real world, light doesn't just hit objects directly from sources—it bounces off surfaces and indirectly illuminates other objects. Global Illumination (GI) is the technology that simulates this indirect lighting.
GI prevents shadowed areas receiving no direct light from becoming completely black, giving scenes a more natural, richer appearance.
Unity supports both realtime and baked GI. Indirect light for static objects is baked into lightmaps, while dynamic objects receive indirect lighting influence through Light Probes.
Shadows
Shadows are crucial for giving scenes depth and dimensionality. Unity's light Inspector lets you choose whether to generate shadows (Shadow Type):
- No Shadows: No shadows generated. Best performance.
- Hard Shadows: Sharp-edged shadows. Relatively fast to compute.
- Soft Shadows: Blurred-edge, more realistic shadows. Most expensive computation, but higher visual quality.
The number and distance of realtime shadow-casting lights directly impacts performance. Balance quality and performance for your target platform via Quality Settings (Edit > Project Settings > Quality), adjusting shadow quality and draw distance.
Lighting Workflow
- Place main light sources: Start with a
Directional Light(for outdoors) or keyPoint Light/Spot Lightas the scene's primary light source. - Configure environment lighting: Open the Lighting window via
Window > Rendering > Lightingand set environment light (sky color, etc.) in theEnvironmenttab. This establishes the scene's overall brightness baseline. - Mark static objects: Objects that won't move during gameplay (terrain, buildings) should have the
Staticflag enabled in Inspector. This makes them eligible for light baking. - Set light modes: Choose each light's
ModefromRealtime,Baked, orMixed. Lights needing dynamic shadows useRealtime; lights only illuminating static objects useBaked. - Execute light baking: Press
Generate Lightingin the Lighting window to perform light baking. This generates lightmaps. - Place Light Probes: Add
Light Probe Groupobjects throughout the scene so dynamic characters naturally receive baked indirect lighting.
Summary
Lighting is a deep field, but mastering the basics significantly improves scene quality.
- Use appropriate light types (Directional, Point, Spot) for each role.
- Set non-moving objects to
Staticand bake lights for better performance. - Wisely combine realtime and baked lighting.
- Use Global Illumination (GI) for indirect lighting and enhanced realism.
- Shadows are expensive—balance quality and performance carefully.
Start by placing various lights in your scenes, experimenting with their effects, and exploring the rich expressions that light and shadow create.