From BlenderWiki

Jump to: navigation, search


Baking, in general, is the act of pre-computing something in order to speed up some other process later down the line. Rendering from scratch takes a lot of time depending on the options you choose. Therefore, Blender allows you to "bake" some parts of the render ahead of time, for select objects. Then, when you press Render, the entire scene is rendered much faster, since the colors of those objects do not have to be recomputed.

Render Baking

Mode: All Modes except Sculpt

Panel: Scene (F10) Render Context → Bake panel

Hotkey: CtrlAltB

Menu: Render → Bake Render Meshes

Description

The Bake tab in the Render buttons panel.

Render baking creates 2D bitmap images of a mesh object's rendered surface. These images can be re-mapped onto the object using the object's UV coordinates. Baking is done for each individual mesh, and can only be done if that mesh has been UV-unwrapped. While it takes time to set up and perform, it saves render time. If you are rendering a long animation, the time spent baking can be much less than time spent rendering out each frame of a long animation.

Use Render Bake in intensive light/shadow solutions, such as AO or soft shadows from area lights. If you bake AO for the main objects, you will not have to enable it for the full render, saving render time.

Use Full Render or Textures to create an image texture; baked procedural textures can be used as a starting point for further texture painting. Use Normals to make a low-resolution mesh look like a high-resolution mesh. To do that, UV-unwrap a high-resolution, finely sculpted mesh and bake its normals. Save that normal map, and Map To (material settings) the UV of a similarly unwrapped low-resolution mesh. The low-resolution mesh will look just like the high-resolution, but will have much fewer faces/polygons.

Advantages
Can significantly reduce render times
Texture painting made easier
Reduced polygon count
Repeated renders are made faster, multiplying the time savings
Disadvantages
Object must be UV-unwrapped.
If shadows are baked, lights and object cannot move with respect to each other.
Large textures (eg 4096x4096) can be memory intensive, and be just as slow as the rendered solution.
Human (labor) time must be spent unwrapping and baking and saving files and applying the textures to a channel.

You apply the baked Normal image as a Normal Map using a Texture channel.

Options

Full Render
Bakes all materials, textures, and lighting except specularity and SSS.
Ambient Occlusion
Bakes ambient occlusion as specified in the World panels (F8). Ignores all lights in the scene.
Normals
Bakes tangent and camera-space normals (amongst many others) to an RGB image.
Textures
Bakes colors of materials and textures only, without shading.
Clear
If selected, clears the image to selected background color (default is black) before baking render.
Margin
Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
Mesh Must be Visible in Render
If a mesh not is visible in regular render, for example because it is disabled for rendering in the Outliner or has the DupliVerts setting enabled, it cannot be baked to.


Options under development (after 2.45)

The Bake tab in the Render buttons panel.Development version

Read more here: Changes since 2.45 -> Baking Selected to Active

Selected to Active toggle button
Information from other object can be baked onto the active object, with the Selected to Active option.
Distance
The Distance parameter controls how far a point on another object can be away from the point on the active object. Only needed for Selected to Active.

A typical use case is to make a detailed, high poly object, and then bake it's normals onto an object with a low polygon count. The resulting normal map can then be applied to make the low poly object look more detailed.
Displacement Map (new option for render-bake type)
Similar to baking normal maps, displacement maps can also be baked from a high-res object to an unwrapped low-res object, using the Selected to Active option.

When using this in conjunction with a subsurf and displacement modifier within Blender, it's necessary to temporarily add a heavy subsurf modifier to the 'low res' model before baking. This means that if you then use a displacement modifier on top of the subsurf, the displacement will be correct, since it's stored as a relative difference to the subsurfed geometry, rather than the original base mesh (which can get distorted significantly by a subsurf). The higher the render level subsurf while baking, the more accurate the displacements will be. This technique may also be useful when saving the displacement map out for use in external renderers.


Normals can now be baked in different spaces:

  • Camera space - The already existing method.
  • World space - Normals in world coordinates, dependent on object transformation and deformation.
  • Object space - Normals in object coordinates, independent of object transformation, but dependent on deformation.
  • Tangent space - Normals in tangent space coordinates, independent of object transformation and deformation. This is the new default, and the right choice in most cases, since then the normal map can be used for animated objects too.

For materials the same spaces can be chosen as well, in the image texture options, next to the existing Normal Map setting. For correct results, the setting here should match the setting used for baking. Note that this replaces the NMap TS setting in material options, which is automatically converted to the Tangent space option in the texture options.

Workflow

