You are here: Shading and Lighting > Baking Workflow

Baking Workflow

Baking is the process used to pre-compute texture and lighting information. The result is often used for real-time applications (such a for games) or for exporting models into other software packages with complex shading intact, or simply as a way to eliminate rendering overhead in elaborate scenes. In this way shaders and lighting are computed by the Modo rendering engine and baked directly into an image that maps perfectly to an existing UV texture.

Perspective Projection

Perspective Projection

Perspective Projection

Hi-res Geometry

Lo-res Geometry

Lo-res Baked Result

Depending on what your intended purpose is, there are a couple of methods for baking images. If your intent is to simply merge (flatten) multiple Shader Tree layers, then all that is needed is an image map added to the Shader Tree set to the appropriate Effect type before baking.

When baking maps such as Displacement and Normal maps, two layers of geometry are necessary, typically one is the high resolution model comprised of all the details of the final model, and a second low resolution model that approximates the shape of the high resolution model serving as the baking target. The low resolution geometry requires a proper UV map with a unique name (unique from any UV maps assigned to the high-res version). Additionally, you need to make sure the applicable layers are selected in the item list, and that the appropriate UV map is also selected. When Baking to Textures, suitable image maps must be placed and selected in the Shader Tree - don't worry, it only sounds complicated, each set-up is detailed below.

For information regarding adding layers and setting their Layer Effects, please see Shader Tree. All baking commands are invoked from the menu bar within the Render menu.

Bake to Render Outputs

The command Bake to Render Outputs allows you to use a UV map from a surface to generate a rendered image that can be applied back to the surface as a texture map. Utilizing the functionality of the Shader Tree's Render Outputs, this allows the baking of Ambient Occlusion specific texture maps, Diffuse Coefficient maps, or even baking a Final Color map that fully computes all surfacing and shading of the target item. Once rendered, images can be saved to disk from the Render Display viewport, then imported and applied back to the geometry.

Before baking, it is important to select the target item in the Items list or 3D Viewport and to select the target UV map in the Vertex Maps Lists viewport. In the Shader Tree, render baking uses the settings from the Render Item to determine bake quality and Frame Size settings. Additionally, an offset amount is applied to the final pixels to reduce, or eliminate, possible seams at UV borders edges. The border offset amount is calculated by an Alpha channel that must be rendered concurrently with the main render output. The amount of the border offset is determined by the Bake UV Border Size setting in the Preferences.

In a default scene, the Render Output is set to Final Color, and you can right-click on the effect type in the Effects column of the Shader Tree and define an alternate render output style. Once the target items are selected, invoking the command Render > Bake to Render Outputs renders all active Render Outputs simultaneously.

Bake from Object to Render Outputs

The Bake from Object to Render Outputs command is similar to the Bake to Render Outputs command above, however it allows the additional ability to generate its results using an alternate mesh layer. It is essentially transferring the surfacing from one object to another.

Typically, in this setup one layer is a detailed, high resolution mesh and the target baking mesh layer is a lower resolution mesh, approximating the overall shape of the high resolution layer. This is often used in games, where the detailed surfacing from the high-res asset is applied to the low-res assets to give the overall visual impression of higher resolution in the final model. Once rendered, images can be saved out from the Render Display viewport, then imported and applied to the target geometry.

Baking from an object requires a background mesh layer (visible in the Items list, but not selected) and a foreground mesh layer (selected and visible). The background layer is typically the high resolution model layer to extract the geometrical, shading, and lighting information from and the foreground layer would be the low resolution model layer with a UV map to apply those baked maps to.

In the Shader Tree, render baking uses the settings from the Render Item to determine bake quality and Frame Size settings. With the Foreground and Background layers properly referenced, select the uniquely named UV map in the Lists viewport and select the command Render > Bake from Object to Render Outputs, opening a dialog where you define an offset Distance that should encompass all surface differences between the two mesh layers. Pressing OK renders all active Render Outputs simultaneously.

WARNING:  When baking from a background object to a foreground object, both object layers must have unique UV map names. Collisions occur if the default Texture name is present on both layers, causing the bake to fail or report errors.

Bake to Selected Texture

The command Bake to Selected Texture can be found in the menu bar under Render > Bake to Selected Texture, but is more commonly used from the Shader Tree directly, using the right-click contextual menu (opened by clicking on the target layer) where it is called Bake to Texture.

This command offers the ability to generate a bitmap texture of one or more Shader Tree texture layers, when all layers share the same Effect type. The common uses for the function are to convert a procedural texture layers to a bitmap for displacement freezing, or to combine complex, multiple Shader Tree layers into a single layer. It can also be used to pre-compute render intensive effects, such as occlusion, saving render time and eliminating any frame to frame variance that may occur.

Bake to Selected Texture require that you first define a new Image Map layer in the Shader Tree. During this process, the file save location is defined, as well as the Resolution and Bit Depth. For information on creating Image Maps, please see Add Images.

The Texture Locator settings are used to determined the appropriate UV map for baking, so make sure the image is applied appropriately. The position of the layer within the Shader Tree is important as well, because only layers below the target are evaluated for baking. Once the Effect has been defined for the layer, it is also necessary to disable the layers visibility (by toggling the eye column) to ensure the target baking layer itself isn't evaluated as part of the bake. Then right-click on the layer, opening the contextual menu and selecting the command Bake to Texture. Once generated, the image needs to be saved using the menu bar command File > Save Image.

Bake from Object to Selected Texture

The command Bake from Object to Selected Texture can be used to generate two specific types of texture maps using the foreground and background mesh layer functionality described in the Bake from Object to Render Outputs section. Specifically, the function is used to generate Displacement and Normal maps. A Displacement map is a grayscale image that represent the difference in position between a low-resolution foreground mesh and a high-resolution background mesh, a Normal map uses color to represent the difference in the surfaces Normal facing direction. Both maps, once generated, can be applied back to the lower resolution geometry to give the impression of much greater resolution.

Bake from Object to Selected Texture first requires a background mesh layer (visible in the Items list, but not selected) and a foreground mesh layer (selected and visible). The background layer is typically the high resolution model layer to extract the Displacement or Normal information from, and the foreground layer is the representative low resolution model layer with a UV map to apply those baked maps to (and a morph map offset from the surface when using the Cage option).

In the Shader Tree, you also need an appropriate target bitmap texture layer with the proper Effect defined for the intended purpose (either as Displacement or Normal) applied to the foreground mesh. The associated Texture Locator settings are used to determined the appropriate UV map for baking, so make sure the image is applied correctly. You also need to disable the texture layer's visibility (by toggling the eye column) to ensure the target baking layer itself isn't evaluated as part of the bake. Then right-click on the layer, opening the contextual menu, and select the command Bake from Object to Selected Texture to display a dialog box.

Bake 2 Popup

In this panel, define the Cage Vertex Map or a Distance value; these represent the offset distance away from the limit surface. The Cage setting is used when baking Normal maps exclusively; with it you can define a Morph Vertex Map (the Cage) for the surface normal evaluation. This Cage is a specially created Morph Map on the baking geometry, where the morph surface is typically offset from the limit surface and represents the ray distance using the difference between the morph position and the undeformed position of the surface. When you specify a Cage, the Distance value should remain at 0 (zero).

When no Cage is specified, the Distance option can be used with either Displacement baking or Normal map creation and represents the maximum ray travel amount, both positive and negative, from the baking surface and should be set to encompass all surface deviations between the two surfaces.

NOTE:  Black regions in the bake result represent areas beyond the defined Distance. You can increase the Distance to eliminate them, but setting the value too high can reduce accuracy and may introduce errors, depending on the geometry.

Press OK to initiate the bake. Once generated, save the image the menu bar command File > Save Image.

NOTE:  Make sure that the Normal Map layer in the Shader Tree is not in the same mask as the item you are trying to bake from.

TIP:  Depending on the type of geometry, and the resolution of the baked image, UV border seams may be visible. These can be eliminated using the Bake UV Border Size option in System > Preferences, listed under Display > Rendering. In order to take advantage of this functionality, you must have an active Alpha Render Output as well, because Modo uses the information from the alpha to compute the border offset.

Bake Geometry Cache

Modo has multiple features that work by way of virtual geometry. Virtual geometry describes geometry in the scene that you interact with, but is only a representation of the actual geometry used to render. Good examples of virtual geometry are Subdivision Surface models, Displacement, Render Curves, and Fur.

Selecting RenderRender, or pressing F9, causes Modo to take the instructions for each feature and convert them to real geometry for the final rendering. This procedurally generated geometry for rendering can be baked into real Mesh items in a scene, making it possible to apply complex procedural displacements or generate fur and bring it back to the scene as real geometry that can be directly edited or exported to other packages. Selecting Render > Bake Geometry Cache displays the following dialog.

Bake Geo Cache

Option

Description

Surfaces

When enabled, the Surface settings of the original object are cloned and added into new Material Groups assigned to the baked geometry.

Shaders

When enabled, the Shader settings per item of the original object are cloned and added to a Material Group assigned to the baked geometry.

Fur

When enabled, convert any Fur in the scene to geometry. If the Fur is set to Strips, it is converted to polygons. If the fur is set to Tubes it is converted to individual Curves, representing each individual fiber.

NOTE:  The Curves for Fur can be further converted to polygons using the 'Render Curves' command and invoking a second pass of the Bake command.)

Running the command converts all Mesh Item layers in the scene, as well as Instances and the procedural effects Fur, Render Curves, and Replicators. Mesh Density is based on the settings for each individual item (exactly as it would tessellate for rendering). The resulting meshes are a separate mesh layer for each surface or effect in the scene.

NOTE:  Special procedural effects, such as Volumes, Blobs, Render Booleans, or Sprites cannot be converted to meshes.

TIP:  Depending on the complexity of the scene, it is possible to create scenes of immense size using the Bake Geometry Cache command. The render statistics panel gives a readout of the total scene geometry during each render as a useful guideline.
If you only want to modify a single element, you can do so by saving individual mesh layers out by right-clicking on the layer in the Items list and selecting Save Selected, and then opening the resulting file and applying the Bake Geometry Cache command.