marian42 / mesh_to_sdf

Calculate signed distance fields for arbitrary meshes
https://pypi.org/project/mesh-to-sdf/
MIT License
991 stars 107 forks source link

Why sign method 'depth' only generates positive SDF? #5

Closed Colin97 closed 4 years ago

Colin97 commented 4 years ago

Thanks for your great work.

I tried to sample SDF near the surface, but it only outputs positive SDF whatever meshes (watertight or non-watertight) serve as input.

points, sdf = sample_sdf_near_surface(mesh, number_of_points=250000, sign_method = 'depth')

marian42 commented 4 years ago

It should generate negative values as well, can you share an example mesh where it doesn't work?

Colin97 commented 4 years ago

mesh.zip

Colin97 commented 4 years ago

Is there any update?

marian42 commented 4 years ago

Sorry, I'm a bit short on time right now. I just checked your mesh. The backrest of the chair has zero volume, so it makes sense that no points are sampled inside it. For the legs of the chair, as well as the cube though, points inside of it should create negative SDF values. For comparison, I created a cube in Blender and it created negative SDFs inside it. There seems to be something weird with the topology of your mesh. I'll investigate and hopefully provide a fix.

marian42 commented 4 years ago

Ok, the issue is now fixed by disabling backface culling. I'll release an updated pip module tomorrow.

marian42 commented 4 years ago

I just uploaded a new version to pypi, you should be able to update with pip.

Colin97 commented 4 years ago

Thank you very much.