pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Is it possible to generate a transparent (non-opacity, zero-density) mesh in pytorch3d?

Open SangHunHan92 opened this issue 3 years ago • 4 comments
trafficstars

I want to render the part of the mesh occluded in another mesh part, and I want to get the front/back normal map of this part. To do this, I first extracted the index of the vertices of the obscured or occluded part.

One way to render is to remove the faces of the mesh. However, in this method, a hole is created in the mesh from which the face has been removed, and the ray passing through that part has the disadvantage that it is impossible to distinguish the front/back of the mesh.

I've come to the conclusion that if I assign an alpha-like transparency parameter to the mesh vertices/faces, I can render the normal map of the part I want.

A similar question was asked at (https://github.com/facebookresearch/pytorch3d/issues/752), but this question was not answered, so I ask again.

SangHunHan92 avatar Aug 20 '22 10:08 SangHunHan92

You could write a custom shader which selectively ignores faces? Or uses the alpha channel in any way you want?

bottler avatar Aug 21 '22 11:08 bottler

@bottler I don't know if I understand your intentions properly,

If I can optionally give a list of faces that I want to ignore (transparent) when declaring the shader, that seems like a good way to go. In this case, the normal map is not calculated on the ignored faces. For example, if the A mesh part is in front of the B mesh part and is obscured, and I want the shader to ignore the face of the A mesh, I will only get the normal map of the B mesh.

Is there any good way? I would be very grateful if you could explain how to use it in code.

SangHunHan92 avatar Aug 22 '22 05:08 SangHunHan92

I don't really understand your intentions. In particular, why you can't just create a new mesh consisting of just your B part. How are you creating the "normal map" anyhow - is that based on a special shader looking at the Fragments plus the original mesh?

But my idea was to create a new shader class based on whichever shader you were using, which only looks at those faces in your B part.

bottler avatar Aug 22 '22 13:08 bottler

I'm sorry I made the explanation difficult.

Originally what I wanted to do was to give the vertices/faces an alpha value. I am concerned that If I make a new mesh for part B, a noisy surface will be detected on the cut surface(Between A and B mesh). Therefore, after giving alpha to the vertices/faces, I wanted to obtain the normal of the surface with the highest alpha by taking the softmax of the alpha values that the ray passes through.

I think there's probably no fundamental difference between creating a new mesh for the B part and letting the shader only see the B part. But I'm not familiar with pytorch3d code, so I'd appreciate it if you could give me an example of how to use shader in this case.

A normal map is created like this : https://github.com/facebookresearch/pytorch3d/issues/865, https://github.com/facebookresearch/pytorch3d/issues/1063

SangHunHan92 avatar Aug 23 '22 04:08 SangHunHan92