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

[Mesh] Copy UV coordinates from a reference mesh #6740

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

Conversation

cdbharath
Copy link
Contributor

@cdbharath cdbharath commented Apr 4, 2024

Adds functionality InterpolateTextureCoordinatesFrom to interpolate UVs from input mesh to processed mesh. UVs are interpolated based on the UVs corresponding to the closest vertices in the input mesh.

Type

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves Copy UV coordinates from a reference mesh. #6625
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

In many mesh processing workflows, UV coordinates are not preserved. UV coordinates are required for many downstream tasks. One way to propagate UV coordinates through mesh processing workflows is by copying them from the original mesh. The related issue can be found here

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

The function performs the following steps during interpolation

  1. Generate a KDTree based on the input mesh.
  2. Establish a vertex-to-UV mapping for the input mesh(there could be multiple UVs mapped to a single vertex).
  3. Iterate through the triangles of the processed mesh and identify the closest point in the input mesh for each of the three vertices.
  4. Retrieve the corresponding UV sets from the vertex-to-UV mapping, resulting in three sets of UVs for each triangle.
  5. Determine the UV coordinates that are closest to each other (a combination of one UV coordinate from each set) among the three sets of UVs corresponding to the vertices of a triangle.
  6. Assign the UVs to the processed mesh

To test the code, I performed the following

  1. Load a sphere mesh
  2. Apply FilterSmoothTaubin filter
  3. Use InterpolateTextureCoordinatesFrom to interpolate the UV coordinates to the filtered mesh
  4. Visualize the original and the filtered mesh
Input Mesh:

Alt TextAlt Text

After InterpolateTextureCoordinatesFrom

Alt TextAlt Text

Copy link

update-docs bot commented Apr 4, 2024

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

@benjaminum
Copy link
Contributor

benjaminum commented Apr 16, 2024

Hi @cdbharath , do you have images of examples with more complex geometry? Maybe something like the Stanford bunny or Armadillo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy UV coordinates from a reference mesh.
2 participants