-
Notifications
You must be signed in to change notification settings - Fork 120
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
Wrong vertex normals and uvs after boolean subtraction #579
Comments
I've just noticed you merged the new triangulator. The described example works with the new triangulator. But it was quite easy to find another example of wrong normals and uvs, so I think the triangulator won't be the problem here. I'll try to prepare another example which shows the problem for the current master. |
Here is a new mesh dump which shows the same problem for the current master. wrong_normals_and_uvs_mesh_dump_2.txt The problematic triangles here are 17 and 28 which use vertex 8 with inappropriate normal and uv. |
are there degenerate triangles in the result? or duplicated vertices at the same position? |
How do I check this? I'm using WASM bindings. I have duplicated vertices because I need different normals and uvs for different surfaces, but I set |
I think we don't have that API in our js binding because it is only intended for debugging. For this bug, I feel like it may be related to degenerate triangles or vertices with same position because the normal computation for them are probably not very stable. Can you try if it works if you modify https://github.com/elalish/manifold/blob/master/src/manifold/src/impl.cpp#L70 a bit to ignore edges with length less than precision? |
Thank you for the detailed report - this definitely sounds like a bug. The next step will be turning it into a reproducible |
I've checked the triangle areas by using cross product of the AB and AC vectors. The smallest triangle I could find in |
I have two manifolds
a
andb
. Both have 8 vertex properties - 3 for coordinates, 3 for normals, 2 for uvs).Manifold
a
is a result of previous boolean operations and you can see it in the following picture. One of its surfaces has a UV debug texture assigned. The short blue segments pointing out from the textured surface shows vertex normals for all the vertices that are involved in any triangle belonging to this surface.Manifold
b
is a simple cuboid larger then manifolda
and translated down a little bit. Here is a picture of both manifolda
andb
in one scene.When
b
is subtracted froma
(manifolda_minus_b
), something bad happens with the normals and uvs on the textured surface. See the picture below.The problematic surface is composed of three triangles. The problem is that two of the triangles uses a vertex which has normal and uv that would be good for the left adjacent surface, but not for this.
The problem occurs in specific situations only. For example, if I move the manifold
b
down by a different offset, the problem disappears. It seems to me that offsets which don't have accurate numeric representation (like multiples of 1/3) triggers this more often.In case you would have time to look into this, I attach a MeshGL dump of all the manifolds -
a
,b
anda_minus_b
. The problematic triangles are 40 and 46. They use vertex 50 which has inappropriate normal and uv. I would expect that these triangles will use vertex 68 instead as it is used in the only correct triangle 38 for this surface.wrong_normals_and_uvs_mesh_dump.txt
The text was updated successfully, but these errors were encountered: