Does not work in WASM
tliron opened this issue · comments
Great library! Unfortunately it doesn't work in WASM, at least not for me. :)
Here's the panic I get (when testing in Firefox). All I did here was add the plugin:
panicked at /home/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.4/src/backend/wgpu_core.rs:3006:5:
wgpu error: Validation Error
Caused by:
In Device::create_bind_group_layout
note: label = `lighting_bind_group_layout`
Too many bindings of type StorageBuffers in Stage ShaderStages(FRAGMENT), limit is 0, count was 1. Check the limit `max_storage_buffers_per_shader_stage` passed to `Adapter::request_device`
Thanks for letting me know!
I haven't used wasm before, but I will see what I can piece together 👍
@tliron It looks like the library only works with wgpu
at the moment. Are you able to get things running by including the webgpu
feature flag from Bevy?
I might need to add a note to the README
to make this restriction clear.
Hm, well I have avoided WebGPU so far, because it's still broadly unsupported and experimental. I tried a quick build with wgpu
, but I'm unable to get it running at all. Firefox doesn't support WebGPU and Chrome gives me a "Unable to find a GPU" panic. I'm on Linux here, so maybe WebGPU isn't support at all.
Do you have an idea of what's stopping bevy_light_2d from supporting plain old WebGL?
Yes, I'm fairly certain it's the storage buffer in the shader. I did a quick test removing it (and the point lights), and was able to get it working. I believe if we port that over to a uniform buffer things will work.
See #6 for a tracker.
Additional: I jumped through some hoops to get WebGPU/Chrome/Linux working. It's extremely janky and unbearably slow, but it does work. :) It's just not viable for any of my work at present.
Great, thanks for the data point. I'll see about getting WebGL2 working next time I sit down with this.
@tliron I took a look at this last night.
Turns out that passing in a runtime sized array into a uniform buffer isn't a supported operation. Sounds like we'd need to get tricky with storing the array of point lights in a texture, and reading the data from there.
There's also the consideration that to support WebGL2, we wouldn't be able to use compute shaders, which I've been hoping to take advantage of for light occlusion.
I'd love to support WebGL2, but I don't currently have a strong understanding on how to reasonably sidestep the limitations.
Yeah, it does sound like it would have to be a different implementation for WebGL. I would add that an OpenGL pipeline could be generally useful for other environments, too, like Android (I think?). But I can understand not wanting to support two different rendering paths.
If you can, though, ... it would be a really nice contribution to the Bevy ecosystem! Bevy + WebGL is used quite a lot for 2D games, for which this plugin adds really amazing pizazz.
Definitely. I'd love to support it! It just might require a bit of re-working to get there (or not supporting certain features like light occlusion if we can't find workarounds). Will keep it in mind.
Let's use #6 to track this issue? It's a bit more discover-able.
For now I've added a note to the README to state that web support is currently limited to WebGPU 👍