pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

normalize UV coordinates to [0,1] in make_material_atlas()

Open Colin97 opened this issue 2 years ago • 1 comments

When building a material atlas, it's common to have negative UV coordinates (e.g., in ShapeNet dataset). Existing options (texture_wrap="repeat", texture_wrap="clamp", texture_map=None) may fail to produce correct textures. Failure case 1: texture_wrap = "repeat" image Failure case 2: texture_wrap = "clamp" image Failure case 3: texture_wrap = None image

However, with this commit, using "texture_wrap = None" can consistently produce correct textures for both cases: image image

Colin97 avatar Jul 27 '22 03:07 Colin97

This PR is about TexturesAtlas, not TexturesUV.

When making a texture atlas, the existing solution for handling negative UV coordinates is wrapping faces_verts_uvs at the very beginning, which may lead to incorrect interpolation.

Instead, we should keep the original faces_verts_uvs and use it to calculate UV positions for all RxR atlas pixels and then wrap the UV positions, which leads to correct sampling and atlas creation.

In the meantime, we should also change the default texture_wrap option to avoid using the existing "repeat" strategy.

Colin97 avatar Jul 27 '22 16:07 Colin97