Is there a way to directly specify descriptor sets for custom material uniforms? #13560
Unanswered
pedrotrschneider
asked this question in
Q&A
Replies: 1 comment 1 reply
-
slang has an attribute for specifying the descriptor set for spir-v: https://shader-slang.com/slang/user-guide/spirv-target-specific#vkbindingbinding-int-set-int--0
or if i'm understanding things correctly, you can use |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Hi! I'm in the process of integrating the Slang shading language into Bevy. It's all going super smoothly. I can compile to either GLSL or SPIR-V and it works flawlessly most of the time. My main problem is that there doesn't seem to exist a way to force slang to use a specific descriptor set when compiling, it always binds to descriptor set 0. The problem with that is, for custom materials, Bevy seems to use descriptor set 2 by default for user-defined uniforms. For example, this WGSL shader creates a fullscreen triangle in the vertex shader and, in the fragment shader, draws a pulsating green circle at the center of the screen:
It works much like a post-processing effect but is implemented as a custom shader on a 2D triangle mesh. The problem is that, as I mentioned, there seems to be no way in Slang to bind uniforms to a specific descriptor set, so I can't use uniforms because they always bind to descriptor set 0. I know there was a way to do that in previous versions of Bevy (before
AsBindGroup
), but I can't find any documentation on how to do it in the latest version. Is there something I'm missing?For reference, I'm using Bevy version 13.2, and compiling the Slang code to SPIR-V. I know that the compilation step is not the issue because the same code works if I implement it as a post-processing effect, since post-processing effects allow me to bind stuff to descriptor set 0. I also used naga to translate the compiled SPIR-V code back to WGSL, and manually changed the
@group(0)
to@group(2)
, which also worked. This is the code naga generated for me, based on the SPIR-V code the Slang compiler generated:As I mentioned, this doesn't work, but if I change the
@group(0)
to@group(2)
, it works. This is the rust code I'm using. Basically the standard example for CustomMaterial:Any help would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions