godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.41k stars 21.26k forks source link

Z-fighting occurs when a CSG node is selected due to gizmo drawing #99184

Open fire opened 1 week ago

fire commented 1 week ago

Tested versions

System information

Windows 11

Issue description

https://github.com/godotengine/godot/pull/94321 @aaronfranke mentioned that CSG has Z-fighting when a CSG node is selected

Steps to reproduce

Select the second csg node and fly around.

https://github.com/user-attachments/assets/e50594c9-e23d-4e3b-9a9c-3067fa643984

Minimal reproduction project (MRP)

csg_flicker.zip

JekSun97 commented 1 week ago

I also mentioned this problem here #96969

Calinou commented 1 week ago

This can be fixed by offsetting the gizmo's vertices in a way similar to the BaseMaterial3D's grow property. This is not currently exposed in the 3D material gizmos, so it should be done (or implemented manually on the CPU, but that would be slower).

If only we had glPolygonOffset() in modern low-level graphics APIs... It would greatly simplify the implementation of https://github.com/godotengine/godot-proposals/issues/1000 as well.