Sidor

Saturday, September 12, 2020

Baking Normal Maps

This post is a continuation of High resolution Meshes and HD Meshes and Geografts.

A HD mesh behaves in many ways as the corresponding base mesh because it has the same topology, while the high-frequency details show up in renders. However, there are still reasons that you will want to bake normal maps from the multires modifier and apply them to the mesh at base resolution. In particular:

  • Performance. The extra geometry is still present, even if it relegated to the multires modifier, which affects file size, memory consumption, and viewport responsiveness.
  • If you want to export your mesh to other applications, e.g. a game, since the multires modifier is Blender specific.

Tutorials about how to bake normal  maps from multires can be found on the internet, but the process is not very straightforward and quite capricious. There are a number of caveats, such as

  • The material used for baking must apparently be the first one. It is not enough that it is the active material.
  • The viewport levels in the multires modifier must be set to zero. This is because the difference between the mesh at the render level and viewport level is used for baking.

Moreover, DAZ meshes typically have multiple UDIM tiles, each of which  must be baked separately. 

For this reason I implemented a tool to Bake Normal Maps, and another to Load Normal Maps that have been baked with the first tool. 

 

First of all we must make sure that the current scene is saved as a blend file. The reason is that the normal maps will be saved in a specific location relative to the current blend file (namely in the directory textures/normals/object-name), so the location of the blend file must be well defined.

Select the HD mesh and press Bake Normal Maps.

Choose the size of the image to be generated.

Seven normal maps are now generated, one for each UV tile. 

Directory: textures/normals/object-name

File name: object-name_NM_tile_size.png

Here is the normal map for the tile 1002, which contains the torso.

Now select the mesh at base resolution, and Load Normal Maps.

 

Again we select the image size.

Texture nodes for the normal maps are generated in the materials. If the material already has a normal map node, the new texture replaces the old one, otherwise a new normal map node is created as well as links to all Normal sockets in the node tree.

Below we show some results.

Cycles.

Base resolution mesh in Cycles
HD mesh in Cycles
Base mesh with normal maps in Cycles

Eevee

Base resolution mesh in Eevee
HD mesh in Eevee
Base mesh with normal maps in Eevee

If you want more prominent normal maps, you can use the Material Editor and change the Normal Strength.


Here are the results

Base mesh with normal maps and normal strength = 2, in Cycles
Base mesh with normal maps and normal strength = 2, in Eevee