Example that shows custom shader for translucent PBR material
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
If you try and create a custom PBR material, using the existing Bevy examples as a basis, you will discover that transparency and blend modes no longer work. Setting the `alpha_mode` property in the material struct has no effect.
Part of the reason for this is because the example shader code creates a new instance of `PbrInput` (see assets/shaders/array_texture.wgsl for an example). This newly-created instance no longer has the 'flags' field set, which is used to configure the blending modes. However, this is not the only problem, and in fact I was unable to solve the issue.
## What solution would you like?
I'd like to see an example that shows the *correct* way to create a custom shader that supports blending modes.
## What alternative(s) have you considered?
For now, what I am doing is calling `pbr(pbr_input)` and then overwriting the alpha field of the result. However, I'm pretty sure this is not the best way to do it.
Contributor guide
Research direction
Start with the custom shader examples and compare their PbrInput handling with assets/shaders/array_texture.wgsl, focusing on how the flags field and pbr(pbr_input) affect blending. The work is done when an example demonstrates a custom shader for a translucent PBR material with working alpha and blend modes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100