Skip to main content

๐Ÿ’ก Lesson 8.1: URP Lighting: Real-time & Baked

A scene lit well looks intentional; a scene lit badly looks like a prototype. In this lesson you'll meet URP's four light types, the three light Modes that decide whether lighting is computed every frame or precomputed once, the Lit shader that receives all that light, and the single most important budgeting decision in graphics: bake it or run it real-time?

๐ŸŽฏ Learning Objectives

By the end of this lesson, you will be able to:

  • Identify the four light types โ€” Directional, Point, Spot, Area โ€” and when each fits
  • Read a URP Light component and set Type, Mode, Intensity, and Shadow Type
  • Explain the difference between Realtime, Mixed, and Baked light modes
  • Describe how the URP Lit shader turns light + material into a shaded pixel
  • Set up ambient / skybox lighting so shadows are never pure black
  • Make a reasoned bake-vs-realtime decision for any object in your scene

Estimated Time: 40 minutes  ยท  Prerequisite: Lesson 7.4 (Pickups & Equipping) and a working URP scene

In This Lesson

Why Lighting Is a Budget

Every light in a scene is a promise your GPU has to keep, sixty times a second. A real-time light recomputes how it strikes every surface, every frame โ€” cheap for one directional sun, expensive for twenty flickering torches. That's the tension the whole rest of this module dances around: how good can it look versus how much can we afford.

Unity gives you two ways to pay. You can pay at runtime (real-time lighting โ€” flexible, dynamic, costs frame time) or you can pay once, ahead of time (baked lighting โ€” the result is precomputed into a texture, nearly free at runtime, but frozen). Most real games mix both. Learning to choose is the skill.

๐Ÿ“– Definition

Global Illumination (GI): the indirect light that bounces off surfaces โ€” the reason a red wall tints a nearby white floor pink. Real-time lights alone only give you direct light; realistic bounce is what baking buys you cheaply.

The Four Light Types

Add a light with GameObject โ–ธ Light โ–ธ โ€ฆ. Each type describes a different real-world source:

  • Directional โ€” parallel rays from infinitely far away, like the sun. Position doesn't matter, only rotation. Every new scene ships with one. Use it as your key light / sun.
  • Point โ€” radiates in all directions from a single point, fading with distance (the Range). Think a bare bulb, a torch, a campfire.
  • Spot โ€” a cone of light from a point in one direction, with a Spot Angle. Think a flashlight, a stage spotlight, headlights.
  • Area โ€” light emitted from a rectangle or disc surface, giving soft, wrapping illumination. Area lights are Baked-only โ€” they don't work in real-time โ€” so they're reserved for lightmapping.

โœ… Pro Tip

Start every scene with one Directional light as the "sun," then add Point/Spot lights only where the art actually needs a pool of light. A scene lit by three deliberate lights almost always beats one lit by fifteen accidental ones.

Reading the Light Component

Select a light and its Light component appears in the Inspector. In URP this is where you set the type, how it's computed, how bright it is, and whether it casts shadows. Here is that component, rebuilt exactly as it appears for a Point light set to Mixed mode:

The URP Light component in the Inspector A recreation of Unity's Light component Inspector. Fields shown top to bottom: Type set to Point, Mode set to Mixed, a Light Appearance colour swatch, Intensity 1.5, Indirect Multiplier 1, Range 10, and a Shadow Type dropdown set to Soft Shadows with a Strength slider. โ˜€ Light Type Point Mode Mixed Emission Light Appearance Color Color Intensity 1.5 Indirect Multiplier 1 Shape Range 10 Shadows Shadow Type Soft Shadows Strength 0.8 Near Plane 0.2 Rendering Render Mode Auto Culling Mask Everything
Figure 1: The URP Light component (faithfully recreated). Type picks the source shape; Mode decides realtime vs baked; Intensity and Color set brightness and tint; Range only appears for Point/Spot; Shadow Type chooses hard, soft, or none.
๐Ÿ’ก Why a diagram and not a screenshot? The Inspector is drawn with Unity's UI toolkit, which doesn't screenshot cleanly. As in Lesson 1.2, these panels are rebuilt precisely from the real component โ€” every field and value matches what you'll see.

Light Mode: Realtime, Mixed, Baked

