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() #1269

Closed
wants to merge 1 commit into 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., 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 produce correct textures for both cases:
image
image

@facebook-github-bot
Copy link
Contributor

Hi @Colin97!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@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
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@Colin97 Colin97 closed this Jul 27, 2022
@bottler
Copy link
Contributor

bottler commented Jul 27, 2022

As you indicate, UV-coordinate wrapping is a feature which PyTorch3D should support, and this PR indicates part of the code which needs to be changed. Unfortunately I think a proper solution is quite complicated. IIUC, UV coordinates should be understood as in an infinite plane which wraps around (topologically a torus). So in general, a single face can encompass parts from many copies of the original map. TexturesUV.join_scene would become much more complicated.

Another enhancement to the class which seems to be wanted is having multiple texture maps instead of one (per batch element). Implementing that would make this easier.

@Colin97
Copy link
Author

Colin97 commented Jul 27, 2022

@bottler Yes, TexturesUV.join_scene can be very complicated.

However, the proposed PR is about TexturesAtlas not TexturesUV. Specifically, when creating a texture atlas from a single image texture, the above change ensure a correct sampling and thus creating a correct atlas. In this case, we already calculated all RxR UV coordinates for each atlas pixel (which may be negative) and need to sample from the image. The proposed wrapping is thus proper and necessary .

@bottler
Copy link
Contributor

bottler commented Jul 27, 2022

Yes, sorry, I was confused about which part this was changing. Let's continue the discussion for the atlas on #1270.

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