Vixen
dd8b0a81
csharp
public static class MapBaker

docs/plan/41 § D12's bake: the output's normal, cast at the source, into the atlas.

Read the guide page for this →

Remarks

This is where the pipeline's arithmetic closes. § D12: a four-million-triangle generated blob is not expensive because it is four million triangles, it is expensive because it is four million triangles of noise with no UVs. Five thousand quads plus a 2K normal map is smaller, looks better under a moving light, subdivides and can be rigged. Retopology without baking is a downgrade; retopology with baking is the pipeline.

⚠ The ray is cast both ways and the nearer hit wins. Casting only outward loses every part of the source the output enclosed, which on a smoothed remesh of a noisy surface is about half of it; casting only inward loses the other half. A cage mesh is the production answer to the ambiguity and it is a thing an artist authors — the nearer of two opposed hits is the answer available to a content build with nobody watching.

⚠ A texel that finds nothing falls back to the closest point rather than to a default. A default normal in the middle of a chart is a flat patch that reads as a modelling error; the closest point is at worst the right answer measured from slightly the wrong place, and Missed says how often it happened.

⚠ Content is rasterized before anything is dilated, in two full passes. Two charts whose texels abut in the atlas is the common case, not the exotic one — the packer's whole job is to make it common — and a dilation interleaved with the rasterization would let whichever chart was drawn first bleed its gutter over the second chart's content. The gutter only ever writes where Coverage is false.

Methods (3)

  • public static BakedMaps Bake(EditMesh source, EditMesh target, BakeSettings settings)

    Bakes a normal and a displacement map from the source onto the output's atlas.

  • public static BakedMaps Bake(EditMesh source, EditMesh target, BakeSettings settings, Action<float>? progress, CancellationToken cancellationToken)

    Bakes a normal and a displacement map, reporting progress and stopping when asked.

  • public static Vector3 IdColour(int id)

    A distinct colour for an id, for the caller that has to write pixels rather than ints.

Used by (7)

  • MapBakerTestsVixen.Geometry.Remeshing.Tests
  • MeshMapTestsVixen.Geometry.Remeshing.Tests
  • ContentTasksVixen.Editor.App
  • MeshMapBakeVixen.Editor.Assets
  • MeshMapBakesVixen.Editor.App.Tests
  • MeshMapEncodingTestsVixen.Editor.Assets.Tests
  • TextureSelectionDeviceTestsVixen.Editor.TextureGraph.Tests