public sealed class MeshExtractionSystemTurns the scene's drawable entities into render objects.
As a system
- Phase
- PreRender
- Writes
- RenderHandle
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 StagesWhich stages an extracted object appears in.
public Material? MaterialWhat a drawable that names no material of its own is drawn with.
public IMaterialSource? MaterialsWhere the material a reference names comes from. Null draws everything in Material.
public VirtualGeometryRenderFeature? VirtualizedThe feature virtualized meshes are drawn through, or null to draw none that way.
public IVirtualGeometrySource? ClustersWhere the cluster hierarchy a mesh reference names comes from.
public int ObjectCountHow many entities are extracted.
public int VirtualizedCountHow many of them took the virtualized path.
public IReadOnlyList<ResolveMaterial> ResolveMaterialsThe materials the resolve pass has to dispatch for, in material-index order.
public IMeshSource? MeshesWhere the geometry a mesh reference names comes from. Null draws no referenced mesh.
public int WaitingHow many entities are waiting for geometry that has not loaded yet.
public int DroppedHow many entities wanted geometry that did not fit in the buffer.
public SystemAccess AccessWhat this system reads and writes.
Methods (6)
public MeshExtractionSystem(RenderSystem system, MeshRenderFeature meshes, TransformRenderFeature transforms, MaterialRenderFeature materials, GeometryResidency residency)Builds the bridge.
public override JobHandle Update(in SystemContext context, JobHandle dependency)Runs the system.
public void Extract(World world)Reconciles the render store with the world.
public bool Forget(Entity entity)Drops an entity's object and claim without needing the entity to be alive.
public void Clear()Drops everything, for a world being torn down.
public static BoundingSphere Transformed(in BoundingSphere local, in Matrix4x4 matrix)A mesh-space bounding sphere in world space.
Used by (6)
- ArenaThirdPersonShooter
- MeshExtractionTestsVixen.Rendering.Tests
- VirtualGeometryExtractionTestsVixen.Rendering.Tests
- WorldRendererVixen.Engine.Renderer
- WorldRendererTestsVixen.Engine.Renderer.Tests
- HostedRendererTestsVixen.App.Tests