Avara icon indicating copy to clipboard operation
Avara copied to clipboard

Z-fighting/moire patterns when rendering thin blocks used for coloring

Open assertivist opened this issue 5 years ago • 3 comments

The easiest way to see this happening is to load Treble from AA Tre and look at the columnar blocks in the center. The decorations on top show z-fighting artifacts on Windows.

This may be distance related since they look fine when you're playing/up close, but I've also seen it on the corner blocks in Symbiosis at pretty close range.

It may also be platform related, but you can definitely see this in both Windows and Linux.

assertivist avatar Mar 03 '19 02:03 assertivist

After hearing from users on other platforms (thanks @scarletswordfish) I can pretty much safely say it isn't a platform issue. We probably need to adjust the way our object shader treats thin objects.

assertivist avatar Mar 03 '19 02:03 assertivist

There's an attempt to deal with this issue in the shader labelled "decal". this uniform becomes .9999 when the object in question has a bounding box with a dimension smaller than some value (.001 I think it is right now). Then the z-buffer value is multiplied by that to bring those objects a little closer to the 'camera'.

This successfully gets rid of z-fighting in some situations but not all, and it also applies to thickness=0 ramps and other objects that we don't want to adjust the z-buffer of. So this is still in progress.

assertivist avatar Jan 26 '20 01:01 assertivist

#74 didn't fix this, but it did make it better...

Instead of messing with the z-buffer directly, I discovered glPolygonOffset and used that to fix a lot of the instances of z-fighting, mostly of flat panels on the surface of larger blocks.

But we still have some, especially in places where the geometry that is coplanar with the decal geometry is also considered a decal (which means they both get shifted and the effect doesn't work).

It may be possible to utilize Juri's original algorithms for whether or not an object is obscured to assist with these adjustments in the depth buffer...

assertivist avatar Jun 11 '20 04:06 assertivist