Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Colin97
Copy link

@Colin97 Colin97 commented Jul 27, 2022

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 27, 2022
@Colin97
Copy link
Author

Colin97 commented Jul 27, 2022

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.

@bottler bottler self-assigned this Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants