Vixen
02b45cc4
csharp
public sealed class IrradianceBrickPool

A fixed number of brick-sized slots, and the probes filling them.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Four probes cubed, in a footprint of five cubed. Sixty-four probes belong to a brick; a hundred and twenty-five texels hold them. The extra plane on each of the three positive faces holds the neighbouring brick's first probe — the same world position, the same value, stored twice — which is what lets one hardware trilinear fetch cross a brick boundary without knowing there was one. It is Epic's volumetric-lightmap detail, and docs/plan/19 § 3 singles it out as the one everybody rediscovers the hard way.

The probes are on the lattice, not in the middle of cells. A brick's probe i sits at i/4 of the way across it, so probe 4 falls exactly on the far face — exactly where the next brick's probe 0 is. Any other convention makes the border texel an approximation of the neighbour rather than a copy of it, and the seam comes back at a smaller amplitude, which is worse than a visible one.

The pool is a volume texture that has not been uploaded yet. Slots are laid out in a 3D grid so a slot's origin is integer arithmetic, and Texels is in the order a 3D copy wants — X fastest, then Y, then Z. Nothing here touches a device; what does lives above this line, and the dependency runs one way.

Capacity is fixed, which is a decision rather than a simplification. A pool that grows reallocates the texture it is a mirror of, mid-frame, at the exact moment a scene got complicated. Doc 19 § 7's platform matrix notes sparse residency as optional precisely because a fixed pool works — running out means the furthest bricks are not resident, which is a quality reduction, not a failure.

Fields and properties (9)

  • public const int BrickResolution

    How many probes along each axis of a brick belong to it.

  • public const int PaddedResolution

    How many texels along each axis a brick occupies, borders included.

  • public const int TexelsPerBrick

    How many texels one brick occupies.

  • public Int3 Slots

    How many brick slots there are along each axis.

  • public int Capacity

    How many bricks the pool can hold.

  • public int Count

    How many bricks are currently handed out.

  • public Int3 TexelResolution

    How many texels the pool is along each axis.

  • public ReadOnlySpan<IrradianceProbe> Texels

    Every texel, in the order a volume copy wants them.

  • public IrradianceProbe this[int slot, int x, int y, int z]

    One texel of one brick.

Methods (9)

  • public IrradianceBrickPool(Int3 slots)

    Builds an empty pool of a given shape.

  • public static IrradianceBrickPool OfCapacity(int capacity)

    Builds an empty pool holding at least a given number of bricks.

  • public bool TryAllocate(out int slot)

    Hands out a slot.

  • public void Release(int slot)

    Gives a slot back, and forgets what was in it.

  • public void Clear()

    Gives every slot back and empties every texel.

  • public bool IsAllocated(int slot)

    Whether a slot is currently handed out.

  • public Int3 OriginOf(int slot)

    Where a slot starts, in texels.

  • public IrradianceProbe Sample(int slot, Vector3 local)

    The probe anywhere inside a brick, trilinearly interpolated.

  • public Vector3 TextureCoordinate(int slot, Vector3 local)

    Where a point inside a brick sits in a volume texture holding the pool, as 0..1.

Used by (17)

  • CapturedIrradianceFillerVixen.Rendering
  • IndirectDiffuseImageTestsVixen.Graphics.Golden.Tests
  • IrradianceBrickPoolTestsVixen.Rendering.IrradianceFields.Tests
  • IrradianceCaptureDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceCoarseningTestsVixen.Rendering.IrradianceFields.Tests
  • IrradianceConvergenceTestsVixen.Rendering.IrradianceFields.Tests
  • IrradianceFieldVixen.Rendering.IrradianceFields
  • IrradianceFieldFillVixen.Rendering
  • IrradianceFieldRepairVixen.Rendering
  • IrradianceFieldTestsVixen.Rendering.IrradianceFields.Tests
  • IrradianceFieldTextureVixen.Rendering
  • IrradianceFieldTextureTestsVixen.Rendering.Tests
  • IrradianceFillDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceRefinementPolicyTestsVixen.Rendering.IrradianceFields.Tests
  • IrradianceRepairDeviceTestsVixen.Graphics.Golden.Tests
  • SamplingConventionTestsVixen.Rendering.IrradianceFields.Tests
  • TracedIrradianceFillerVixen.Rendering.IrradianceFields