Vixen
02b45cc4
csharp
public sealed class ShadowMapRenderer

Renders a directional light's cascaded shadow map.

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

Remarks

The clearest thing a compositor buys, and the reason the collect phase exists at all: a cascade is a view. Four cascades are four RenderViews over one stage, culled independently, sorted independently, and drawn into four tiles of one texture. Nothing about the mesh feature, the material feature or the sort key changes to support them.

One pass, four viewports. The atlas is cleared once and each cascade draws into its tile, rather than four passes into four textures. On a tile-based GPU four passes mean four loads and four stores of a depth buffer that is never read outside the frame; on a desktop one they are four pipeline barriers for no reason.

The camera's parameters are here, not on the view. A RenderView deliberately holds only what culling needs — a frustum and a position — because a view is not a camera. Fitting a cascade needs the field of view and the aspect ratio, which are the camera's, so the node that fits them is where they belong.

Fields and properties (32)

  • public required RenderStage CasterStage

    The stage that draws depth-only casters.

  • public ViewConstants? Constants

    The per-view block to bind before each cascade's casters.

  • public string Atlas

    The name of the atlas to render into.

  • public ParameterCollection? Scene

    Where to publish what a shading pass needs to read the atlas, or null to publish nothing.

  • public string ShaderName

    Which pass's names to publish under.

  • public SamplerCache? Samplers

    Where the atlas's sampler comes from. Without one, no sampler is published.

  • public float ConstantBias

    How far the depth comparison is nudged, in metres.

  • public float SlopeBias

    How much more of that a surface gets as it turns away from the light, in metres.

  • public float FadeRange

    Over what distance shadows fade out at the last cascade's end, in metres.

  • public RenderStage? StaticCasterStage

    The stage that draws casters which do not move, or null to redraw everything every frame.

  • public string StaticAtlas

    The name of the texture the cached static content lives in, or empty for no cache.

  • public float Slack

    How much larger than each slice to cut its cascade, as a fraction.

  • public int StaticVersion

    Bumped by the host whenever a static caster is added, removed or moved.

  • public int StaticRebuilds

    How many times the static atlas has been redrawn.

  • public int CascadeCount

    How many cascades to fit, up to MaxCascades.

  • public int Resolution

    One cascade's side in texels.

  • public RenderView? Camera

    The view whose frustum the cascades are fitted to.

  • public ISunSource? Sun

    Where the sun comes from, when it comes from the scene.

  • public Vector3 Eye

    Where the camera is, when no Camera says.

  • public Vector3 Forward

    Where it looks.

  • public Vector3 Up

    Its approximate up direction.

  • public float FieldOfView

    Its vertical field of view, in radians.

  • public float AspectRatio

    Its width divided by its height.

  • public float NearPlane

    Where the first cascade starts.

  • public float ShadowDistance

    How far shadows are drawn — the shadow distance, not the camera's far plane.

  • public float SplitLambda

    How far to blend the splits from uniform toward logarithmic.

  • public float Extrusion

    How far behind a cascade the light's near plane sits, so outside casters still cast.

  • public Vector3 LightDirection

    The direction light travels — away from the sun, toward the scene.

  • public ReadOnlySpan<float> Splits

    How far each cascade is culled to, which is its own end distance.

  • public ReadOnlySpan<ShadowCascade> Cascades

    The cascades this frame fitted.

  • public IReadOnlyList<RenderView> Views

    The views the cascades are drawn from, for a host that wants to inspect them.

  • public Int2 AtlasSize

    The atlas's size in texels, for whoever creates the texture.

Methods (3)

  • protected internal override void Collect(GraphicsCompositor compositor)

    Declares the views and stages this node needs, before anything is culled.

  • protected internal override void Build(GraphicsCompositor compositor, CompositorFrame frame)

    Declares this node's render-graph passes.

  • public override string ToString()

    Returns a string that represents the current object.

Used by (8)

  • CompositorBuilderVixen.Rendering
  • CompositorImageTestsVixen.Graphics.Golden.Tests
  • ForwardFrameTestsVixen.Rendering.Tests
  • FrameVixen.Rendering.Tests
  • HarnessVixen.Rendering.Tests
  • HarnessVixen.Rendering.Tests
  • ShadowCacheTestsVixen.Rendering.Tests
  • ShadowMapRendererTestsVixen.Rendering.Tests