Lesson 37 +10 XP

Shadows & Lightmapping

Shadows & Lightmapping

To make baked lighting work, Unity uses a process called Lightmapping.

Lightmapping Process

Lightmapping calculates how light rays bounce off static objects in your scene, baking the illumination into textures that are overlaid on top of scene geometry.

To enable lightmapping on an object:

  1. Select the GameObject (e.g. floors, walls, columns).
  2. In the Inspector, check the Static checkbox in the top-right (or specifically Contribute GI).
  3. Set your lights to Baked or Mixed mode.

The Lighting Window

Configure baking settings under Window -> Rendering -> Lighting:

  • Click New Lighting Settings to create a settings asset.
  • Select a Lightmapper (e.g. Progressive GPU for fast bakes using your graphics card).
  • Click Generate Lighting in the bottom-right to start the bake.

Shadows settings

For real-time lights, you can adjust shadow settings:

  • Shadow Type:
  • No Shadows: No shadows cast (fastest).
  • Hard Shadows: Sharp, pixelated shadow edges.
  • Soft Shadows: Blurry, realistic shadow edges (more expensive).
  • Shadow Resolution: High resolutions produce sharper shadows but consume more GPU memory.

TL;DR

  • Lightmapping bakes light data into textures for static objects.
  • Objects must be marked Static or Contribute GI to be included in light bakes.
  • Control light bakes from the Lighting window.
  • Real-time shadow types include Hard (sharp) and Soft (realistic).