Baking lightmaps and ambient occlusion maps in Blender
For this scenario, we’re going to revisit the example from Chapter 10, where we used a lightmap from Blender. This lightmap provides good-looking lighting without having to calculate it in real time in Three.js. To do this with Blender, we’re going to take the following steps:
- Set up a simple scene in Blender with a couple of models.
- Set up the lighting and the models in Blender.
- Bake the lighting to textures in Blender.
- Export the scene.
- Render everything in Three.js.
In the following sections, we will discuss each step in detail.
Setting up a scene in Blender
For this example, we’ll create a simple scene in which we’ll bake in some lighting. Start a new project, delete the default cube by selecting it and hitting x, and do the same for the default light. Use Add | Mesh | Plane to add a simple 2D plane to the scene. Press Tab to go to Edit Mode, select three vertices...