bevy/examples/shader
Patrick Walton 26f7313212
Allow phase items not associated with meshes to be binned. (#14029)
As reported in #14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`. This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes #14004.

## Changelog

### Added

* `BinnedRenderPhase` now contains a `non_mesh_items` field for plugins
to add custom items to.
2024-06-27 19:41:42 +02:00
..
animate_shader.rs Deprecate shapes in bevy_render::mesh::shape (#11773) 2024-02-08 18:01:34 +00:00
array_texture.rs Removed Into<AssedId<T>> for Handle<T> as mentioned in #12600 (#12655) 2024-03-22 20:26:12 +00:00
compute_shader_game_of_life.rs Handle wgsl errors in the game of life example (#13624) 2024-06-03 13:31:56 +00:00
custom_phase_item.rs Allow phase items not associated with meshes to be binned. (#14029) 2024-06-27 19:41:42 +02:00
custom_vertex_attribute.rs Intern mesh vertex buffer layouts so that we don't have to compare them over and over. (#12216) 2024-03-01 20:56:21 +00:00
extended_material.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
fallback_image.rs Deprecate shapes in bevy_render::mesh::shape (#11773) 2024-02-08 18:01:34 +00:00
gpu_readback.rs Use BufferVec for gpu_readback example (#13668) 2024-06-04 19:31:44 +00:00
post_processing.rs Use dynamic uniform buffer in post processing example (#13540) 2024-06-14 20:55:41 +02:00
shader_defs.rs Intern mesh vertex buffer layouts so that we don't have to compare them over and over. (#12216) 2024-03-01 20:56:21 +00:00
shader_instancing.rs Make render phases render world resources instead of components. (#13277) 2024-05-21 18:23:04 +00:00
shader_material.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
shader_material_2d.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
shader_material_glsl.rs Intern mesh vertex buffer layouts so that we don't have to compare them over and over. (#12216) 2024-03-01 20:56:21 +00:00
shader_material_screenspace_texture.rs Migrate from LegacyColor to bevy_color::Color (#12163) 2024-02-29 19:35:12 +00:00
shader_prepass.rs Updates default Text font size to 24px (#13603) 2024-05-31 16:41:27 +00:00
texture_binding_array.rs Use BindGroupLayoutEntryBuilder in texture_binding_array example (#13169) 2024-05-02 20:10:32 +00:00