41
\$\begingroup\$

What does it mean to bake lightmap ? I heard this in Unity3d, and again found this LightUp plugin for sketchup that bakes lightmap.

From what I observe, the lightmap baked gives the 3d object a much more realistic feel. Is the purpose of baking light on object to give that cg animation look you see on pre-rendered animations?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Also, anytime you bake something, whether its physics, lighting or anything else. It means you have set up something that will take a long time to render/process in real time, or you want it to play the same way each time, so you only do it once, and save the results for later use, and because all of thecalculations are done, displaying what has been baked is fast, and always the same across all playthroughs. \$\endgroup\$ Mar 20, 2011 at 18:21
  • \$\begingroup\$ AttackingHobo, that is a great way to put it. I understand it now. But curious, how would physics be baked? Does Luxrender produce photorealistic renders because they can calculate the physics of the light? \$\endgroup\$ Mar 20, 2011 at 23:40
  • 1
    \$\begingroup\$ Physics can be baked for complex scenes by once simulating and storing all the objects positions, and rotations etc for every timestep. Then instead of recalculating all the values again live, they are just played back from the stored values. \$\endgroup\$ Mar 21, 2011 at 3:02

1 Answer 1

62
\$\begingroup\$

When you have a static (non-moving) light in a game, you have two options for rendering this light. You could render it the same as a dynamic light; that is, feed it through the shader pipeline which will calculate its effect on everything around it, every frame, on its way to the screen. This is obviously pretty expensive. Or, an editor can bake the light into the scene.

What I've always thought of baking was perhaps a more simple version: basically the editor just takes the textures of everything around the light, calculates the effect of the light on those textures (brightens them, perhaps colors them, shadows, etc.), and saves them as replacement textures to use. So all the textures around the "light" look like they have a light cast on them, but at runtime there actually isn't a light from a calculation standpoint; it's an optical illusion, essentially.

Unity, however, seems to be generating a lightmap. This is similar to the above notion, but the baked lighting is kept separately instead of modifying the underlying texture, and I assume a shader merges the two at runtime. This would have the advantage of keeping the advantage of tiled textures (i.e. low memory usage), since they wouldn't have the light baked right into them therefore they could remain tiled, and the shader would be very lightweight, especially compared to treating the light as dynamic.

A light obviously needs to be static for this to work; that is, you can't move it during gameplay, because the light has been baked into the textures. Also, any dynamic objects in the room (such as the player character) won't have the light shining on them so there needs to be some sort of exception, where the light is rendered for dynamic objects but not (re-)rendered on the static scenery.

\$\endgroup\$
3
  • 14
    \$\begingroup\$ And most of the time because the lighting is softish, the lightmap can be saved in lower resolution than the rest of the textures, still looks good, but renders faster, and takes less memory. \$\endgroup\$ Mar 20, 2011 at 9:03
  • \$\begingroup\$ +1, this is a really nice and extensive answer, thank you. :) \$\endgroup\$
    – Xeo
    Mar 20, 2011 at 14:52
  • \$\begingroup\$ So if you plan to add objects later in the scene, you shouldn't bake lights. Isn't capturing global illumination correctly one of the other goals as realtime engines like webgl uses rasterization instead of raytracing to light the scene? \$\endgroup\$
    – Ajay
    Mar 31, 2021 at 17:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .