Vixen
02b45cc4
csharp
public sealed class MeshExtractionSystem

Turns the scene's drawable entities into render objects.

Read the guide page for this →

As a system

Phase
PreRender

Remarks

The counterpart to LightExtractionSystem, and the opposite trade. A light is rebuilt every frame because it has no handle worth keeping; a mesh holds a render object, a residency claim and a slot in every feature's parallel array, all of which are expensive to create and cheap to keep. So this reconciles: create for what appeared, destroy for what went, and update the transform of what stayed.

In PreRender, ordered by its declared access. TransformSystem writes WorldTransform in the same phase and this reads it, so the graph puts this second — an object culled against last frame's bounds pops in and out at the edge of the frustum.

Each drawable takes the material it names, and Material is what a drawable that names none gets. That fallback is not a stopgap: a block-out mesh dropped into a level before anybody has made a material for it has to draw in something neutral, and Material being null is how an author says so. A reference that names a material this frame cannot supply yet is waited for exactly as a mesh is — see Materials.

⚠ What this is still not is doc 06's "a mesh with three materials is three render objects". One entity is one render object with one material; a model whose sub-meshes want different materials needs one entity each, which is what a prefab already produces.

⚠ Every live object's transform is rewritten every frame. Doc 06 wants only what moved re-extracted, and the change-version filter that would do it is owed — as is the assertion that a settled frame extracts nothing. What is here is correct and pays a matrix store per drawable per frame, which is the wrong cost and not a wrong picture.

Fields and properties (12)

  • public RenderStageMask Stages

    Which stages an extracted object appears in.

  • public Material? Material

    What a drawable that names no material of its own is drawn with.

  • public IMaterialSource? Materials

    Where the material a reference names comes from. Null draws everything in Material.

  • public VirtualGeometryRenderFeature? Virtualized

    The feature virtualized meshes are drawn through, or null to draw none that way.

  • public IVirtualGeometrySource? Clusters

    Where the cluster hierarchy a mesh reference names comes from.

  • public int ObjectCount

    How many entities are extracted.

  • public int VirtualizedCount

    How many of them took the virtualized path.

  • public IReadOnlyList<ResolveMaterial> ResolveMaterials

    The materials the resolve pass has to dispatch for, in material-index order.

  • public IMeshSource? Meshes

    Where the geometry a mesh reference names comes from. Null draws no referenced mesh.

  • public int Waiting

    How many entities are waiting for geometry that has not loaded yet.

  • public int Dropped

    How many entities wanted geometry that did not fit in the buffer.

  • public SystemAccess Access

    What this system reads and writes.

Methods (6)

Used by (6)

  • ArenaThirdPersonShooter
  • MeshExtractionTestsVixen.Rendering.Tests
  • VirtualGeometryExtractionTestsVixen.Rendering.Tests
  • WorldRendererVixen.Engine.Renderer
  • WorldRendererTestsVixen.Engine.Renderer.Tests
  • HostedRendererTestsVixen.App.Tests