Baking Texture Maps

 
< previous page next page >

Within this tutorial, we are going to use RapidCompact CLI in order to generate some texture maps, applied to a low-resolution mesh with UV coordinates, by extracting data from a corresponding high-resolution 3D asset. We will use a scanned plastic bust of Nefertiti (courtesy of CultLab3D) as an example throughout this tutorial. You can find the files here.

Table of Contents

Basics

 back to top

The process of generating maps for an asset that has UV coordinates is often referred to as baking, and we will use that term throughout this tutorial. An basic overview of the baking process is shown in the following figure:

As shown in the left of the figure, baking needs an asset with UV maps, which is typically a low-poly mesh. The data which should be used to generate the content of the detailed texture maps (such as surface normals, colors and occlusion) is typically a high-resolution original asset, for example a detailed 3D scan.

To generate a version of the UV-mapped low-resolution nefertiti mesh, using data from a high-resolution version with vertex colors, use the following command:

    rpdx -i nefertiti-vcols.ply -i nefertiti-lowpoly-uv.obj --bake_maps -e baked/nefertiti.obj

This will create a directory entitled baked inside your current working directory, which will contain the baked maps and the respective textured asset.

Configuration

 back to top

The baking process can be configured in several ways, with more than just a handful of parameters. Therefore, to ease configuration, you may want to use a config file, instead of specifying all parameters you want to change via the command line (see here for more information on configuration possibilities). The available settings which are directly affecting texture baking are the following:


Texture Baking

Name Type Default Valid Range Quick Description
baking:bakeCombinedScene Flag false {true, false} bakes the scene as a single entity even if its meshes have transformations
baking:fixedAtlasResolution Flag false {true, false} if false, each texture's pixel budget is divided by all atlases
baking:forceNormalRebaking Flag false {true, false} rebakes normal maps when preserving UVs, even if UV overlaps are detected
baking:generateDisplacement Flag false {true, false} enables/disables the generation of displacement maps
baking:generateNormal Flag true {true, false} enables/disables the generation of normal maps when the input has no normal maps
baking:tangentSpaceNormals Flag true {true, false} switches between tangent-/object-space normal maps
baking:baseColorMapResolution Int 2048 {1 .. 16384} resolution for baked base color and diffuse maps
baking:clearcoatMapResolution Int 2048 {1 .. 16384} resolution for baked clearcoat maps
baking:clearcoatNormalMapResolution Int 2048 {1 .. 16384} resolution for baked clearcoat normal maps
baking:clearcoatRoughnessMapResolution Int 2048 {1 .. 16384} resolution for baked clearcoat roughness maps
baking:displacementMapResolution Int 2048 {1 .. 16384} resolution for baked displacement maps
baking:emissiveMapResolution Int 2048 {1 .. 16384} resolution for baked emissive maps
baking:genericMapResolution Int 2048 {1 .. 16384} resolution for baked generic maps
baking:iridescenceMapResolution Int 2048 {1 .. 16384} resolution for baked iridescence maps
baking:iridescenceThicknessMapResolution Int 2048 {1 .. 16384} resolution for baked iridescence thickness maps
baking:metallicMapResolution Int 2048 {1 .. 16384} resolution for baked metallic maps
baking:normalMapResolution Int 2048 {1 .. 16384} resolution for baked normal maps
baking:occlusionMapResolution Int 2048 {1 .. 16384} resolution for baked AO maps
baking:roughnessMapResolution Int 2048 {1 .. 16384} resolution for baked roughness, specular and glossiness maps
baking:sampleCount Int 4 {1, 4, 8, 16} number of samples per texel for texture baking
baking:sheenColorMapResolution Int 2048 {1 .. 16384} resolution for baked sheen color maps
baking:sheenRoughnessMapResolution Int 2048 {1 .. 16384} resolution for baked sheen roughness maps
baking:specularColorMapResolution Int 2048 {1 .. 16384} resolution for baked specular color maps
baking:specularValueMapResolution Int 2048 {1 .. 16384} resolution for baked specular value maps
baking:thicknessMapResolution Int 2048 {1 .. 16384} resolution for baked thickness maps
baking:transmissionMapResolution Int 2048 {1 .. 16384} resolution for baked transmission maps
baking:forcedDisplacementMax Real 0 {-inf .. inf} (see baking:forcedDisplacementMin)
baking:forcedDisplacementMin Real 0 {-inf .. inf} when forcedDisplacementMax and forcedDisplacementMax are given and valid (min < max), their values are used to clamp and normalize the final entries in the displacement map
baking:normalMapScale Real 1 {2.2250738585072014e-308 .. inf} normal scaling for the baked normal map (only used on glTF output)
baking:skipNormalsRoughnessThreshold Real 0 {0 .. 1} roughness value below which difference in normals between source/target are not baked

AO Baking

 back to top In addition, you may want to bake AO maps and tweak the respective settings:


Ambient Occlusion

Name Type Default Valid Range Quick Description
ao:enabled Flag false {true, false} turns AO (Ambient Occlusion) generation on/off
ao:replaceMissingAlbedo Flag false {true, false} turns replacement of missing base color by AO map on/off
ao:replaceOriginal Flag true {true, false} computes a new AO map even if one is present in the input
ao:textureSamples Int 48 {8 .. 64} number of samples per texel for AO map generation (converted to a multiple of 8)
ao:vertexSamples Int 100 {1 .. 1024} number of samples per vertex for AO generation
ao:filterRadius Real 3 {0 .. 16} filter radius for smoothing the AO map (if any)
ao:strength Real 0.85 {0 .. 1} strength (intensity) for generated AO maps

Occlusion baked with the FlightHelmet model and different ao:strength levels, from left to right: 0.25, 0.5, 0.8.

Computation of Normal / Tangents

There is also a setting which only relevant for low-poly mesh during baking, affecting how normals and tangents will be computed on this mesh:

Name Type Default Valid Range Quick Description
general:normalsHardAngleDeg Real 60 {0 .. 180} hard angle (degrees) used for normal generation (0 = everything flat, 180 = everything smooth)

For organic 3D models or 3D Scans from Photogrammetry we recommend to set the "normalsHardAngleDeg" to 180. This makes sure that the generated low polygon normals are completely smooth. Finally, it is possible to tweak the inpainting on the texture maps (filling of the gutter spaces):


UV Inpainting

Name Type Default Valid Range Quick Description
inpainting:radius Real 32 {0 .. 32} radius, in pixels, for texture inpainting

There are also other settings for further tweaking. An example config file is packaged within the zip archive with the nefertiti assets. This config file contains all settings that are somehow related to the baking process and in addition some export settings such as image file format specifications. To employ it and update the previously generated files, simply use the following command line:

    rpdx --read_config baking_config.json -i nefertiti-vcols.ply -i nefertiti-lowpoly-uv.obj --bake_maps -e baked/nefertiti.obj

Baking PBR- & Generic Maps

 back to top

In addition to baking the base color, normal and occlusion maps, the RapidCompact CLI is also able to bake PBR- and Custom Texture Maps. You can find the respective sections in the next Tutorial: PBR Materials & advanced Texture processing.

Visualization

 back to top

The exported asset with baked maps is now ready for visualization. The following images illustrate how the details of the high-resolution mesh are preserved on the surface of the textured low-resolution asset (shown with wireframe on top in the rightmost image):

To visualize the result in 3D, you can zip and host the web directory yourself; The web-export tutorial might become handy for that process. After adjusting the 3D settings and environment, your result will look similar to this:


< previous page next page >