Vixen
02b45cc4
csharp
public sealed class DistanceFieldAoRenderer

Occlusion and a sun shadow, traced through the global distance field.

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

Remarks

The companion to AmbientOcclusionRenderer, not a replacement. GTAO searches the depth buffer, so it is sharp, cheap and completely blind to anything off screen — a wall behind the camera does not darken the floor in front of it. This searches the field, so it sees the whole world at the field's own resolution and nothing finer. A frame wants both, multiplied: contact darkening from one, the room from the other.

It traces a sun shadow too, because the march is already paid for. A distance field answers "how much of the sky is blocked" and "how much of the sun is blocked" with the same walk over the same data, and the penumbra falls out of how close the ray passed rather than out of a filter kernel — which is what a cascade cannot do at any resolution.

It binds no part of the clipmap itself. The volumes, their textures and their sampler live in the frame's set 0, put there by GlobalDistanceFieldRenderer — because the field follows the camera and belongs to the frame, not to this pass. What this owns is the depth, the normals and the numbers of its own march. The pair has to agree on one thing and only one: the compose-slot prefix those names are written under.

Occlusion in red, sun visibility in green. Two numbers a shading pass multiplies into different terms, so they are kept apart. Pre-combining them into one "darkness" darkens direct lighting with ambient occlusion, which is the classic mistake that makes a scene look dirty rather than grounded.

Fields and properties (17)

  • public required string Depth

    The depth it reconstructs world positions from.

  • public required string Normals

    The normals it orients the occlusion integral by.

  • public string Source

    The shader behind the field slot — what the march actually reads.

  • public bool SunShadow

    Whether to trace a sun shadow alongside the occlusion.

  • public RenderView? View

    The view whose camera drives the unprojection below, or null to set it by hand.

  • public Matrix4x4 InverseViewProjection

    Clip space back to world space, for turning a depth into a position.

  • public float OcclusionRadius

    How far up the normal the occlusion integral looks, in metres.

  • public int OcclusionSamples

    How many steps it takes along that.

  • public float OcclusionStrength

    How dark the occlusion goes.

  • public Vector3 SunDirection

    Which way the sun is, in world space.

  • public float SunDistance

    How far to march toward it before calling the point lit.

  • public float SunSoftness

    The reciprocal of the sun's angular radius. Larger is a sharper shadow.

  • public float ShadowBias

    How far off the surface a shadow ray starts.

  • public int ShadowSteps

    How many steps a shadow march may take.

  • public float SurfaceThreshold

    How near counts as arrived, for both marches.

  • public float StepScale

    What fraction of the reported distance each step actually takes.

  • public float Scale

    What fraction of the frame it runs at.

Methods (3)

  • public DistanceFieldAoRenderer()

    Occlusion and a sun shadow, traced through the global distance field.

  • protected override Int2 TargetSize(Int2 frame)

    The size the effect's own target is, given the frame's.

  • protected override void Configure(CompositorFrame frame, ParameterCollection parameters, IList<ResourceBinding> bindings)

    Fills in this frame's parameters and bindings.

Used by (3)

  • DistanceFieldAoImageTestsVixen.Graphics.Golden.Tests
  • PostEffectFactoryVixen.Rendering.PostFx
  • PostEffectTestsVixen.Rendering.PostFx.Tests