Skip to content
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

Write Simpler shaders for Compatibility / WebGL #217

Open
TokisanGames opened this issue Sep 25, 2023 · 7 comments
Open

Write Simpler shaders for Compatibility / WebGL #217

TokisanGames opened this issue Sep 25, 2023 · 7 comments
Labels
bug Something isn't working waiting for godot Bug or missing feature in the engine
Milestone

Comments

@TokisanGames
Copy link
Owner

TokisanGames commented Sep 25, 2023

Switch to compatibility mode and the textures are black. Supposedly texture arrays are not supported. However height and the colormap are there, so some texture arrays are being read. So it's unclear what is supported exactly.

Also opengl doesn't support FMA, so a macro should be made to replace fma with *+ via code or have two separate shaders.

Waiting for OpenGL support in Godot:

@TokisanGames TokisanGames added the bug Something isn't working label Sep 25, 2023
@TokisanGames TokisanGames added this to the Stable milestone Sep 25, 2023
@directedchaossoftware
Copy link
Contributor

I wonder if this would help iOS, where I am seeing the heightmap mesh (including shadows) but with the "chess squares" shader issue (as if it had no textures?). This is with the Godot Project Settings->General->Renderering->Renderer->Rendering Method options: forward_plus or mobile (gl_compatibility shows an all grey plane, no height at all or squares).

It looks like iOS is unsupported, but I managed to build for iOS (scons platform=ios), updated the terrain.gdextension file to point to the resulting libterrain.ios.debug.universal.dylib and exported without much trouble (and some hints from the Android discussion).

@TokisanGames
Copy link
Owner Author

TokisanGames commented Sep 26, 2023

If you can render forward_plus or mobile, then that is not related to this issue. What you see on gl_compatibility is this thread.

Thanks for letting me know about ios builds. This is the first I've heard about anyone trying it. Please post the full lines that you put in terrain.gdextension. It will help for later when it does maybe become a supported platform. You can make a separate ios support issue if you like so we can keep the discussions focused.

The chess squares are textures generated and placed in the texture list. If the forward renderer is displaying them, then there might be another issue as to why the grass/rock textures aren't showing, such as something with export. Let's discuss further on an IOS thread.

@TokisanGames
Copy link
Owner Author

Apparently shadows aren't included in the compatibility renderer yet. Who knows what else isn't finished. This should wait until 4.2 is out with its compatibility shader improvements

godotengine/godot#77496

@filipworksdev
Copy link

you can see here what is and isn't finished godotengine/godot#66458

@TokisanGames TokisanGames added the waiting for godot Bug or missing feature in the engine label Sep 28, 2023
@TokisanGames
Copy link
Owner Author

Here specifically texturearrays are not supported. (even though we read them for height and color) the issue shows it doesn't work for albedo.

godotengine/godot#71029

@JohnathonNow
Copy link

JohnathonNow commented Feb 8, 2024

Looks like some big progress towards support got merged last night. There's some wonkiness with the shader but I at least see textures on a web build now. Edit: biggest issue seems to be that usampler2Ds don't seem to work. I wonder if you can work around it with floatBitsToUint?

@TokisanGames
Copy link
Owner Author

TokisanGames commented Feb 8, 2024

Looks like some big progress towards support got merged last night. There's some wonkiness with the shader but I at least see textures on a web build now.

That's good news.

Edit: biggest issue seems to be that usampler2Ds don't seem to work.

The control map uses usamplers for texture placement. You should get no textures if it's not working, or a broken shader if it's an unsupported command.

I wonder if you can work around it with floatBitsToUint?

Yes, you could change the usampler to sampler and wrap the control texelfetches with floatBitsToUint().

But if it's true that usamplers are not supported in opengl, then the better solution is for Godot to support standard opengl formats, including usamplers (which may not have a separate ticket) and that we stay on them until these issues are tracked and implemented.

We store the control map as a 32-bit uint directly in memory, then the shader reads a 32-bit uint out of memory. The whole path through the Image/Texture/RenderingServer/RenderingDevice Godot thinks of that portion of memory as a 32-bit float, but we don't care because it doesn't change it. The contents of that memory are a 32-bit uint. If read as a float it's garbage data. Reading it as a usampler is direct. Reading it as a sampler and recasting it with floatBitsToUint can work for an extra step. See all of this ticket, especially my final comment regarding using usamplers and encoding floats.
godotengine/godot#57841 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for godot Bug or missing feature in the engine
Projects
Status: 1.0-Stable
Development

No branches or pull requests

4 participants