pytorch3d
pytorch3d copied to clipboard
normalize UV coordinates to [0,1] in make_material_atlas()
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"
Failure case 2: texture_wrap = "clamp"
Failure case 3: texture_wrap = None
However, with this commit, using "texture_wrap = None" can consistently produce correct textures for both cases:
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.