bevy
bevy copied to clipboard
Shader defs can now have a value
Objective
- shaders defs can now have a
boolorintvalue #if SHADER_DEF <operator> 3- ok if
SHADER_DEFis defined, has the correct type and pass the comparison ==,!=,>=,>,<,<=supported
- ok if
#SHADER_DEFor#{SHADER_DEF}- will be replaced by the value in the shader code
Migration Guide
- replace
shader_defs.push(String::from("NAME"));byshader_defs.push(String::from("NAME").into()); - if you used shader def
NO_STORAGE_BUFFERS_SUPPORT, check howAVAILABLE_STORAGE_BUFFER_BINDINGSis now used in Bevy default shaders
How will this feature be documented ? As the syntax is proper to bevy, even though resembling what's existing in other solutions, I think documentation and discoverability will be very important :)
Examples and Bevy book.
If this get merged, I'll continue on adding features to shader defs, the two I have planned is being able to define a shader def from inside a shader, and being able to have a function as a shader def. They will both be somewhat more complicated, so I'll do it small PR by small PR. But they will also have a lot more added value and it will be quite easier to show how this can be used.
Very nice work! I love the changes / they resolved all of my comments.
bors r+
bors retry
Pull request successfully merged into main.
Build succeeded:
- build-and-install-on-iOS
- build-android
- build (macos-latest)
- build (ubuntu-latest)
- build-wasm
- build (windows-latest)
- build-without-default-features (bevy)
- build-without-default-features (bevy_ecs)
- build-without-default-features (bevy_reflect)
- check-compiles
- check-doc
- check-missing-examples-in-docs
- ci
- markdownlint
- run-examples
- run-examples-on-wasm
- run-examples-on-windows-dx12