Better compatibility for WGSL on WebGL2
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
Since WGSL does work when targetting WebGL2, it would be lovely if we could add a form of preprocessing for cases where discard to exist in or get imported to a vertex shader source.
That way we can just reuse the WGSL library for WebGL2 targets instead of needing specialized/seperate shaders.
Currently importing bevy_pbr::pbr_functions in a vertex shader source will fail at the validation step in all major browsers.
https://github.com/bevyengine/bevy/blob/main/crates/bevy_pbr/src/render/pbr_functions.wgsl#L24
It's fairly difficult to debug, since the only proper hint we get is the following:
`Internal error in VERTEX shader: ERROR: [line-here]:[column-here]: 'discard' : discard supported in fragment shaders only
`
Or maybe it should just be upstreamed to wgpu/naga.
Contributor guide
Research direction
Start with crates/bevy_pbr/src/render/pbr_functions.wgsl around line 24 and reproduce the validation failure when importing bevy_pbr::pbr_functions into a vertex shader targeting WebGL2. Trace the relevant preprocessing or validation path, and determine whether the compatibility change belongs in Bevy or should be upstreamed to wgpu/naga; done means the WGSL library can be reused for WebGL2 without the vertex-shader discard error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100