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

Support Compatibility Renderer #217

Closed
TokisanGames opened this issue Sep 25, 2023 · 13 comments · Fixed by #500
Closed

Support Compatibility Renderer #217

TokisanGames opened this issue Sep 25, 2023 · 13 comments · Fixed by #500
Assignees
Labels
enhancement New feature or request
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)

@TokisanGames TokisanGames changed the title Write Simpler shaders for Compatibility / WebGL Support Compatibility / WebGL Jul 9, 2024
@TokisanGames
Copy link
Owner Author

Minor update:

  • In 4.2.2, the minimum shader works with the compatibility renderer to produce a greyscale terrain with heights.
  • The PR to provide 3D textures support to allow us to get albedo textures out of the texture array was merged into 4.3, but not 4.2.
  • A custom shader that adds your own texture uniforms and works. One could copy the autoshader code out of the main shader and have a nice looking terrain right now with only two textures, just like the demo.
  • The mouse cursor doesn't work, as it is a GPU driven, so no sculpting in this mode. Perhaps the GPU mouse will work in 4.3 or with some minor adjustment to the shader. Otherwise, we'll need to have a non-gpu fallback, returning to this version of get_intersection()

@Xtarsia
Copy link
Contributor

Xtarsia commented Sep 17, 2024

when we move to 4.3, the texture array issue is now fixed, thanks to this pr
godotengine/godot#91365

a compatability insert that has these defines covers initial shader errors

#define fma(a, b, c) (a) * (b) + (c)
#define dFdxCoarse(a) dFdx(a)
#define dFdyCoarse(a) dFdy(a)
#define textureQueryLod(a, b) vec4(0.0)

The GPU mouse needs its shader modifying, and its own defines so it can work correctly in compatability.

the only thing left is the decal, which can be drawn directly on the terrain (we could move to this for all render modes.)

@TokisanGames TokisanGames removed the waiting for godot Bug or missing feature in the engine label Sep 26, 2024
@TokisanGames
Copy link
Owner Author

PR #500 provides support for Compatibility and maybe webgl if you guys want to test and review it. 4.3 recommended. 4.2 works if you import your textures as Lossless.

cc: @Saul2022

@Saul2022
Copy link

PR #500 provides support for Compatibility and maybe webgl if you guys want to test and review it. 4.3 recommended

cc: @Saul2022

Is there any artifact of it? I am still stuck with just my phone, and building from there from what i tried with java is just too time consuming and i am on institute now ( have to do 2 batx again so barely any time).

@Xtarsia
Copy link
Contributor

Xtarsia commented Sep 26, 2024

@Saul2022

there is, linked at the bottom of the PR. (tho its of the original PR for now)

@TokisanGames TokisanGames changed the title Support Compatibility / WebGL Support Compatibility Renderer Sep 28, 2024
@TokisanGames TokisanGames added enhancement New feature or request and removed bug Something isn't working labels Sep 28, 2024
@TokisanGames
Copy link
Owner Author

TokisanGames commented Oct 2, 2024

Compatibility mode has been implemented thanks to @Xtarsia . Try it out in nightly builds. Read about caveats here
https://terrain3d.readthedocs.io/en/latest/docs/platforms.html#compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants