bevy_render: Centralize shader View uniform type
Objective
- Keep the shader-side definition of the
ViewUniformstruct in one place, inbevy_render - The long-term fix from #5512 and #5531
Solution
- Move shader
Viewstruct to a shader import atbevy_render::view_types - Make shader view bindings for binding the view uniform to group 0 binding 0 as this is very common, at
bevy_render::view_bindings- note that this itself importsbevy_render::view_typesfor convenience as we have done elsewhere - Remove the shader
Viewstruct frommesh_view_types.wgslinbevy_pbr,mesh2d_view_types.wgslandsprite.wgslinbevy_spriteandui.wgslinbevy_uiand instead make use of the above imports.
Changelog
- Removed:
bevy_sprite::mesh2d_view_typesandbevy_sprite::mesh2d_view_bindings - Added:
bevy_render::view_typesandbevy_render::view_bindings - Changed: All of
bevy_pbr,bevy_sprite, andbevy_uinow usebevy_render::view_typesandbevy_render::view_bindingsto keep the shaderViewstruct in-sync
Migration Guide
If you were using the bevy_sprite::mesh2d_view_types and/or bevy_sprite::mesh2d_view_bindings shader imports, now use bevy_render::view_types and/or bevy_render::view_bindings instead.
I tested lighting, mesh2d, many_sprites, and ui and all look ok to me.
Is this still relevant? Kind of a nice small change
I forgot that this was never merged. Definitely something we want to do in my opinion because of how ViewUniform is reused.
We have centralized the View type under bevy_render::view. With the new import system, it looks like #import bevy_render::view View. However binding imports are still separated inside bevy_pbr::mesh_view_bindings and bevy_sprite::mesh2d_view_bindings.
I like the idea of standardizing the view binding position and consolidating the import under bevy_render. We might also want to standardize the globals binding position to group(0) binding(1) and also place it in bevy_render?