pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Bug found in _get_culled_faces()

Open Bear-kai opened this issue 9 months ago • 0 comments

The code in renderer/mesh/clip.py link should be modified from

if op == "<":
    verts_clipped = face_verts[:, axis] < clip_value
else:
    verts_clipped = face_verts[:, axis] > clip_value

to

if op == "<":
    verts_clipped = face_verts[:, :,axis] < clip_value
else:
    verts_clipped = face_verts[:, :,axis] > clip_value

since the 3rd dimension stores the xyz locations in face_verts: (F,3,3) tensor.

Also note that the clipping_planes link are not consistent with the coordinate convention "x-left, y-up, z-inner" used in pytorch3d.

clipping_planes = (
        (frustum.left, 0, "<"),
        (frustum.right, 0, ">"),
        (frustum.top, 1, "<"),
        (frustum.bottom, 1, ">"),
        (frustum.znear, 2, "<"),
        (frustum.zfar, 2, ">"),
    )

The above snippet indicates the frustum is under "x-right, y-down, z-inner". It does not have any effect when we set, say "left=-1, right=1", but it somehow confused me at first. To be clear, I think it is better to set “left=1, right=-1” with

clipping_planes = (
        (frustum.left, 0, ">"),
        (frustum.right, 0, "<"),
        (frustum.top, 1, ">"),
        (frustum.bottom, 1, "<"),
        (frustum.znear, 2, "<"),
        (frustum.zfar, 2, ">"),
    )

Bear-kai avatar Jan 16 '25 04:01 Bear-kai