Skip to content

FaceAtlas

Namespace Nfty.Model in assembly Nfty.Model.

public static class FaceAtlas

The texture every model carries: [front W][gutter 1][back W], height H. The front half is what the front faces (and front-owned wall voxels) show, the back half what the back faces show. The one-pixel gutter repeats the front half's last column. The sampler is NEAREST, so there is no smoothing to bleed; the gutter guards the edge texel: a sample exactly on the front half's right edge (u = W / (2W + 1)), or pushed there by float rounding, reads the gutter, never the back half.

Remarks

A single picture uses the atlas too — its back half repeats the art — so the writers and the preview share ONE texture shape and ONE UV rule (MeshBuilder, built from the constants here).

Methods

Build(Image<Rgba32>, StackFaces?)

public static Image<Rgba32> Build(Image<Rgba32> art, StackFaces? faces = null);

Builds the atlas.

Parameters

  • art (Image<Rgba32>) - The finished picture; both halves are copies of it when faces is null. Not modified.
  • faces (StackFaces?) - The front and back owners' pictures, or null for a single picture.

Returns. The atlas; the caller owns it.

Exceptions

  • ArgumentException - The faces are another size than the art.

UpdateRegion(Image<Rgba32>, Image<Rgba32>, StackFaces?, Rectangle)

public static void UpdateRegion(Image<Rgba32> atlas, Image<Rgba32> art, StackFaces? faces, Rectangle area);

Rewrites a rectangle of an atlas from the art and faces it was built from, in place. The atlas layout lives here and only here: FaceAtlas.Build() is this over the whole picture.

Parameters

  • atlas (Image<Rgba32>) - An atlas made by FaceAtlas.Build() for this art's size; changed in place.
  • art (Image<Rgba32>) - The finished picture; used for both halves when faces is null.
  • faces (StackFaces?) - The front and back owners' pictures, or null for a single picture.
  • area (Rectangle) - The art pixels to copy; clipped to the picture.

Exceptions

  • ArgumentException - The atlas or faces are another size than the art.

WidthFor(int)

public static int WidthFor(int artWidth);

The atlas width for art artWidth pixels wide: 2W + 1.

Parameters

  • artWidth (int) - The art's width.

Returns. The atlas width.