Windows Users do AO first
If you are running Blender on a Windows operating system, you may have to first bake Ambient Occlusion before baking any other option. If you do not bake AO first, you may get the error message "No Image to Bake To" and will not be able to bake anything for that mesh and will have to restart Blender.


  1. In a 3D View window, select a mesh and enter UV/Face Select mode
  2. Unwrap the mesh object
  3. In a UV/Image Editor window, either create a new Image or open an existing Image. If your 3D view is in Textured display mode, you should now see the image mapped to your mesh. Ensure that all faces are selected.
  4. With your mouse cursor in 3D View, press CtrlAltB to popup the menu of available baking choices. Alternatively, access the Bake panel in the Buttons window, Scene (F10) context, Render sub-context.
  5. Bake your desired type of image: Full Render, Ambient Occlusion, Normals, or shadeless Textures.
  6. After computation, Blender replaces the image with the Baked image.
  7. Save the image in the UV/Image Editor window via Image->Save
  8. Refine the images using the process described below, or embellish with Texture Paint or an external image editor.
  9. Apply the image to the mesh as a UV texture. For displacement and normal maps, refer to Bump and Normal Maps. For full and texture bakes, refer to Textures. In all cases you want to Map Input to the UV Map that was used when baking.

Render baking and additional options are available in the Render buttons context, Bake tab. The saved image can now be assigned as an image texture using UV coordinates in Map Input tab of Materials context (F5). In a multiple UV setup, images can be baked from one (inactive) UV set to another (active) set. This can be useful for seam removal, or for game engines that require particular UV setups.

Refining Baked Images

Mode: UV/Image Editor

Hotkey: AltS

Menu: Image->Save

After baking, be sure to save the generated image. Images may also be refined in the UV/Image Editor using Texture Paint.

Examples

"Adrianna" model by Mr_Bomb; unwrap and textures by BgDM
UV Layout for Adrianna model



These examples use a model of a human head, and its UV Layout, shown to the left. The mesh was seamed along the top scalp line and down back of the head, and unwrapped using LSCM projection. It has seven layered image and procedural textures, and is lit by a hemisphere of spots as well as several accent lights.

Ambient occlusion bake




Ambient Occlusion option: Generates a bitmap of the "unwrapped" ambient occlusion result, ignoring all lighting. AO maps are often multiplied with color channels to simulate self-shadowing, soft lighting, or dirt. Note: if the texture shown here were simply multiplied by the diffuse texture, it would darken it by half; see below for a compositing noodle to brighten and blur this image.

Normals bake (camera space)


A Normals bake generates a camera-space normals RGB map. The orientations of the mesh's vertex normals relative to the Camera's X, Y, and Z axes are recorded as different levels of Red, Green, and Blue respectively. In this example, the camera was aimed at the right side of the head model, so the right-side faces are largely blue since they faced the camera more or less straight-on (normals parallel to camera's Z). Camera-space maps have limited utility; this map would allow you to create relief on a lower-poly model, but the illusion would be accurate only if viewed from the right side of the head. The solution to this is a "Tangent space" normal map which is independent of camera position and object deformation. Blender can bake many different types of maps, and to see them, please go to Doc:Manual/Textures/Maps/Bump and Normal Maps.


Textures only bake




The Textures option renders all materials and textures devoid of lighting, AO and shadows (similar to a "shadeless" render). This example baked image comprises the color and bump textures, two Cloud textures, and a subtle linear blend texture. A potential use of such a map might be to multiply it with a baked AO map in the compositor.


Full render bake



Full Render bake takes into account lighting/shadow, materials, vertex colors, bump, and AO if applicable. Full render baking does not include specularity and subsurface scattering, as these are view-dependent parameters. Neither does this mode support halo materials. Full renders can be useful as time-savers for renders of static scenes or objects; for example, soft shadows of a tree or piece of furniture cast by an area light (slow to render) can be baked and "painted" into the scene (very fast render), and will remain convincing as long as the object or light do not move.


Margin option "bleeds" pixels beyond edges of UV map





The Margin option adds the specified number pixels beyond the edge of the UV map. Can be useful for minimizing seams when the image is mapped back onto the mesh. If no value is specified, 1 pixel is added by default.

Applying Baked Images

When you baked the mesh, you were in UV Face Select Mode and the image is created. Save or Pack the image. Then, depending on the Option chosen, you map the rendered texture to the mesh using the following method:

Full Render
In the object's material settings, enable TexFace, which tells Blender not to compute the material color based on the procedural material settings, but instead use the UV Texture image mapped to the mesh according to the UV Layout.
Alternatively, create a Texture channel for the Material. In the MapInput panel, enable UV and enter the name of the UV Texture ("UVTex" by default). In the MapTo panel, enable "Col" for Color. Activate the Texture buttons subcontext, choose Image as the type of texture, and Load the image by selecting it from the selector list by the button "Load New".
With either mapping method, TexFace or Texture Channel, since the Full Render also takes into account the lighting, you should also enable Shadeless in the Material panel. When rendering the composite scene, Blender does not waste time recomputing the lighting effects on Shadeless materials, saving a lot of render time.
Ambient
Add a texture channel, and in the MapInput panel, map the texture to UV as described above. In the MapTo panel, enable "Col" but change the mix method to "Multiply". Blender will now multiply the above texture color channels by the AO mask, darkening the colors in the cracks and crevices.
Normal
Add a texture channel and load the baked normals image. Make sure to activate "Normal Map" in the Map Image panel. In the Materials contents Map Input panel, enable UV; in the Map To panel, enable Nor and turn off "Col". For camera mapped normals, do not use NMap TS in the shader; this option is for tangent space maps only
Texture

The Texture bake includes all materials, but no shading information.


Refining the Ambient Occlusion Image

Often, the rendered AO image will be dark and grainy. Keep in mind this image is multiplied by the base material, so if it is dark, it will darken the whole mesh. If it is grainy, it will make your mesh look speckled or dirty. If so, try increasing the number of Samples and disabling Noise.

Suggested compositing noodle for AO images

We recommend that you save the AO bake as an image file named "<object>-AO.<ext>", where <object> is the name of the selected object, and <ext> is the appropriate format extension ("tga" for targa format, "jpg" for JPEG, etc). Note that if you have extensions enabled, Blender will add the correct <ext> for you.

As a last resort, although not technically precise, you can blur the image to smooth it out, and increase the dynamic range of the image. To do so, switch to Composite Nodes and construct the noodle shown above. Read in that AO file using the Image input node. The Blur node will remove the graininess, and the adjust the ColorRamp node so that the brightest parts of the image are white (a value of 1.0).

Using a UV/Image Editor window, select "Viewer Node" as the display, and you can then save the image back out; we suggest using something like "<object>-AOK.<ext>". Now, use the AOK file as the multiplier against Color, and it will delicately and smoothly shade the mesh for ambient occlusion.

Applying High-Res Normal to a Low-Res Mesh

One of the tricks of the trade, especially in gaming, is to make a low-poly model look better by modeling two versions of the same thing; one low-poly, and another high-poly. (Blender's "multi-resolution mesh" feature is specifically designed for this.) Then, you bake the normal map of the high-poly model, which gives you a texture image that shows all the shadows and creases and detail. Then, apply those images to the low-poly model, and you save yourself a lot of time that you would otherwise have to spend hand-painting the low-poly UV Texture. For detailed explanations on normal maps, please visit Doc:Manual/Textures/Maps/Bump and Normal Maps.

Thanks to the option which allows baking from selected to Active, you do not need to unwrap the high-poly mesh. Here are the steps:

  1. Make a copy of your object.
  2. Unwrap the copy at a low resolution.
  3. Add a new image to the unwrapped mesh using the UV / Image window.
  4. Make sure the High-poly and Low-poly objects share the exact same location in Blender (having them on separate layers can help. You can work on one layer at a time and then select both layers when you bake.)
  5. Select the High-Poly Object, Shift Select the Low-Poly object. This leaves both selected with the Low-poly being the Active selected object.
  6. In the Render panel, select the Bake tab.
  7. Choose the map you want to Bake (Normal or Displacement).
  8. Choose the "Selected to Active" button.
  9. Click Bake.

Hints

Currently (v2.45), only mesh objects can be render-baked.

Baked images are not automatically saved. Save from the UV editor window with Alt-S or Image menu -> Save.

Baking can be interrupted with the Esc key.

If you move lights, you should re-bake any Full Render textures. If you change the mesh geometry, you should re-bake all of the options.

If you change any object's material color or any settings, you have to re-bake that object's Texture or Full Render for those changes to take effect.

Procedural textures (e.g. Clouds) can be baked with the Full Render or Textures options, providing a basis for further detailing. Use Shadeless materials if necessary.

If you get the error "No images found to bake to", check the following:

  1. The object is selected
  2. The object is visible (check the Logic panel)
  3. Ensure there is a new image (with UV test grid) loaded for baking.
  4. If Step 1 does not work although object meets all criteria in that Step, switch to Object mode, select the object, and try to bake.
  5. Try Image->New again in the UV editor and bake to AO before anything else.

Blender to xNormal/Maya Normal

Converting Blender Normal to xNormal

Blender's normal map baking tool is different from other applications, such as xNormal and Maya. Both of these are widely used in the games industry and are already production proven (meaning the way they bake their normal maps is more commonly used and can be regarded as a standard). To convert a Blender normal map to an xNormal, you need to invert the Red and Green channels. This is easily accomplished using the noodle shown to the right. Use the Image input node to read in the baked normal from Blender. Thread the Image socket to an RGB Curves node. In the Red and Green channels, drag the left endpoint up, and the right endpoint down, so that the curve runs diagonally down as shown. Thread the Image output to the Composite output, enable Do Composite, and save the image.