Vixen
02b45cc4
csharp
public readonly record struct ImpostorGrid

The grid of directions a mesh is photographed from, folded onto a hemi-octahedron.

Read the guide page for this →

Remarks

[docs/plan/31 § T7], and [docs/plan/06]'s "impostors / billboards" row for its only real consumer. A tree seen from four hundred metres is a few pixels of silhouette, and drawing forty thousand triangles for it is the cost the far field is made of. An impostor is that tree photographed from a grid of directions once, offline, and drawn as two triangles for ever after.

⚠ A hemi-octahedron, and it is a different fold rather than half of OctahedralMap's. Nobody looks at a tree from underneath — and a full-sphere grid spends half its atlas on the views a forest never shows, which at the resolutions an impostor is worth having is the difference between an eight-by-eight grid and a twelve-by-twelve one. The full-sphere fold exists, is used for probe radiance, and is not this.

⚠ Three cells are blended, not one. Snapping to the nearest view makes the impostor rotate in visible steps as the camera moves — the classic impostor artefact, and it is worse for a forest than for one object because every tree pops on a different frame. The three that share the direction's triangle sum to one, so the blend is continuous everywhere including across a cell boundary.

⚠ The grid is odd-sided so a cell sits exactly overhead. Straight down is the direction a top-down view spends its whole time in, and an even grid puts a seam there.

Fields and properties (4)

  • public const int MinimumSide

    The fewest cells a side that is still a grid.

  • public const int MaximumSide

    The most, so an atlas of any sane resolution has texels left per cell.

  • public int Side

    How many cells along each axis.

  • public int CellCount

    How many views the bake renders.

Methods (6)

  • public ImpostorGrid(int side = 9)

    Creates a grid.

  • public static Vector2 Encode(Vector3 direction)

    Folds a direction into the unit square.

  • public static Vector3 Decode(Vector2 square)

    Unfolds a point of the square back into a direction.

  • public Vector3 DirectionOf(ImpostorCell cell)

    Which direction a cell was photographed from.

  • public void Blend(Vector3 direction, Span<ImpostorSample> samples)

    The three cells whose views a direction is made of, and how much of each.

  • public ImpostorCell NearestTo(Vector3 direction)

    The cell nearest a direction, for a caller that wants one view.

Used by (7)

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