facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.7k stars 1.3k forks source link

the normal map is different form blender normal map #1840

Closed yejr0229 closed 2 months ago

yejr0229 commented 2 months ago

I use the phong_normal_shading() to render a normal map:

def phong_normal_shading(meshes, fragments) -> torch.Tensor:
    faces = meshes.faces_packed()  # (F, 3)
    vertex_normals = meshes.verts_normals_packed()  # (V, 3)
    faces_normals = vertex_normals[faces]
    pixel_normals = interpolate_face_attributes(
        fragments.pix_to_face, fragments.bary_coords, faces_normals
    )
    return pixel_normals

and I get: image

But the colormap it's different from the controlnet normal map: image

how can I render a normal like controlnet in pyorch3d?

bottler commented 2 months ago

There's probably some simple mapping between the two versions of the color channels. I think you are best positioned to work this out manually for yourself, maybe by looking at some values.

yejr0229 commented 2 months ago

Thanks for replying, could you please tell me how to find this mapping more specially?

bottler commented 2 months ago

@yejr0229 (Please do not repost this question on other issues.) Your question is not specifically about PyTorch3D, and you shouldn't expect an answer here. It's an arithmetic question. We won't help. You could investigate the specific definition of the controlnet normal map, but more productive would just be to look at values.