point_to_mesh_distance returns strange "jumps" in distance
Hello! I have troubles to get the point_to_mesh_distance function to work. Here is a MWE:
import matplotlib.pyplot as plt
import torch
from kaolin.io import obj
from kaolin.ops.mesh import index_vertices_by_faces
from kaolin.metrics.trianglemesh import point_to_mesh_distance
mesh = obj.import_mesh("/path/to/model.obj", with_normals=True, triangulate=True)
resolution = 64
# hardcoded to match the model bounds
x = torch.linspace(-10, 10, resolution)
y = torch.linspace(-10, 10, resolution)
z = torch.linspace(-10, 10, resolution)
grid_points = torch.stack(torch.meshgrid(x, y, z, indexing="ij"), dim=-1).view(-1, 3)
vertices = mesh.vertices.cuda()
faces = mesh.faces.cuda()
grid_points = grid_points.cuda()
face_vertices = index_vertices_by_faces(vertices[None], faces)
distance, _index, _dist_type = point_to_mesh_distance(grid_points[None], face_vertices)
plt.imshow(distance.reshape(resolution, resolution, resolution).cpu()[:, :, 31])
plt.savefig("df-kaolin.png")
However, the resulting distance field looks way off (I'm especially irritated by the edge in the top part of the image):
Calculating the distance field using trimesh returns the following, which makes much more sense:
What am I doing wrong?
Would you be able to share the mesh file that is causing this issue?
Here is a link to the used mesh: https://uniaugsburg-my.sharepoint.com/:u:/g/personal/julian_lorenz_uni-a_de/ESAXVkFPQ-xNlEipcrXJjcoBLfyl_CXqIgHLdwnsWAreiQ?e=7H5Ixm
The used mesh was converted to the OBJ file format. The original mesh from Kristen Brown can be found here
(edit: updated the link)
Hi @lorjul I can't have access to the first link, just to make sure I'm using the same model can you share it with us? Please contact me at [email protected]
My bad, sorry, the link was set to expire. Here is an updated link which should work: https://uniaugsburg-my.sharepoint.com/:u:/g/personal/julian_lorenz_uni-a_de/ESAXVkFPQ-xNlEipcrXJjcoBLfyl_CXqIgHLdwnsWAreiQ?e=7H5Ixm
Is there any progress on this problem? We also encounter the strange "jump" in some cases.
Stale issue message
Hi, is there any update on this? I also encounter the same issue.
Stale issue, please reopen if still relevant
Hi all, I've been trying on the model suggested I downloaded the USD model, and couldn't observe the jump, if you have any model with the jump please share I will have a look.