The Mode dropdown is the field that decides your whole budget. It has three values:

  • Realtime โ€” recomputed every frame. Can move, change colour, turn on/off at runtime. Casts real-time shadows on everything. Costs frame time. Use for the sun, a swinging lamp, a muzzle flash.
  • Baked โ€” computed once by the lightmapper and stored in a texture. Free at runtime, includes gorgeous indirect bounce, but cannot move or change and only affects objects marked Static. Use for fixed environment lights.
  • Mixed โ€” the best of both. It bakes indirect light onto static geometry and still casts real-time direct shadows for moving objects. This is the usual choice for a scene's main sun.

โš ๏ธ Baked light ignores moving objects

A purely Baked light will not light your player character or any spawned enemy โ€” they aren't in the lightmap. Moving objects get baked light only through Light Probes (next lesson). If your character walks into a baked room and stays dark, this is almost always why.

Here's how the three modes split the work:

flowchart TD L["Light Mode?"] --> R["Realtime"] L --> M["Mixed"] L --> B["Baked"] R --> R1["Direct + shadows
computed every frame"] R --> R2["Affects static AND
moving objects"] M --> M1["Indirect bounce baked
onto static geometry"] M --> M2["Direct shadows still
real-time for movers"] B --> B1["Everything precomputed
into a lightmap"] B --> B2["Only affects Static;
movers need Light Probes"]

Figure 2: The three light modes and what each one actually computes.

The URP Lit Shader

Light doesn't show up on its own โ€” it has to land on a material, and the material's shader decides how that light becomes colour. In URP, the default workhorse is the Universal Render Pipeline / Lit shader, a physically based (PBR) shader. When you create a material (Assets โ–ธ Create โ–ธ Material) in a URP project, it uses Lit automatically.

Its key inputs:

  • Base Map โ€” the albedo (surface colour / texture).
  • Metallic & Smoothness โ€” how metal-like and how glossy the surface is. These drive how sharply it reflects light.
  • Normal Map โ€” fakes surface bumps by perturbing how light reflects.
  • Emission โ€” makes the surface emit light (glow). With baking on, emissive materials can even contribute GI.

Conceptually, for every pixel the Lit shader combines the surface properties above with the incoming light to produce the final shaded colour:

// Pseudocode for what the Lit shader does per pixel (not code you write)
finalColor = BaseColor
           * (DirectLight  + IndirectLight/GI)   // how much light hits it
           + Specular(Metallic, Smoothness)       // shiny highlights
           + Emission;                            // its own glow

You rarely touch the Lit shader's math directly โ€” but in Lesson 8.3 you'll build your own shader in Shader Graph, and knowing that a shader's job is "turn surface + light into a pixel colour" is exactly the mental model you'll need.

๐Ÿ“– Definition

Shader: a small program that runs on the GPU for every vertex and every pixel of a mesh, deciding its final on-screen colour. A material is an instance of a shader with specific values plugged in (this texture, this colour, this smoothness).

โœ… Pro Tip

If a URP material shows up bright magenta, its shader isn't URP-compatible (often a Built-in Render Pipeline shader dragged in from an old asset). Fix it with Edit โ–ธ Rendering โ–ธ Materials โ–ธ Convert Selected Built-in Materials to URP, or switch its shader to Universal Render Pipeline / Lit.

Ambient & Skybox Light

Notice that in a normal scene the shadowed side of an object isn't pure black โ€” it's a dim version of the sky. That fill comes from ambient lighting, configured in Window โ–ธ Rendering โ–ธ Lighting โ–ธ Environment.

The default Ambient Source is Skybox: Unity samples the skybox material and uses it as soft light coming from all directions. That's why a scene with the default blue-sky skybox has slightly blue shadows. You can also set a flat ambient Color or a three-band Gradient (sky / equator / ground) for stylized looks.

The Skybox Material field (also under Environment) sets what the camera sees in the distance and, by extension, the ambient tint. Swap it for a sunset skybox and your whole scene warms up for free.

โš ๏ธ "My shadows are jet black"

If shadowed surfaces read as pure black, your Ambient Source is probably set to a black Color, or Ambient Intensity is 0. Bump the intensity or switch the source back to Skybox. Some ambient fill is what makes a scene feel like it has air in it.

Bake or Real-time?

Here's the decision that separates a smooth-running scene from a stuttering one. Ask two questions about each light: does it need to move or change? and what does it light?

flowchart TD Start["A light in your scene"] --> Q1{"Does it move,
flicker, or toggle
at runtime?"} Q1 -- "Yes" --> RT["Realtime
(sun, torch, muzzle flash)"] Q1 -- "No" --> Q2{"Does it light any
moving objects
(player, enemies)?"} Q2 -- "Yes, and it's the sun" --> MX["Mixed
(baked bounce + realtime shadows)"] Q2 -- "No, static scenery only" --> BK["Baked
(free, rich indirect GI)"]

Figure 3: A practical realtime-vs-baked decision flow for any light.

Rules of thumb that hold up in production:

  • The sun: almost always Mixed โ€” you want baked bounce on the world but crisp real-time shadows under your moving character.
  • Static decorative lights (wall sconces, ceiling lights in a fixed room): Baked. They're the cheapest beautiful light you'll ever get.
  • Anything dynamic (a lamp you can shoot out, a car headlight, a spell effect): Realtime.
  • Keep the number of real-time lights hitting any one object small. On mobile especially, per-pixel real-time lights are the classic frame-rate killer.
๐Ÿ’ก The mixed strategy in one line: bake the world, run the sun, probe the movers. That single sentence describes how most 3D games you've played are lit โ€” and it's exactly what Lesson 8.2 sets up.

Hands-on Challenge

๐Ÿ‹๏ธ Exercise 1: Light a small room three ways

Objective: feel the difference between the three modes.

  1. Make a simple room: a floor plane and a few cube walls. Add a Point light in the middle.
  2. Set the Point light's Mode to Realtime, press Play, and drop a Sphere that rolls through โ€” note it's lit.
  3. Switch the light to Baked, mark the walls/floor as Static (top-right of the Inspector), and note that the rolling sphere goes dark.
  4. Switch it to Mixed and observe the walls keep their baked look while the sphere is lit again (once probes exist โ€” foreshadowing 8.2).
๐Ÿ’ก Hint: baked light isn't showing at all

Baked lighting only appears after a bake. For now, in the Lighting window turn on Auto Generate (or click Generate Lighting) and make sure the walls are marked Static with Contribute GI on. Full baking is the whole of the next lesson โ€” a rough result here is fine.

โœ… Success check

You can articulate, out loud, why the sphere is lit under Realtime and Mixed but dark under pure Baked โ€” because baked light lives in a lightmap that moving objects aren't part of.

๐Ÿ‹๏ธ Exercise 2: Warm the scene from the sky

Open Window โ–ธ Rendering โ–ธ Lighting โ–ธ Environment. Change the Ambient Source to a warm Color, then back to Skybox, and finally to a Gradient with a warm sky and cool ground. Watch how the shadowed sides of your cubes change tint each time. Decide which fits a sunset mood.

๐ŸŽฏ Quick Quiz

Question 1: Which light type ignores its position entirely and cares only about rotation?

Question 2: Your moving player character walks into a room lit only by a Baked light and turns completely dark. Why?

Question 3: For a scene's main sun that must cast crisp shadows under a running character and give the static world nice bounced light, which Mode is the standard choice?

Summary

๐ŸŽ‰ Key Takeaways

  • Four light types: Directional (sun), Point (bulb), Spot (cone), Area (soft, baked-only).
  • The Light Mode is the budget lever: Realtime (per-frame, dynamic), Baked (precomputed, free, static-only), Mixed (baked bounce + real-time shadows).
  • The URP Lit shader turns material properties (Base, Metallic, Smoothness, Normal, Emission) plus incoming light into a shaded pixel.
  • Ambient / skybox light fills shadows so they're never pure black; set it under Lighting โ–ธ Environment.
  • Decide per light: does it move? does it light movers? Bake the world, run the sun, probe the movers.

๐Ÿš€ What's Next?

You now know which lights to bake โ€” next you'll actually bake them. In Lesson 8.2: Lightmapping & Light Probes we mark objects Static, drive the Lighting window, generate lightmaps, and drop Light Probes so your moving characters finally pick up all that baked light.

๐Ÿ’ก You can light a scene on purpose now

Type sets the source, Mode sets the budget, the Lit shader receives it, ambient fills the dark. Every lighting decision from here is a variation on those four choices.