pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

How can I use OpenGL-related methods in PyTorch3D to render semi-transparent textures?

Open changfali opened this issue 6 months ago • 2 comments

How can I use OpenGL-related methods in PyTorch3D to render semi-transparent textures? I want to achieve the effect shown in the image below, or does PyTorch3D support using the blend function like gl.glEnable(gl.GL_BLEND) in MeshRasterizerOpenGL? img_v3_02e1_f4e05203-f392-4e41-b892-bbea1021e7dg

In my scene, after rasterization, a single pixel might correspond to multiple faces. If I use MeshRasterizerOpenGL, its rasterization method is:

pix_to_face, bary_coords, zbuf = self.opengl_machinery(
    meshes_gl_ndc, projection_matrix, image_size
)

The pix_to_face result always contains only one face (with a shape of [N, H, W, 1]). However, when I use MeshRasterizer, the rasterization method is rasterize_meshes, which allows modifying the result by setting faces_per_pixel. The reason I’m not choosing MeshRasterizer is that MeshRasterizerOpenGL is faster, and I don’t care about differentiability. Is it possible to achieve my requirement using MeshRasterizerOpenGL? Or how should I modify it to get the result I want? @amyreese @JaapSuter @thatch @yurimalheiros could anyone help me with it?

changfali avatar Aug 23 '24 06:08 changfali