Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noisy Z-fighting in WebGL #26

Closed
komadori opened this issue Oct 31, 2023 · 3 comments
Closed

Noisy Z-fighting in WebGL #26

komadori opened this issue Oct 31, 2023 · 3 comments
Assignees

Comments

@komadori
Copy link
Owner

komadori commented Oct 31, 2023

AFAICR, WebGL support was tested and working fine at the time 0.5.0 was released, but that same release exhibits noisy Z-fighting between the volume and stencil meshes now. I don't have a Cargo.lock file, so it could be related to minor version upgrades of dependencies. It could also be related to the version of my browser or 3D drivers having changed.

image

See also the previous issue #19 concerning Z-fighting with WebGL.

@komadori
Copy link
Owner Author

komadori commented Nov 2, 2023

The above screenshot was produced with an Nvidia card on Linux, but the problem did not occur when testing with Intel HD Graphics. The source of the noise appears to be interpolating between the depth values at different vertices. Although they should be the same in flat mode, this will add numerical error which can apparently exceed the depth offset.

With 613e1dd, I have changed the way flat mode is implemented again to always set the depth in the fragment shader. This should be ensure that depth values are bit-for-bit identical across the plane, so a depth offset isn't even needed for the stencil. I was originally worried about the performance of this, but I think I was overthinking it. The fragment shader is trivial so the benefits of early Z testing should be minimal. In any case, the other approach does not seem to be reliably portable so it's the best option.

I will release 0.5.1 soon.

@komadori komadori self-assigned this Nov 2, 2023
@komadori
Copy link
Owner Author

komadori commented Nov 3, 2023

Released 0.5.1.

@komadori komadori closed this as completed Nov 3, 2023
@komadori
Copy link
Owner Author

komadori commented Nov 6, 2023

Also back-ported to 0.4.3.

ian-h-chamberlain added a commit to ian-h-chamberlain/pist-off that referenced this issue Dec 28, 2023
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

No branches or pull requests

1 participant