michael-fadely / sadx-d3d11

MIT License
9 stars 3 forks source link

Z fighting issues #8

Open PiKeyAr opened 6 years ago

PiKeyAr commented 6 years ago

These happen only when OIT is on, 32-bit Z Buffer doesn't help

Pool in the Ice Cap cave in the Mystic Ruins (DC level only) image Water ripple (happens only with the SADX version of the ripple) image Hard to see but this thing in MR Past appears to have some kind of shadow that flickers when the screen moves. It shows up only with OIT when a 24-bit Z Buffer is used, but it also shows up without OIT when a 32-bit Z Buffer is used. image Sky Chase sky looks weird in motion (DC level only) image Character shadow at the bottom of Emerald Coast 2 pond image

michael-fadely commented 6 years ago

The reason for this is the use of a less-equal comparison for transparent fragments. The only reason I do this is for HUD elements (for example, the pause menu). You can mess with the comparison here and the normalization here. Might be worth somehow special-casing the HUD, or perhaps using a different method of storing depth.

Currently transparent fragment depth is stored normalized (0 to 1). The reasons for this are:

*z is the depth from the far plane to the near plane, effectively world-space; dividing by w normalizes it, making it screen-space

If I had full control over the entire pipeline, I could easily draw opaque first, transparent second, and then draw hud elements over the top after composition of the scene fragments. I could of course take control over the entire pipeline by force, but that will be very time consuming if not impractical (says the person who just shimmed D3D8 to D3D11 for OIT).

So it turns out to be a bit of a complex issue.

PiKeyAr commented 6 years ago

If you can test which texlist is being used, maybe it's possible to whitelist all HUD texlists and get rid of the less-equal check?

PiKeyAr commented 6 years ago

Sky Chase got worse with the latest update. image Looks fine without OIT though. It also looks fine with the SADX version of the level, so maybe it's some depth manipulation that I'm doing in the mod causing this.

PiKeyAr commented 5 years ago

Sky Chase works fine with the latest generic build (or maybe it's because I reworked it a while back, not sure), all other issues are still there. I fixed the Emerald Coast pool thing manually.