Vixen
02b45cc4
csharp
public sealed class ViewConstants

One uniform block per view, bound before that view's work.

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

Remarks

Set 1 of the four-set convention, and the thing whose absence was the largest hole in the renderer: nothing could tell a shader where it was being drawn from. TransformRenderFeature pushes a world matrix and there was no second half — so a shadow caster could not know which cascade's projection to use, and a golden fixture had to compose the cascade's matrix into the object's world transform to draw anything at all.

One block per view, not per draw. A frame has a camera and a dozen views — four cascades, six probe faces — and every object in a view shares its matrix. Binding it once per (view, stage) rather than per object is the whole reason the convention orders its sets by how often they change.

The layout is shared, and that is what makes set 1 work at all. A descriptor set is only bindable across pipelines whose layouts agree up to that set, so every shader in a frame reads the same per-view block by construction. That is why the members are configured here once rather than taken from an effect: the block belongs to the frame, not to any shader in it.

The view's own matrix and position are written for you, so the common case is to leave Members at its default and set nothing. Anything else a project wants in set 1 — the time, an exposure, a light environment — is a member and a key it sets on Of.

Fields and properties (12)

  • public static readonly ParameterKey<Matrix4x4> ViewProjection

    The view-projection, at byte 0 of the default layout.

  • public static readonly ParameterKey<Vector3> ViewPosition

    Where the view is, at byte 64 of the default layout.

  • public static readonly ParameterKey<Matrix4x4> View

    World to view, at byte 80 of the default layout.

  • public static readonly ParameterKey<Matrix4x4> PreviousViewProjection

    Last frame's view-projection, at byte 144 of the default layout.

  • public DescriptorAllocator? Descriptors

    Where the descriptor sets come from. Without one, nothing is bound.

  • public DescriptorSetLayoutHandle Layout

    The set's shape. Without one, nothing is bound.

  • public DescriptorSetSlot Slot

    Which of the four conventional sets this is.

  • public uint Binding

    Which binding within the set the block occupies.

  • public int Size

    How large the block is, in bytes.

  • public IList<EffectParameter> Members

    Where each value goes in the block.

  • public int Count

    How many views have a block.

  • public bool IsConfigured

    Whether there is enough here to bind anything.

Methods (8)

  • public ViewConstants(IGraphicsDevice device, string name = "View")

    One uniform block per view, bound before that view's work.

  • public ParameterCollection Of(RenderView view)

    The values for one view, for a caller adding members of its own.

  • public bool AdoptLayout(Effect effect)

    Takes the set layout off a resolved shader, if it has not got one.

  • public bool Bind(ICommandList commands, RenderView view)

    Fills this view's block if it changed, and binds it.

  • public bool Bind(ICommandList commands, RenderView view, Effect? effect)

    The same, allocating the set against the layout of the pass about to be drawn.

  • public bool Forget(RenderView view)

    Forgets a view's block, for a view that has gone away.

  • public ReadOnlySpan<byte> BytesFor(RenderView view)

    The bytes one view's block was last filled with, for checking they are the right ones.

  • public void Dispose()

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

Used by (25)

  • ArenaThirdPersonShooter
  • ClusteredShadingDeviceTestsVixen.Graphics.Golden.Tests
  • CompositorAssetTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering
  • CompositorImageTestsVixen.Graphics.Golden.Tests
  • ForwardFrameTestsVixen.Rendering.Tests
  • FrameVixen.Rendering.Tests
  • GpuClusterResolveVixen.Rendering
  • IrradianceBounceDeviceTestsVixen.Graphics.Golden.Tests
  • IrradianceShadingDeviceTestsVixen.Graphics.Golden.Tests
  • MeshRenderFeatureVixen.Rendering
  • MotionVectorTestsVixen.Rendering.Tests
  • ParticleRenderFeatureVixen.Rendering
  • ParticleSpriteDeviceTestsVixen.Graphics.Golden.Tests
  • PunctualShadowRendererVixen.Rendering
  • RenderDrawContextVixen.Rendering
  • ShadowMapRendererVixen.Rendering
  • SingleStageRendererVixen.Rendering
  • SpriteRenderFeatureVixen.Rendering
  • ViewConstantsTestsVixen.Rendering.Tests
  • VirtualGeometrySystemVixen.Rendering
  • VirtualShadowRendererVixen.Rendering
  • VisibilityBufferRendererVixen.Rendering
  • WorldRendererVixen.Engine.Renderer
  • PickingRendererVixen.Editor.SceneView