Table Of Contents
Introduction
Baking allows the rendering of AOVs onto texture maps using a specific UV channel. This can be useful in a variety of scenarios. One of these is "light mapping" where the user renders the diffuse lighting received by a particular object onto a texture and then re-uses the texture during animation rendering instead of having to compute the (potentially slow) diffuse lighting on each frame.
Baking Pros
- Can help increase rendering performance
- Textures can be tweaked by an external image editing program or script for quality or look reasons.
Baking Cons
- Involves some setup effort
- The quality of the baked results depends on the resolution of the texture. Extremely high resolution textures can take a long time to compute.
- When used for light mapping, changes to the lighting due to animated geometry and lights won't be reflected on the baked texture
The image below shows a simple light-mapped scene containing a couple of objects. Both the teapot and the floor are using a 512x512 baked TotalDiffuseLightingRaw AOV image.
|
|
---|---|
Original scene used to generate the baked lightmap textures. Rendered in 11 seconds. |
Modified shader graphs to use the lightmap textures. Rendered in 2 seconds. |
The floor's baked 512x512 image. Please note that the image appears darker because it's shown in linear space.
Using Baking
Generating baked images involves a few main steps:
- Creating an appropriate unwrapped UV channel that will be used by baking
- Creating and configuring one or more BakeSets
- Setting up the AOVs
- Executing the bake
Redshift requires an appropriate UV channel to perform baking. In most 3d apps, there will be an "Automatic UV" or "Unwrap UV" option which will generate an appropriate UV layout for baking. Two important requirements for a baking UV channel is that the UVs should fit in the 0->1 UV range and the different parts of the object should not be overlapping in UV space. The unwrapped UVs generated by most 3d apps already satisfy these criteria.
Creating Bake Sets
Once we have our UV channel, one or more bake sets should be created and configured. Bake sets contain baking settings that can be applied to single object or a group of objects. Each object in the group will get its own baked image.
Finally, Redshift's AOV settings have to be configured to specify which AOVs should be baked as well. For example, if we wanted to bake diffuse lightmaps, we should use the "TotalDiffuseLightingRaw" AOV.
To create a BakeSet, you can select one or more scene objects and then, from the Redshift menu, click Redshift->Tools->Texture Baking->Create BakeSet from Selection.
Create BakeSet from Selection
You can also create a new empty BakeSet from the Create menu.
Create new Redshift BakeSet
Then a bake set will be created with the following options:
BakeSet Parameters
Width
Specifies the horizontal output resolution of the baked textures.
Height
Specifies the vertical output resolution of the baked textures.
UV Source
Specify the UV channel name in the UV Source section that should be used for baking.
If left blank or if the specified UV channel name is not found, the BakeSet will export a texture for the default UV channel called "UVW."
Tiling
Select the UDIM tiling convention used for the baked textures (Only applicable if using UDIMs)
Objects
Control which objects are included in the BakeSet. One image will be rendered for each object assigned to a BakeSet.
Bake button
Quickly execute a new Bake for the selected BakeSet from the bottom button.
AOV Setup for Baking
Redshift's baking capabilities rely on the AOV system for rendering out the baked images. Setting up the AOVs for baking is identical to setting them up for a render (camera-based) render.
You can find general information on AOVs here and a short AOV tutorial here.
We advise that users set up a separate render pass/layer (depending on their 3d app's capabilities) to configure the AOVs used for baking, as these might differ to the AOVs required by your main render.
When configuring AOVs for baking, the user has to make a choice regarding the baked image filenames. Since all bake sets rely on the global AOV options (which include filenames), how can this work when the scene contains multiple objects? I.e. how do we prevent the baking of all object in the scene from writing to the same image file?
This depends on the 3d app.
A baked texture file will automatically have the object name appended to their respective AOV's file name.
For example, say our scene contained an object called "red_sphere" and our AOV image's filename is normally:
Default_Pass_Redshift_TotalDiffuseLightingRaw.exr
Since Cinema 4D automatically appends the object name to the file name the final baked image filename will be:
Default_Pass_Redshift_TotalDiffuseLightingRaw_red_sphere.exr
Baking out AOV's requires rendering out with the Direct Output AOV type which can be enabled and managed in the Redshift AOV Manager as pictured below.
Executing Baking
To execute baking you either do it quickly by clicking the "Bake" button at the bottom of a BakeSet as pictured below:
Or intiate a new bake from the Redshift menu via Redshift > Tools > Texture Baking > Bake as pictured below.
At which point the Bake Textures panel will pop up with the following options:
Bake Textures Parameters
Options
Objects
Here you can select which BakeSets will take part in the the next bake.
- Selected BakeSets: Bakes all objects that are specified in the currently selected BakeSets.
- All BakeSets: Bakes all objects that are specified in all BakeSets in the scene.
Output Folder
Specifies the output path the baked texture files will be rendered to.
AOVS
Default Beauty
Specifies whether the default beauty render pass is output with the baked textures. When disabled only the Direct Output AOVs will be baked for each object.
Animation
Range
Specifies the frame range that will be baked for the objects in the BakeSet.
- Current Frame: Bakes textures for the current frame only.
- All Frames: Bakes textures for all frames in the scene.
- Manual: Bakes textures for the frame range specified manually with the Start Frame, End Frame and Frame Step parameters in the Bake Textures panel.
- Preview: Bakes textures for all frames in the current preview range.
Start Frame
Specifies the first frame when in Manual range mode.
End Frame
Specifies the last frame when baking in Manual range mode.
Frame Step
Specifies how often a frame is baked when baking in Manual range mode.
Examples:
- When set to 1, bake a texture for every frame in the frame range.
- When set to 2, bake a texture for every other frame in the frame range.
- When set to 4, bake a texture for every 4th frame in the frame range.
Limitations
The baking system currently doesn't work with the following rendering features:
- Tessellation and displacement. If the baked geometry is tessellated or displaced, visual artifacts will appear on the baked image.
- Point-based techniques such as point-based subsurface scattering, irradiance cache and the irradiance point cloud don't work in conjunction with baked renders. Photons (and, subsequently, caustics) do work.
- Projection mapping is not currently supported.
- high-res to low-res texture baking is not currently supported.
Using Baking for Lightmapping
Here are a few quick steps to generate baked lightmaps similar to the one shown above:
- Create a scene like the one shown above, with two objects
- Create unwrapped UV channels for both objects. Ensure the UV channels are named consistently.
- Select both objects and assign them a bake set on both objects. Ensure the bake set is using the correct UV channel
- Add a "TotalDiffuseLightingRaw" AOV to your scene
- Depending on your 3d app, perform the baking filename steps explained above
- Execute the bake
- Then edit the shader graph as follows:
- Remove any diffuse lighting by making the diffuse color black or the diffuse weight zero
- Connect the baked images to the incandescent (or emission) color ports of your shader and set incandescent (or emission) weight to the same value as your original diffuse weight
- Ensure that, if the image was saved out as an EXR, the gamma in the texture node is set to linear
- The above steps essentially replace the 'real' diffuse lighting with baked diffuse lighting
- If the diffuse port was textured, use a multiplication shader node to multiply the texture with the lightmap before connecting it to the incandescent port (or emission).