Vixen
02b45cc4
csharp
public sealed class ReconstructedScreenSurface

The screen's own surfaces, reconstructed from a frame's depth and normal buffers.

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

Remarks

What "probe placement from the real depth buffer" is. The gather's fixtures answer IScreenSurface from analytic geometry; a frame answers it from what it drew. This holds one frame's depth and encoded normals on the host and reconstructs a world position per pixel by exactly the arithmetic every screen-space shader here uses — Transform.UvDepthToWorld, the UV-to-NDC map with no y negation, the clip divide guarded by the same epsilon. The shader and this must be one function evaluated twice, because a probe placed by this arithmetic is upsampled by that one.

Zero depth is the sky, because depth is reversed. Near is one and far is zero (Matrix4x4.PerspectiveFieldOfView says why), so a pixel nothing drew reads the depth clear of zero and has no surface — the test that keeps the comparison the right way round is the same <= 0 the upsample pass runs.

The buffers are owned here and refilled in place. A caller reading a frame back copies into Depth and Normals and sets InverseViewProjection to the matrix of the camera that drew them — the two are one snapshot, and pairing this frame's matrix with last frame's depth reconstructs surfaces that exist nowhere. Nothing here reads a device: the readback is the caller's, which is what keeps this checkable against closed forms.

Fields and properties (4)

  • public Int2 Viewport

    The viewport the buffers cover, in pixels.

  • public Matrix4x4 InverseViewProjection

    The inverse of the view-projection that drew the buffers.

  • public Span<float> Depth

    Device depth per pixel, row-major over the viewport. Zero is the sky.

  • public Span<Vector4> Normals

    Stored normals per pixel, row-major — xyz raw and signed, as the G-buffer stores them in Rgba16Float.

Methods (2)

  • public ReconstructedScreenSurface(Int2 viewport)

    Builds a surface over one viewport. The buffers start empty — all sky.

  • public bool TrySurface(Int2 pixel, out Vector3 position, out Vector3 normal)

Used by (8)

  • ReconstructedScreenSurfaceTestsVixen.Rendering.ScreenProbes.Tests
  • ReflectionRendererDeviceTestsVixen.Graphics.Golden.Tests
  • ReflectionTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenDepthPyramidTestsVixen.Rendering.ScreenProbes.Tests
  • ScreenProbeGatherRendererVixen.Rendering.PostFx
  • ScreenProbeTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenSpaceTraceVixen.Rendering.ScreenProbes
  • ScreenSpaceTraceTestsVixen.Rendering.ScreenProbes.Tests