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

About using xatlas to extract uvmap #7

Open
jugwangjin opened this issue Mar 5, 2024 · 2 comments
Open

About using xatlas to extract uvmap #7

jugwangjin opened this issue Mar 5, 2024 · 2 comments

Comments

@jugwangjin
Copy link

jugwangjin commented Mar 5, 2024

Hi.
Thank you for great work.

While I was working on this work, I found out that the resulting uv map is corrupted.

I fount that although xatlas duplicates some vertices, current work does not apply this on the mesh class.

the resulting uv map is

스크린샷 2024-03-05 164209

however,

if I add two lines in the xatlas_uvmap a bit, like

@torch.no_grad()
def xatlas_uvmap(self):
    import numpy as np
    # Create uvs with xatlas
    v_pos = self.vertices.detach().cpu().numpy()
    t_pos_idx = self.indices.detach().cpu().numpy()
    vmapping, indices, uvs = xatlas.parametrize(v_pos, t_pos_idx)

    # Convert to tensors
    indices_int64 = indices.astype(np.uint64, casting='same_kind').view(np.int64)
    vmapping_int64 = vmapping.astype(np.uint64, casting='same_kind').view(np.int64)
    vmapping = torch.tensor(vmapping_int64, dtype=torch.int64, device=self.device)

    uvs = torch.tensor(uvs, dtype=torch.float32, device=self.device)
    faces = torch.tensor(indices_int64, dtype=torch.int64, device=self.device)

    self._uv_coords = uvs
    self._uv_idx = faces
    self.vmapping = vmapping

    # ADDED LINES
    self.vertices = self.vertices[vmapping]
    self.indices = faces

the resulting UV map goes

스크린샷 2024-03-05 164405

It may not affect the result, hope it helps.
especially about the tangent computation, which includes uv coordinates.

@sbharadwajj
Copy link
Owner

sbharadwajj commented Mar 10, 2024

Hi,

Thank you so much for your input! Let me recheck.

As far as I remember, I have verified the UV coordinates in the original code, but a bug might have been introduced when I was cleaning the code for release. Do you see a difference in performance? We don't backpropagate the gradients through this, but the uv maps are used for tangent computation as you mentioned.

As far as I understand, the step that you mentioned reorders the vertices, right?
I am assuming your UV map is not a face?

@jugwangjin
Copy link
Author

jugwangjin commented Mar 12, 2024

Thank you for replying.

As you said, the reordering vetices, can fix this.

However, when I'm testing on the code, there was no big differences.
Maybe it can show some robustness on your method.

ps) the extracted UV map is from the result of xatlas on the face model in the directory 'assets'

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

No branches or pull requests

2 participants