-
Notifications
You must be signed in to change notification settings - Fork 14
Rendering
UGUIDOTS renders by reading all Canvas entities and iterating through each submesh. The OrthographicRenderSystem
internally stores a CommandBuffer and links the CommandBuffer with Orthographic Render Feature.
When the system is destroyed, the internal CommandBuffer is disposed.
During runtime (update loop), the OrthographicRenderSystem
iterates through each Canvas entity and fetches the
- SharedMesh
- Stores the mesh data needed to actual render the canvas
- MaterialPropertyBatch
- Stores material property blocks per submesh
- DynamicBuffer
- Stores a dynamic array of entities which links to the common texture associated with the submesh and the common material associated with the submesh
Let's say we had 3 submeshes, which represent 3 images with different textures.
- Canvas
- Image 1 - square texture
- Image 2 - circle texture
- Image 3 - triangle texture
The Canvas entity will have a MaterialPropertyBatch
of 3 elements and a DynamicBuffer<SubmeshKeyElement>
with potentially
3 pairs of entities linked.
The
MaterialPropertyBatch
is a managed component which stores an array of Material Property Blocks.
The MaterialPropertyBatch
would look like so:
MaterialPropertyBatch
- MaterialPropertyBlock 1
- MaterialPropertyBlock 2
- MaterialPropertyBlock 3
And the DynamicBuffer<SubmeshKeyElement>
would like so:
DynamicBuffer
- SubmeshKeyElement
- Texture 1
- Material 1
- SubmeshKeyElement
- Texture 2
- Material 2
- SubmeshKeyElement
- Texture 3
- Material 3
Depending on the submesh level, the OrthographicRenderSystem
will fetch the corresponding MaterialPropertyBlock and
SubmeshKeyElement, to fetch the texture and material to apply to the MaterialPropertyBlock.