Texture baking is a process in which scene lighting is "baked" into a texture map based on an object's UV texture coordinates. The resulting texture can then be mapped back onto the surface to create realistic lighting in a real-time rendering environment. This technique is frequently used in game engines and virtual reality for creating realistic environments.
In Octane, texture baking is implemented as a special type of camera known as a "Baking" camera, which, in contrast to to the thin lens and panoramic cameras, has one position and direction per sample. The way these are calculated depends on the input UV geometry and the actual geometry being baked.
For each sample, the camera calculates the geometry position and normal then generates a ray that points towards it, using the same direction as the normal, from a distance of the configured kernel’s ray epsilon. Once calculated, the ray is traced in the same way as it would usually do with other types of camera.
Mesh Requirements for Baking
In order for a mesh to be used for texture baking it should be setup to fulfill the following requirements:
- The mesh should contain at least one UV set. In the case of Alembic, up to 3 sets can be used.
- Overlapping UV's should be eliminated. Overlapping UV's occur when more than one mesh or mesh component share the same UV texture coordinates. Otherwise you may find artifacts due to overlapping geometry (figure 1).
Figure 1: The orange square highlights an area of overlapping UV texture coordinates.
Setting up a Texture Baking camera
Assuming you’ve already created a scene that contains geometry, lighting, material information, etc., the first step is to create a camera and set its Octane Camera Type to Baking camera (Figure 2). Typically users will duplicate the main rendering camera in the scene and then set the duplicate camera's Type to Baking.
Figure 2: Set the Octane Camera Type to Baking Camera.
Baking group ID
Specifies which baking group should be baked. By default all objects belong to the default baking group number 1.
If checked, the camera directions are flipped.
Use Baking position
If a baking position is used, camera rays will be traced from the specified coordinates in world space instead of using the mesh surface as reference. This is useful when baking position-dependent artifacts such as the ones produced by glossy or specular materials.
UV box min/UV box size
Specifies the area that the baking camera takes into account. This can be used to pan and zoom in and out of the camera in case your UV geometry is not within the [0,0]->[1,1] region.
The next step is to set the Baking Group Id of the objects to match the Baking group ID of the Baking camera (figure 3). For example if you wanted to bake the lighting of a room into the textures for the walls (provided the walls do not have overlapping UVs) you would set the camera's Baking Group ID to 2 and the Baking Group ID of each of the walls to 2 as well. Then you can render either using May's batch rendering or the IPR window. Then if you wanted a separate texture for the floor you would set the Baking Group ID of the floor to 3 and the Baking Group Id of the camera to 3 as well and then render and so on until all the textures for the items in the room have been baked. Each time you bake a texture you would save out teh image and then use the image as part of a texture map for the object as part of a shading network. Any of the Octane Render Passes can be baked into a texture.
If you have high resolution geometry that shares the same UV texture layout as a low resolution version of the same geometry, texture baking can be a great way to create the look of high detail in low poly meshes.
Figure 3: Set the Baking Group ID of the object to match the Baking Group ID of the Baking camera.