Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update information about ShaderDef's to indicate how to use non-boolean types in code #13393

Open
robojeb opened this issue May 16, 2024 · 0 comments
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!

Comments

@robojeb
Copy link
Contributor

robojeb commented May 16, 2024

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:

for(int i = 0 i < FLAG; ++i) {...}

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 with u or i (sometimes it is helpful though to be able to use f).

It would also be useful for the shader_defs example to be updated to use a numerical ShaderDefVal to demonstrate their use.

@robojeb robojeb added C-Docs An addition or correction to our documentation S-Needs-Triage This issue needs to be labelled labels May 16, 2024
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen D-Shaders This code uses GPU shader languages S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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!
Projects
None yet
Development

No branches or pull requests

2 participants