Skip to content

Fix wrong GL DepthTest param#5659

Open
Helwor wants to merge 2 commits into
ZeroK-RTS:masterfrom
Helwor:patch-1
Open

Fix wrong GL DepthTest param#5659
Helwor wants to merge 2 commits into
ZeroK-RTS:masterfrom
Helwor:patch-1

Conversation

@Helwor
Copy link
Copy Markdown
Contributor

@Helwor Helwor commented Jan 15, 2026

That may disturb other widgets (especially Eco Drawer).

@GoogleFrog
Copy link
Copy Markdown
Contributor

Have you checked whether the widget that runs after this one (by default) happens to rely on this state being left there?

@GoogleFrog
Copy link
Copy Markdown
Contributor

I ask because either you've tested it, or I am going to have to.

@sprunk
Copy link
Copy Markdown
Member

sprunk commented Feb 7, 2026

widget:DrawGroundDeferred() doesn't seem to be a real thing. Maybe it's BAR specific?

The full list of widgets using widget:DrawWorldPreUnit() after enabling this one:

Mex Placement Handler
Custom Markers
Lups
AllyCursors
Map Edge Extension
Commands FX
Map Edge Extension 2        <----
Showeco and Grid Drawer
Missile Impact Points
Defense Range Zero-K
Decloak Range
Antinuke Coverage
Selected Units GL4 2
API Unit Tracker GL4

It looks like lots of things below and above happens to rely on whatever state they inherit from the previous widget. I put a little test on the glDepthTest-debug branch and at least defense ranges, antinuke ranges, mex spots, and OD pylon circles get broken in various ways if they start with the wrong glDepthTest value.

image image

@Helwor
Copy link
Copy Markdown
Contributor Author

Helwor commented May 12, 2026

Yes I've tested it.
As a widget, when you says gl.DepthTest(true) you expect it will suppress anything below ground.
For that it need the param to be set to GL.LEQUAL (or GL.LESS but it's not default). So having it as GL.ALWAYS is obviously problematic. It basically means that a widget doing gl.DepthTest(true) will draw as same as gl.DepthTest(false) aka draw everything. Widgets never expect that param to be changed. A widget that changes it should mandatorily reset it at the end.
Letting DepthTest ON or OFF, is a bit less problematic bc usually a widget will explicitly say if he want to draw with depth constraints or not. From what I understood: DrawWorldPreUnit have DepthTest false by default and DrawWorld have it true, not sure 100%.
Letting Culling ON is problematic bc a widget usually don't expect the culling to be activated and don't bother set it to false before drawing.
Letting Culling Param is less problematic bc a widget using culling will most likely explicitely state which face he want to cull.
Eco Drawer use a shadow volume stencil trick to draw circles perfectly on the ground (glVolumes.lua). For that it need culling to be false and expect depth test to be GL.LEQUAL when activated.
Idk about other widgets, but if they are disturbed by that change (depth param GL.LEQUAL, culling false), they should adapt imo. For the reasons cited above...

@Helwor
Copy link
Copy Markdown
Contributor Author

Helwor commented May 12, 2026

I havent tested it yet, but widget:DrawGroundDeferred() is probably relying on Spring Settings
AllowDrawMapPostDeferredEvents
AllowDrawMapDeferredEvents
AlwaysSendDrawGroundEvents

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants