vkQuake icon indicating copy to clipboard operation
vkQuake copied to clipboard

Bad water transparency layering in start level

Open Macil opened this issue 1 year ago • 14 comments

In the start level (using the rerelease basedir), if you look at the water before episode 4, you can see that specific sections of the bottom surface incorrectly render over specific sections of the top surface. (Specifically, the upper surface's right third allows all of the lower surface to render over it, and the upper surface's left two-thirds allows the lower surface's far-left corner to render over it.)

vkquake0002

This isn't a recent issue. I've tested master and a few months-old commits and they each show the issue the same way. The issue is not affected by "r_alphasort 0".

I can consistently reproduce this on both MacOS and Linux that I've tested on.

Macil avatar Mar 13 '23 06:03 Macil

@temx Not sure about this. Shouldn't the BSP recursive walk alpha sorting have fixed this one?

Novum avatar Mar 13 '23 06:03 Novum

That's not done for the worldmodel. It'd require walking the entire map tree looking for water surfaces, I haven't tried but I suspect it'd be quite slow for large maps. Maybe a pruned tree could be created at load time? I don't think it's worth it for one map with strangely split water.

temx avatar Mar 13 '23 10:03 temx

I did a quick test - see branch sorted-world-water, requires indirect path. It fixes this but slowdowns large maps by over 10x. R_RecursiveNode could be made faster, but it's unlikely this will ever be practical without some preprocessing.

temx avatar Mar 13 '23 12:03 temx

I added some basic pruning, the speed hit is greatly lessened but can still be in the >10% range.

temx avatar Mar 13 '23 13:03 temx

The issue seems to happen in qs too: https://github.com/sezero/quakespasm/issues/53 .. but only in rerelease start map. Does this actually happen anywhere else?

sezero avatar Mar 13 '23 13:03 sezero

@temx Okay, not really worth it. @sezero Seems like a new vis patch for the rerelease data would work?

Novum avatar Mar 13 '23 15:03 Novum

@sezero Seems like a new vis patch for the rerelease data would work?

Really don't know, never ever tried it

sezero avatar Mar 13 '23 15:03 sezero

It's not a vis problem (though DOPA does have plenty of vis problems, since the VIS compiler used considers fence textures opaque - these can be fixed with r_novis 1 which is what the rerelease implicitly does).

The BSP tool chose to cut this water volume in an unfortunate order. I don't have visualization of the planes, but you can kind of guess where they are from the results: It sliced it vertically twice (into three parts) before the horizontal cuts, which would ideally be first. I don't think patching this in the BSP is practical.

I've made another tweak to the pruning, and now the cost for large levels is around 3-7% without tasks, and 1-2% with (it's usually not in the critical path). Probably not worth it for a single map.

temx avatar Mar 13 '23 17:03 temx

Okay, I think I'll keep this bug open - perhaps forever.

Novum avatar Mar 13 '23 17:03 Novum

So, it's a map-specific issue and not worth caring about much, yes?

sezero avatar Mar 13 '23 17:03 sezero

Technically it's an engine bug, but there is cost to walking the BSP recursively back to front so it might not be worth doing it just for this case.

I believe the original Quake did a recursive walk for transparency but it was removed in later source ports for performance reasons.

Novum avatar Mar 13 '23 17:03 Novum

No transparency in the original, but it did walk front-to-back to get correct, zero overdraw drawing without a Z-buffer. Just don't ask how it handled brush or alias models (clipping the polygons into the world tree for the former, or building a Z-buffer just for the latter).

temx avatar Mar 13 '23 17:03 temx

I actually know that! It was writing a Z value during zero overdraw span-based raster and alias was rendered with z check and write.

Novum avatar Mar 13 '23 17:03 Novum

I found another place with bad water transparency layering: "Abyss of the troglodytes" (d2m8) of Dwell v2.2. Here's a save looking right at the issue: s2.sav.zip.

vkquake0000

Macil avatar Apr 25 '23 02:04 Macil