-
Notifications
You must be signed in to change notification settings - Fork 134
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
HTML WebGL support #502
Comments
for refrence, this project is a working example of GDextension exported to web, and is under MIT https://github.com/kiwijuice56/sand-slide - working example in chrome browser in itch.io too! |
Ok, I have the demo scene building and loading. Updated instructions in Op. However there are three problems:
|
New url. Back tick ` will also capture the mouse, and arrow keys will turn the camera. It seems that all the samplers need highp. Including those in uniforms.glsl. Here's the full console log, after adding additional highps: The last remaining shader error is:
These lines are:
I'm not sure why webgl doesn't like these array indices compared to our other array indices.
I think this should be |
Alright, next error is 256 instances of this before it stops:
I changed controlmap to sampler2DArray and put in floatBitsToUint() around the calls. However that didn't fix it or change the number of errors. I don't have any shader dumps or identification as to what line it doesn't like. |
did you catch all 5 instances of the control map reads? |
No, I have 7 instances. 5 in main, 1 editor functions, 1 debug views. Worked on desktop. |
theres actually a few more in debug views now you mention that, but those shouldnt cause problems unless they are on. |
I have it rendering something now. https://tokisan.com/terrain3d_demo/demo.html This is using the minimum shader with a gradient color applied. Albedo is only blue. These grey spots appear only near the camera, and they are usually constantly moving around, even when the camera is still. But at some angles they are still. Removing source_color from the mouse depth didn't help Just highp with a usampler didn't work. This needed highp and sampler/floatbitstouint. Holes work surprisingly. I thought it complained about dividing by 0 before, but it doesn't care about it now. Here's my working minimum.txt shader. This full_shader.txt produces the errors noted above. |
This version of the full shader works. working_shader.txt |
#512 has a working web build. |
Description
#500 brings support for the compatibility renderer. However, we haven't been successful getting an HTML export working. It's unclear if this is due to our process, or bugs in Terrain3D or Godot.
Here is the process so far.
A key point is that the terrain build, the export template, and export settings need to match the same thread support. All three marked on or off.
Docs
Building instructions
https://docs.godotengine.org/en/stable/contributing/development/compiling/compiling_for_web.html
Godot Export for web docs
https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_web.html
Building
To build the extension for web you must install emscripten, set up the build environment, then build the web assembly version. I installed with scoop, which is how my python is also installed, per the Godot building instructions.
Emscripten seems to be very finicky about versions. Akien reports they are using v3.1.64 for 4.3 stable builds.
This file needs to be added to
terrain.gdextension
These are also untested possibilities:
Exporting
C:/Users/Cory/AppData/Roaming/Godot/export_templates/4.3.stable/web_dlink_nothreads_debug.zip
Extensions Support
Threads Support
is disabled to match the other settingsUpload to Webserver
After export, the full package must be uploaded to a webserver. Itch or your own. That server must be configured with SharedArrayBuffer & Cross Origin Isolation.
In nginx this can be enabled with:
On Itch.io , edit game, find the Embed Options section and enable:
SharedArrayBuffer support - (Experimental) This may break parts of the page or your project. Only enable if you know you need it.
Running
I built w/ 4.2.2 and seemed to mostly load but error messages complained that my scene files were built for 4.3?? So I built and exported everything with 4.3: godot source, godot-cpp, Godot binary, Godot export templates.
Edge complained about being unable to load the textures if compressed with vram compressed. But no complains using vram uncompressed.
Currently it loads to the godot logo, then our demo scene w/ player and blue sky, but the terrain doesn't render and has no collision.
Errors & Solutions
Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #0 "env" "memory": mismatch in shared state of memory, declared = 1, imported = 0
This is a mismatch of thread options: godotengine/godot#94537
Ensure all builds and settings are set to not threaded (or all threaded, untested).
The text was updated successfully, but these errors were encountered: