allow user-defined mesh-view bindings#5427
Conversation
|
I agree that the general concept would be really nice to have, but asking users to compose file goes way too much against the easy modularity goals of bevy. I haven't looked at the code yet, but I assume the reason for that is that the bind group index needs to be specified in the shader. My suggestion for that is to inject the index with a shader def. This way, plugin authors could simply add a |
yes exactly.
shader defs (in so i guess i would add another vec to the |
|
Yeah, to be clear I don't think shader defs allows that right now. I meant that it could be extended and use to do something like that. I had in mind something like you are suggesting with a search and replace yes. |
|
added a search/replace on user defined binding strings (which must be WGSL) so that users don't need to worry about binding index with multiple plugins, updated the example. still pretty ugly but much less error prone. (as an aside, running the clippy warnings locally always fails for me in |
Have you tried running |
yes, it gives the same output: |
|
closing in favour of #6738 |
Objective
allow user-defined mesh-view bindings to be added for use in custom materials or user-overridden pbr functions.
Solution
UserViewBindingsLayoutsandUserViewBindingsEntries, add the layouts to MeshPipeline's view_layout at build time and then add entries to the bind group each framebevy_pbr::mesh_view_user_bindingswgsl import which can be overridden to pull the user bindings into the shaderscustom_view_bindingsto show how to use itthe layouts are keyed by a string, so that a plugin doesn't need to know what other plugins are adding view bindings.
unfortunately if multiple plugins with view bindings are being used, the app author will need to make their own composite
bevy_pbr::mesh_view_user_bindingscontaining the bindings from all the plugins (and they will need to have no overlap in names).this is pretty ugly so i welcome any suggestions to improve it, and i won't be upset if it's not accepted - i think the functionality is needed but this may be too hacky.
i can't think of a clean way to specify the bindings per-plugin without extending the preprocessor, and i don't want to do that without feedback on the approach first.