public sealed class SpriteRenderFeatureDraws sprites: textured quads in their own plane, cut into nine when they have a border.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Doc 06 § Geometry and materials, the row that says sprites share the UI batcher. What is shared is the arithmetic and the shape of the answer, not the assembly: the nine pairs of rectangles come from NineSlice in Vixen.Core.Mathematics, which is also what UiGeometryBuilder cuts a panel's background with, and both sides expand a batch of quads into one buffer and draw it in one call. They cannot share code beyond that, because Vixen.Ui describes a frame without a device and this describes a device without an element tree.
Local space, and that is the whole difference from the particle feature. A sprite's quads are built around its pivot with no camera in them, so the geometry is the same for every view that draws it — one expansion a frame rather than one a view — and where the sprite is comes from TransformRenderFeature pushing a matrix, the same way a mesh's does. A camera-facing sprite is therefore not this feature's job: that is a billboard, it has to be built against a view, and asking one object to answer "where am I" twice is how a shadow pass ends up drawing a different scene from the camera.
⚠ Rebuilt every frame, including the sprites that did not move. A still sprite has the same nine quads it had last frame and this writes them again — which is the cost the particle feature pays for a reason that does not apply here, and it is a deliberate holdover rather than an oversight: caching needs a version per object and an invalidation on every field of SpriteAppearance, and the write is thirty-six vertices. What would make it worth doing is a scene of tens of thousands of static sprites — a tile map — which is the case that wants one batched mesh rather than one object each anyway.
Fields and properties (10)
public override string NameThe feature's name, for logging and profiling.
public RenderDataKey<SpriteDraw> DrawsWhere each sprite's run is. One entry per object.
public RenderDataKey<int> SpriteIndicesEach object's sprite, as one more than its index in Known. Zero for none.
public RenderDataKey<SpriteAppearance> AppearancesHow each object's sprite is drawn.
public IReadOnlyList<Sprite> KnownThe distinct sprites this feature has been given.
public IGraphicsDevice? DeviceThe device the buffers live on. Set before the first frame that draws.
public PipelineCache? PipelinesWhere pipelines come from. Set before the first frame that draws.
public IPipelineDescriber? DescriberHow a pipeline is described for a given effect, stage and output.
public int VertexLayoutWhich vertex layout SpriteVertex is, as an index into the describer's table.
public int LastQuadCountHow many quads the last frame expanded, across every sprite.
Methods (8)
public void SetSprite(RenderObjectId id, Sprite? sprite)Attaches a sprite to an object.
public void SetAppearance(RenderObjectId id, in SpriteAppearance appearance)Says how an object's sprite is drawn.
public Sprite? SpriteOf(RenderObjectId id)The sprite an object is showing, or null.
protected internal override void Initialize(RenderSystem system)Registers this feature's own per-object data. Called once, when it is added.
protected internal override void Prepare(RenderSystem system)protected internal override void Draw(RenderSystem system, RenderDrawContext context, ReadOnlySpan<RenderNode> nodes)Records this feature's share of one stage's work into a command list.
protected internal override uint SortGroupOf(RenderSystem system, RenderObjectId id, RenderStage stage)public void Dispose()Frees the buffers.
Used by (2)
- HarnessVixen.Rendering.Tests
- SpriteRenderFeatureTestsVixen.Rendering.Tests