Update information about ShaderDef's to indicate how to use non-boolean types in code #13393
Labels
A-Rendering
Drawing game state to the screen
C-Docs
An addition or correction to our documentation
D-Shaders
This code uses GPU shader languages
D-Straightforward
Simple bug fixes and API improvements, docs, test and examples
S-Ready-For-Implementation
This issue is ready for an implementation PR. Go for it!
How can Bevy's documentation be improved?
Neither the documentation for ShaderDefVal nor for the
shader_defs
field on the Shader (or ComputeShaderPipelines) have any information about how the defined values get passed to your shader.Users coming from a C background might assume that the behavior is like passing
-DFLAG=1
and would use it as a bare identifier:But this results in naga compilation errors about unknown identifiers.
It actually appears that to use a value it must be with in a "preprocessor context" like a
#define
.This is demonstrated fairly well in the
shader_defs
example, but this still doesn't help users know how to use a numerical value in their code.I ended up finding the correct invocation by finding an old issue.
I think that the documentation for
ShaderDefVal
should be updated with examples of how the values defined can be used in a shader. This should include information about some of the strange behavior like how the inserted value will not have a type suffix, so to make many equations work you need to suffix withu
ori
(sometimes it is helpful though to be able to usef
).It would also be useful for the
shader_defs
example to be updated to use a numericalShaderDefVal
to demonstrate their use.The text was updated successfully, but these errors were encountered: