-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lacking compute support (HTML5) #2177
Comments
WebGL 2.0 is a subset of OpenGL ES 3.0, which itself doesn't support compute shaders. This feature is impossible to support until WebGPU comes around, and that won't happen before 4.0 (if not later). The same applies to the GLES3 and GLES2 renderers on desktop. |
Yep that makes sense why it wasn't working in the HTML5 version! However I have found a workaround, as can bee seen at the end of the docs for this project. |
@tavurth Godot doesn't have "true" compute shader support in 3.x. Reading your proposals, it seems you're using particle shaders as a hack for compute shader functionality, hence the issue title I applied. |
Almost, I'm using canvas shaders (2d texture rendering, rather than vertex rendering), and yes I would say it's lacking, however this issue should still be relevant when moving to the new 4.0 backend. (unless work is done on this) |
Are you saying that Viewports are broken in HTML5? If so, this sounds like it needs to be a bug report rather than a proposal. |
Can you provide some information on your OS and browser? |
Here's an exported template of this repo Unzip then run The code works just fine in Godot, but when exporting to HTML5 it breaks. Workaround version ( |
Did you try other browsers?
|
I'm seeing the following warning with that project running in Firefox: |
This is very clearly a limitation of WebGL. I'm surprised it even works on desktop. To do GPGPU using framebuffers you should always use 2 framebuffers and rotate between them. This should be moved to the Godot repo and tagged as a documentation issue. |
@clayjohn interesting, so basically double buffering. |
Essentially yes. Rendering to the same Viewport that you are reading from is not well supported (and I'm pretty sure the OpenGL specification forbids it). Instead you should use what is often called a "ping pong" approach. The Sprite under Viewport A reads from Viewport B. While the Sprite under Viewport B reads from Viewport A. Depending on your program the Sprite in Viewport B may simply just copy the contents of Viewport A into Viewport B (e.g. for simulating the game of life). While for other effects (e.g. blur) you may apply your effect in both Viewports. This is the approach you will find used in all OpenGL programs prior to the introduction of general purpose compute. |
It seems like Godot was not happy with the A third bug I seem to have run into is that the |
I will submit these as bug reports in time after I've tested a bit more. The demo is updated here: |
Describe the project you are working on
A water depth & velocity simulation shader in 2D (from above).
Describe the problem or limitation you are having in your project
I've run into many issues while dealing with Godot's shader language, and I wanted to start this post as part of my documentation of such. When dealing with the current shader implementation I feel like my hands are tied many times, which leads me to believe that the current shader implementation keeps Godot far behind other engines.
No compute support (or inconsistent)
I've been using a lot of compute shaders using Viewports & only clearing the screen on the next render. This is extremely useful for people making CA (cellular automata), however at present support in Godot is lacking or buggy.
An example of this can be found here.
FBO (viewport) is not currently fully cross compatible to the WEBASM version of Godot, which means we lose portability.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
See above
If this enhancement will not be used often, can it be worked around with a few lines of script?
This enhancement will affect anyone who has more than a passing interest in shaders.
Is there a reason why this should be core and not an add-on in the asset library?
Shader language improvements must be core.
The text was updated successfully, but these errors were encountered: