How to assign per-instance custom data to shader extending StandardMaterial #19784
Unanswered
snappa-app
asked this question in
Q&A
Replies: 1 comment
-
Upon further research, it appears that the challenge I am running into is due to mixing the StandardMaterial and per-instance data. I am wondering how to resolve this. Is there a way to set the binding of the per-instance data? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey folks!
I am wondering how to assign modifiable per-instance custom data to a shader. For example, controlling the color of a bunch of cubes all rendered with the same MeshMaterial3d. I've been struggling to find an example for this, so if we figure out a way to do this, I would be happy to add it to the bevy examples if we want.
Goals:
I am going to give you what I have so far in snippets, but I can extract it out to a reproducible example so we can iterate if it's helpful.
In
material.rs
, I have a struct Component that I'd like to embed in each instance. I also have theMaterialExtension
:In
character.wgsl
I have the following to try and read from the CharacterMaterialParameters embedded in the GPU:When I spawn my entity, I add the following
CharacterMaterialParameters
and my extension material Components (also I do add a mesh). I also add a MeshTag:In my plugin, I add the
ExtractComponentPlugin
andUniformComponentPlugin
for my component:I get the following error with this setup:
My hunch is I'm missing something large, or mixing up concepts on my way to getting this working.
My main questions are:
@group(0) @binding(7)
to? I've tried all combinations of groups 0-2, and bindings 0-2. I am wondering if there's a good way to inspect what is embedded in each of those bindings.CharacterMaterialParameters
gets embedded in, or is that handled automatically by theExtractComponentPlugin
?Beta Was this translation helpful? Give feedback.
All reactions