BachiLi / redner

Differentiable rendering without approximation.

Home Page:https://people.csail.mit.edu/tzumao/diffrt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UV mapping

mmgutsche opened this issue · comments

Little question regarding UV handling for shapes:

From the docs

  • vertices (torch.Tensor) – 3D position of vertices float32 tensor with size num_vertices x 3
  • indices (torch.Tensor) – vertex indices of triangle faces. int32 tensor with size num_triangles x 3
  • uvs (Optional*[torch.Tensor]**:*) – optional texture coordinates. float32 tensor with size num_uvs x 2 doesn’t need to be the same size with vertices if uv_indices is None
  • normals (Optional*[torch.Tensor]*) – shading normal float32 tensor with size num_normals x 3 doesn’t need to be the same size with vertices if normal_indices is None
  • uv_indices (Optional*[torch.Tensor]*) – overrides indices when accessing uv coordinates int32 tensor with size num_uvs x 2
  • normal_indices (Optional*[torch.Tensor]*) – overrides indices when accessing shading normals int32 tensor with size num_normals x 2

What does "uvs (Optional*[torch.Tensor]**:*) – optional texture coordinates. float32 tensor with size num_uvs x 2 doesn’t need to be the same size with vertices if uv_indices is None" exactly mean?. I try to understand how to properly map textures to meshes. Is there a way for simple planar projection of a texture onto a mesh? I tried it with a tilted plane, but so far I either get very weird results (when using more than 3 vertices), or I do not understand how to change the projection in the case of a single triangle. Can I use more UV coordinates than I have vertices? If yes, how do they relate to the existing vertices?

That was a typo: it should be "doesn’t need to be the same size with vertices if uv_indices is not None".
It is similar to how the Wavefront obj file format setup the uv coordinates https://en.wikipedia.org/wiki/Wavefront_.obj_file#Vertex_indices

Let me know if this answers you questions.