bonsairobo / building-blocks

A voxel library for real-time applications.
MIT License
368 stars 30 forks source link

`surface_nets` lighting artifacts from normal interpolation #31

Open bonsairobo opened 3 years ago

bonsairobo commented 3 years ago

mesh_acne

It seems like there are two issues contributing to the artifacts:

  1. Non-manifold complexes
  2. Interpolation between "unlit" normals and "lit" normals

When you see random isolated black spots that seem like they should be lit, it's because the vertex is actually non-manifold, and its normal was estimated to point more in the "unlit" direction than the "lit" direction.

Then the interpolation will make that darkness bleed out where it might not makes sense. In particular, on sharp edges. If the normal is estimated as "unlit" that will bleed around the edge.

I think the sharp edge issue is actually a bigger problem. Non-manifold complexes are always undesirable. But sharp edges are certainly something we would like to look correct.

bonsairobo commented 3 years ago

BTW, this should not be an issue if flat shading is used.