Vixen
02b45cc4
csharp
public readonly record struct ImpostorAtlas

Where each of a grid's views lives in the baked texture.

Read the guide page for this →

Remarks

One atlas per foliage type, and one texture fetch per channel per blended view. The alternative — a texture array with a layer per cell — is the same memory and one more binding, and it makes the three-way blend three array reads whose layers are decided per pixel, which is exactly the access pattern a texture array is worst at.

⚠ Every cell is padded, and the padding is not optional. A bilinear tap near the edge of a cell reaches into its neighbour, which at a distance of four hundred metres is a tree wearing a stripe of the tree next to it. The gutter is what the bake dilates into.

⚠ The atlas has no mips below the cell size, and a caller building them has to stop. A mip that mixes two cells is the same bleed the padding exists to stop, arriving through a different door — so MipLevels is how many are safe rather than how many fit.

Fields and properties (7)

  • public ImpostorGrid Grid

    The view grid.

  • public int CellSize

    How many texels a cell is, gutter included.

  • public int Padding

    How many of those are gutter, on each side.

  • public int Resolution

    How many texels the whole atlas is, on a side.

  • public int DrawSize

    How many texels of a cell the mesh is drawn into.

  • public int MipLevels

    How many mip levels can be built before two cells share a texel.

  • public long ByteCount

    How many bytes the atlas is, at four channels a texel.

Methods (3)

  • public ImpostorAtlas(ImpostorGrid grid, int cellSize = 128, int padding = 4)

    Creates a layout.

  • public (int X, int Y, int Width, int Height) RectOf(ImpostorCell cell)

    Where a cell's drawable area is, in texels.

  • public Vector2 UvOf(ImpostorCell cell, Vector2 uv)

    Where a point of a cell's own view lands in the atlas.

Used by (5)

  • ImpostorBakeVixen.Rendering
  • ImpostorBakeTestsVixen.Rendering.Tests
  • ImpostorCapturePassVixen.Rendering
  • ImpostorCapturePassTestsVixen.Rendering.Tests
  • ImpostorTestsVixen.Rendering.Tests