Open thethinur opened 1 year ago
Do you mean WebGL2? WebGPU is not supported on some of the browsers you mention.
Would you have an example that can reproduce that error?
I guess I do, I didn't realize the device was picking GL as a backend by default, I know for a fact Chrome has WebGPU and I can't figure out how to get it to pick WebGPU instead of WebGL2 despite doing what is asked in: https://github.com/bevyengine/bevy/tree/main/examples#wasm
That doesn't matter anymore though.
If anyone could convert this to a feature request instead that would be nice. I'll add a minimal example; once I've stitched one together.
I think this might be fixed by #5703 (if it gets merged) because it will only import shader functions that are used in the end file.
That's great, I hope it filters the end file so you can discard in it, though having to split the fragment shader from the rest for GL compatibility probably wont be too cumbersome. Now that we are moving towards WebGPU in the browser, it would be nice to be able to start working in WGSL while WebGPU isn't available everywhere.
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.