Vixen
02b45cc4
csharp
public sealed class ImpostorCapturePass

Draws a mesh into an impostor atlas: the caller ImpostorBake wants.

Read the guide page for this →

Remarks

[docs/plan/31 § T7]'s missing half. ImpostorBake owns the atlas, the viewports and the two colour targets, and takes the draw as a delegate on purpose — a bake renders the mesh with whatever material the caller has, and a class that owned a pipeline would be a class that decided what a tree looks like. What was missing was anybody with a pipeline to hand it, so the bake had no caller at all.

⚠ The albedo is a constant, and that is a stated simplification rather than an oversight. A tree is bark and leaves — two materials over one mesh — and a faithful bake draws it once per material through the same material system the level uses. What this produces is the correct silhouette with a flat colour, which is the half of an impostor a forest four hundred metres away actually reads; the alpha is the coverage, and the coverage is what the far field is made of.

⚠ One descriptor set per cell, not one per bake. Each cell is a different camera and the camera is in the uniform block, so a bake of an 8×8 grid writes sixty-four blocks into one buffer and binds a different offset per draw. Rewriting one block per cell would be rewriting a buffer the pass before it is still reading.

Fields and properties (4)

  • public const int VertexSizeInBytes

    How many bytes one vertex of a captured mesh is.

  • public const int BlockAlignment

    What one cell's constant block is aligned to.

  • public Color4 BaseColour

    What the mesh is photographed as, until a bake resolves its material.

  • public int CellsDrawn

    How many cells the last Bake drew into.

Methods (4)

  • public ImpostorCapturePass(IGraphicsDevice device, ShaderHandle vertex, ShaderHandle fragment, int cells, PixelFormat colourFormat = Rgba8UNorm, PixelFormat normalFormat = Rgba8UNorm, PixelFormat depthFormat = Depth32Float)

    Creates the pipeline a bake draws with.

  • public int Bake(ICommandList commands, ImpostorBake bake, in ImpostorMesh mesh)

    Photographs a mesh into every cell of an atlas.

  • public static int Pack(ReadOnlySpan<Vector3> positions, ReadOnlySpan<Vector3> normals, Span<byte> into)

    Packs positions and normals the way ImpostorMesh wants them.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (1)

  • ImpostorCapturePassTestsVixen.Rendering.Tests