docs.unity3d.com
Version: 

    Bake materials

    API function: algo.bakeMaps

    Use this feature as part of your mesh optimization process to transfer mesh and materials information to texture maps.

    Usecase

    Usually, you would use this function in two scenarios:

    • Auto baking: optimize a set of meshes with different materials into one or multiple meshes with one material (see Algo::CombineMaterials)
      1. Create UVs, tangents and normals (optional if they already exist)
      2. Repack UVs
      3. Normalize UVs
      4. Bake Maps
      5. Create a material with generated textures
      6. Merge meshes (optional)
      7. Assign the created material
    Tip

    Copy your original UVs in an empty channel if you don't want them to be overrided.

    • LOD baking: bake mesh and material information from a high detailed LOD and assign created textures to a low detailed LOD.
      1. Duplicate LOD0 occurrences
      2. Generate LOD1 (decimation, proxy mesh, ...)
      3. Create tangents on LOD0 (optional if they already exist)
      4. Create UVs, tangents and normals on LOD1 (optional if they already exist)
      5. Repack UVs (LOD1)
      6. Bake Maps (source: LOD0, destination: LOD1)
      7. Create a material with generated textures
      8. Assign the created material to LOD1

    This example shows a model with many curved surfaces. After baking, the triangle count is reduced from 40,000 to 8,000:

    After baking, the character still has a good visual quality.

    This example shows a model with many flat surfaces. After baking, the triangle count is reduced from 20,000 to 278:

    After baking, the equipment still has a good visual quality.

    Subsequently, you can use these maps to transfer information back to optimized assets.

    Parameters

    Method

    When source and destination are different, the function tries to find the destination's (lowpoly) texel's corresponding position on the source (highpoly). To do so, several approaches are possible:

    • Ray only: shoots a ray from the destination position along the normal vector. Bake the information from the intersection of the ray and the source. Fastest.
    • Proj only: finds the nearest position (shortest distance) from source to destination. Slower than ray-only.
    • Ray and proj: shoots a ray alon the normal vector and projects if it does not intersects.

    Maps

    Maps of various types are used for baking.

    Diffuse map

    This map defines the base colors of the 3D model.

    Diffuse map

    This map is also referred to as the albedo map.

    Normals map

    This map defines the map of normals for a material, in tangent or object space.

    The color of each pixel in this map represents a direction.

    Object space

    Opacity map

    This map defines the transparency of a material.

    Opacity map

    This map is also referred to as the transparency map.

    Roughness map

    This map controls how rough or smooth the surface of a material appears.

    Roughness map

    Metallic map

    This map determines how metal-like a surface is.

    Metallic map

    Ambient Occlusion map

    This map provides information about which areas of the model should receive high or low indirect lighting.

    Indirect lighting comes from ambient lighting and reflections. For example, the steep concave parts of your model, such as a crack or a fold, don't realistically receive much indirect light.

    Ambient Occlusion map
    Version 2025.2.0.1
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX.