Vixen
02b45cc4
csharp
public sealed class GlobalDistanceFieldRenderer

Keeps the clipmap over the camera, on the device, and named in the frame's set.

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

Remarks

The node that joins the three halves that already existed and never met: a GlobalDistanceField that knows how to composite itself, a GlobalDistanceFieldTexture that knows how to copy one up, and a shader that knows how to read one. Everything here is sequencing.

It recomposites when the answer would change, not every frame. A composite is every cell of every level against every instance — the most expensive thing in the frame by a wide margin — and a camera that has not crossed a cell boundary would get the same numbers back. The levels are snapped to their own grids precisely so that "has anything moved" is a comparison rather than a guess, and this is what cashes that in: a still camera composites once and then never again.

The names are written every frame regardless. They are cheap, they are the frame's answer to "where is the clipmap now", and a set rebuilt for another reason would otherwise bind whatever the last frame left. Re-asserting a value that has not changed does not bump ParameterCollection.Version, so it does not cost an upload either.

The view position is the host's, not the camera's. It is usually the camera and does not have to be: a clipmap centred slightly ahead of a fast-moving camera has the geometry it is about to need rather than the geometry behind it. Taking it from RenderView would make that impossible to express, so the default is to follow the view and the property is there to override it.

Fields and properties (13)

  • public GlobalDistanceField? Field

    The clipmap to keep. Null does nothing at all.

  • public GlobalDistanceFieldTexture? Texture

    Its mirror on the device, made on the first record.

  • public SceneConstants? SceneConstants

    Where the names go — the frame's set 0.

  • public string ShaderName

    The compose-slot prefix the clipmap's names are written under.

  • public IList<string> Passes

    Any further prefixes the same clipmap is written under.

  • public IList<DistanceFieldInstance> Instances

    What the clipmap covers.

  • public int InstancesVersion

    Bumped by whoever changes Instances, to say the composite is out of date.

  • public Vector3? ViewPosition

    Where to centre the clipmap, or null to follow the view.

  • public RenderView? View

    Whose position to follow when ViewPosition says nothing.

  • public IGraphicsDevice? Device

    The device its texture is made on, or null to take the frame's.

  • public long Reused

    How many cells the last recomposite kept rather than recomputed.

  • public int Composites

    How many times the clipmap has actually been recomposited.

  • public bool Parallel

    Whether the composite may use more than one thread.

Methods (3)

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

    Declares the pass that composites the clipmap and copies it up.

  • protected internal override void Record(GraphicsCompositor compositor, RenderDrawContext context)

    Records this node's work into a pass somebody else opened.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (6)

  • ArenaThirdPersonShooter
  • ArenaIlluminationThirdPersonShooter
  • CompositorAssetTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering
  • DistanceFieldAoImageTestsVixen.Graphics.Golden.Tests
  • GlobalDistanceFieldRendererTestsVixen.Rendering.Tests