Module bevy_render::render_phase

source ·
Expand description

The modular rendering abstraction responsible for queuing, preparing, sorting and drawing entities as part of separate render phases.

In Bevy each view (camera, or shadow-casting light, etc.) has one or multiple render phases (e.g. opaque, transparent, shadow, etc). They are used to queue entities for rendering. Multiple phases might be required due to different sorting/batching behaviors (e.g. opaque: front to back, transparent: back to front) or because one phase depends on the rendered texture of the previous phase (e.g. for screen-space reflections).

To draw an entity, a corresponding PhaseItem has to be added to one or multiple of these render phases for each view that it is visible in. This must be done in the RenderSet::Queue. After that the render phase sorts them in the RenderSet::PhaseSort. Finally the items are rendered using a single TrackedRenderPass, during the RenderSet::Render.

Therefore each phase item is assigned a Draw function. These set up the state of the TrackedRenderPass (i.e. select the RenderPipeline, configure the BindGroups, etc.) and then issue a draw call, for the corresponding item.

The Draw function trait can either be implemented directly or such a function can be created by composing multiple RenderCommands.

Structs§

Enums§

Traits§

  • Registers a RenderCommand as a Draw function. They are stored inside the DrawFunctions resource of the app.
  • Represents phase items that are placed into bins. The BinKey specifies which bin they’re to be placed in. Bin keys are sorted, and items within the same bin are eligible to be batched together. The elements within the bins aren’t themselves sorted.
  • A PhaseItem item, that automatically sets the appropriate render pipeline, cached in the PipelineCache.
  • A draw function used to draw PhaseItems.
  • An item (entity of the render world) which will be drawn to a texture or the screen, as part of a render phase.
  • RenderCommands are modular standardized pieces of render logic that can be composed into Draw functions.
  • Represents phase items that must be sorted. The SortKey specifies the order that these items are drawn in. These are placed into a single array, and the array as a whole is then sorted.

Functions§