Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

webgl not supported #8

Closed
gzzo opened this issue Jun 3, 2021 · 5 comments
Closed

webgl not supported #8

gzzo opened this issue Jun 3, 2021 · 5 comments

Comments

@gzzo
Copy link

gzzo commented Jun 3, 2021

It looks like this library can't run on webgl due to something with the shaders. I know this library is not supported anymore officially, but I'm wondering if there is a way to support webgl with this library. Happy to contribute a fix, just need some guidance.

@zicklag
Copy link
Member

zicklag commented Jun 3, 2021

Hey there!

You are correct that WebGL isn't supported because of the shaders. Unfortunately I don't know of a great way to avoid having to write the shaders twice, with one version for web and another version for desktop. I know there are some shader compilers out there, but most of them don't compile desktop shaders to WebGL shaders as far as I know.

I think the only thing necessary would be to convert the shaders in this folder from GLSL 4.50 to GLSL ES 3.00. That seems to be what the bevy_webgl2 library has done here, they seem to have re-implemented all of the built-in Bevy shaders in GLSL ES 3.00.

I never got to the point of actually testing that that worked, though so I'm not sure if you would run into other issues. I don't have any experience with bevy_webgl2 yet so I don't know.

Happy to contribute a fix, just need some guidance.

Absolutely! I'd be glad to merge anything you come up with if it works. Let me know if you have any other questions.

@zicklag
Copy link
Member

zicklag commented Jun 16, 2021

I've recently discovered that spirv-cross is actually capable of compiling GLSL 4.0 to GLSL ES 3.0. I'm not sure if there is a way to do it through the commandline, but I've found that the rafx project's shader processor does it using the Rust bindings to spirv-cross. That could mean we could automatically convert the shader to version we need, but I still have to do some research.

@zicklag
Copy link
Member

zicklag commented Jun 16, 2021

Just created a gist that shows how to convert the shaders with Rust. I might try it out sometime to see if that fixes web support, but if I don't get to it that's something you can try:

https://gist.github.com/zicklag/4223939751c5bf50094a2a85bd75e411

@zicklag
Copy link
Member

zicklag commented Jun 18, 2021

Well, after looking into the translated shaders I found that we currently use shader features not supported in WebGL. That means that we'd probably have to refactor the way maps are rendered a bit, which is probably better anyway because the maps currently have rendering issues anyway.

Eventually, once bevy's done with their rendering rework that is being discussed here, I think we may end up using this library again after porting Bevy Retro to use Bevy's renderer. If that happens that I'll be working on getting this working again.

@zicklag
Copy link
Member

zicklag commented Aug 9, 2021

Bevy LDtk is getting merged into Bevy Retrograde so I'm closing this issue and archiveing the repo. Soon Bevy Retrograde will support Bevy's renderer ( katharostech/bevy_retrograde#41 ) which will allow you to use bevy_retrograde_ldtk alone with out-of-the-box Bevy, removing the need to have separate plugins for Bevy and Bevy Retrograde.

Additionally we are working on integrating Bevy's new renderer with WebGL support so the new LDtk plugin will work with WebGL when we get that working.

You won't be able to comment after the repo is archived, but you can redirect any questions or comments to the Bevy Retrograde discussions page!

@zicklag zicklag closed this as completed Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants