DaemonEngine / Daemon

The Dæmon game engine. With some bits of ioq3 and XreaL.
https://unvanquished.net
BSD 3-Clause "New" or "Revised" License
303 stars 60 forks source link

Creep is rendered behind the glass surface it should be over #1025

Open illwieckz opened 9 months ago

illwieckz commented 9 months ago

Creep is rendered behind the glass surface it should be over:

unvanquished_2024-01-13_143531_000

illwieckz commented 9 months ago

This affects any impact mark:

unvanquished_2024-01-13_151156_000

slipher commented 9 months ago

It's possible that this is the same underlying problem as https://github.com/DaemonEngine/Daemon/issues/906. Either one might be caused by the mark polys being generated insufficiently far in front of the surface.

VReaperV commented 4 weeks ago

This is supposed to be worked around by using polygonOffset, but maybe the factor and offset that we use are wrong.

slipher commented 2 days ago

Creep has the SS_DECAL sort order so it is drawn before almost all translucent surfaces. And it is treated as a translucent surface, so depth doesn't even matter since the dueling surfaces are both translucent.

So the renderer is working as designed here... but it's an old design based on heuristics that favor batching surfaces with a shared texture to improve speed at the cost of correctness.

With the material system, everything renders as we would like, yay! I think it might ignore fine-grained shader sorting distinctions?

Until very recently, the creep texture had only 0 or 1 alpha values. So we could have fixed it without changing the sort order by using depthWrite in the shader. Now it has alpha that fades out at the edges so we couldn't do that.

VReaperV commented 2 days ago

I think it might ignore fine-grained shader sorting distinctions?

Yeah, it essentially skips this sort when adding surfaces since it just does R_AddWorldSurfaces(), and then they either end up in the same material in the order they were received in or implicitly correctly sorted by material.