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

Setting the Viewport's scaling_3d_scale to any value except 1.0 while the WorldEnvironment's background_mode is set to BG_CANVAS breaks Z sorting in Compatibility renderer. #97039

Closed
atomius0 opened this issue Sep 15, 2024 · 2 comments · Fixed by #97131

Comments

@atomius0
Copy link

Tested versions

  • Reproducible in: v4.3.stable.official [77dcf97], v4.4.dev2.official [97ef3c8]

System information

Godot v4.3.stable - Fedora Linux 37 (KDE Plasma) - X11 - GLES3 (Compatibility) - AMD Radeon RX 6650 XT (navi23, LLVM 15.0.7, DRM 3.49, 6.2.8-200.fc37.x86_64) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

Issue description

In a 3D scene, the Z sorting(?) breaks when setting the Viewport's "scaling_3d_scale" (or "rendering/scaling_3d/scale" in the project settings) to any value except 1.0 while the WorldEnvironment's background_mode is set to "Canvas" (Environment.BG_CANVAS).

Setting the scaling_3d_scale back to 1.0, or changing the background_mode to "Clear Color" (Environment.BG_CLEAR_COLOR) makes the Z sorting go back to normal.

This issue only occurs with the Compatibility renderer. (I tested it on Linux, Windows and in Web exports)
It does not occur when using the Forward+ or Mobile renderers.

The same issue occurs with these configurations, too (the System information field only allows one line, so I'll paste them here):

  • Godot v4.4.dev2 - Fedora Linux 37 (KDE Plasma) - X11 - OpenGL 3 (Compatibility) - AMD Radeon RX 6650 XT (navi23, LLVM 15.0.7, DRM 3.49, 6.2.8-200.fc37.x86_64) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

  • Godot v4.3.stable - Windows 6.1.7601 - GLES3 (Compatibility) - GeForce GTX 750 Ti - AMD FX(tm)-6350 Six-Core Processor (6 Threads)

Steps to reproduce

  • run the minimal reproduction project: everything looks normal.
    Screenshot_20240915_144121

  • drag the "scaling_3d_scale" slider to any value other than 1.0: Z sorting breaks.
    Screenshot_20240915_144131

  • change "background_mode" to "Clear Color": it looks fine again, no matter what scale it is set to.
    Screenshot_20240915_144135

Minimal reproduction project (MRP)

env_bg_canvas_z_bug.zip

@matheusmdx
Copy link
Contributor

Bisecting points to #87360 as the culprit, @BastiaanOlij

image

@akien-mga akien-mga added this to the 4.4 milestone Sep 17, 2024
@BastiaanOlij
Copy link
Contributor

GRMBL dumb global state in OpenGL.....

One thing we fixed in that PR is that we copy the canvas into the background which was missing. But I made a booboo:

https://github.com/BastiaanOlij/godot/blob/aa260e5f3d4ce0c5551e84ef0b098ddf9e78fd0d/drivers/gles3/rasterizer_scene_gles3.cpp#L2612

Notice that we turn the depth test off before we copy the canvas into our background.

We never turn it back on again...

oops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants