Vixen
02b45cc4
csharp
public sealed class ScreenDepthPyramid

The depth's nearest-per-cell pyramid — what a hierarchical screen march skips with.

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

Remarks

The other reduction. HiZReduce keeps the farthest texel per cell, because occlusion culling asks "could anything behind this cell be visible"; a screen march asks the opposite — "could anything in this cell stop my ray" — and the answer is no whenever the ray passes nearer than the cell's nearest surface. Depth is reversed, so nearest is the maximum device depth, and a cell of pure sky reduces to zero, which stops nothing.

Level zero is the depth itself; each level above it halves the way a mip chain halves — flooring, to a minimum of one — because the device pyramid is a mip chain and the two must hold the same texels for the two marches to skip the same cells. Each cell reduces a clamped three-by-three block of the level below, exactly NearestReduce.rvn's taps: floor-halving leaves a trailing row and column a two-by-two block never reads, and a missed surface would lower a cell's nearest, which is the direction that lets a ray skip through a wall. The extra ring only ever raises it, which merely descends a level sooner — the trade every conservative hierarchy makes, in this pyramid's own direction.

Fields and properties (2)

  • public Int2 Viewport

    The level-zero size.

  • public int Levels

    How many levels the pyramid has, down to one-by-one.

Methods (4)

  • public ScreenDepthPyramid(Int2 viewport)

    Builds an empty pyramid over one viewport.

  • public Int2 SizeOf(int level)

    One level's size.

  • public float Nearest(int level, Int2 cell)

    The nearest surface in one cell — the maximum device depth, zero for pure sky.

  • public void Build(ReadOnlySpan<float> depth)

    Reduces a depth buffer into every level.

Used by (5)

  • ReflectionTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenDepthPyramidTestsVixen.Rendering.ScreenProbes.Tests
  • ScreenProbeTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenPyramidDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenSpaceTraceVixen.Rendering.ScreenProbes