Baking Lighting Data Into Your Unity Scene

Often when working on Unity projects, you will want to use “baked” lighting, for any number of reasons. This is how.

Today’s Objective: Show you how you can use baked lighting data to improve the lighting and visuals in your Unity scene easily.

Baked Lighting:

“Baked” Lighting, as opposed to “Realtime” Lighting, is a lighting method in which the shadows, Ambient Occlusion, and other lighting details of “Static” (non-moving) shadow-casting objects are “baked”, or combined with, the rendered textures of other objects in the scene.

Realtime lights cast shadows that update every frame to ensure accuracy, generally because Realtime lights are used on moving objects.

Baked lights cast shadows once, and those shadows are then combined with whatever surface they hit, because Baked lights do not move and so, their shadows shouldn’t either.

When using Baked Lights, remember to bake the lighting data regularly, to update scene changes.

There are exceptions to Baked light shadows not moving, such as when a character walks in front of a baked light, they should be lit/shadowed accordingly. In these cases, another Unity feature is used called “Light Probes”, but that is a topic I cover in another post.

How to bake lighting:

The process is very simple.

1.

Ensure you have at least one source of baked light in the scene. This could be an actual light set to “Baked” mode, or it could be an emissive material which emits light.

2.

Make sure all the non-moving objects that you want to be affected by baked light are set to “Static/Contribute GI”. If this isn’t enabled, no baked lighting will affect the object, unless using Light Probes which I will discuss more later.

3.

Open the Lighting window by going to “Window/Rendering/Lighting”.

4.

Set the Lightmapper option to “Progressive GPU (Preview)” (or whatever GPU option is available on future versions), then click “Generate Lighting” on the Lighting window to start the baking process.

By choosing Progressive GPU, you will significantly speed up the time required to fully bake a scene (possibly by 90% or more!), so much so that it is rarely worth using the CPU. However, this does depend on your GPU hardware.
Ideally, bakes should not take more than 5 minutes for most projects when using GPU, and if it is higher, you should check what scene elements you can optimise to improve the scene.

During the baking process, your computer may slow down considerably depending on your hardware, as Unity will use a lot of processing resources in order to quickly bake the scene.

After the baking process completes…

you should notice that a new folder has been created for you at the location your scene is saved:

This folder should now contain a collection of files which are the baked lighting data created just now, and saved to lightmaps for scene reference.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.