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.
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: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: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) |
In addition, you may want to bake AO maps and tweak the respective settings:
AO Baking
Name |
Type |
Default |
Valid Range |
Quick Description |
ao:enabled |
Flag |
false |
{true, false} |
turns AO (Ambient Occlusion) generation on/off |
ao:textureSamples |
Int |
48 |
{8 .. 64} |
number of samples per texel for AO map generation (converted to a multiple of 8) |
ao:filterRadius |
Real |
3 |
{0 .. 16} |
filter radius for smoothing the AO map (if any) |
ao:replaceMissingAlbedo |
Flag |
false |
{true, false} |
turns replacement of missing base color by AO map on/off |
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) |
It is especially important when baking normal maps for meshes with overall soft, averaged normals such as organic 3D models or 3D Scans from Photogrammetry to set the "normalsHardAngleDeg" on 180 ; it makes sure that the generated low polygon normals are completely smooth / averaged.
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 >