-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Some kind of offset in TexturesUV Map, leads to faulty texture on mesh #1847
Comments
In the last image, have you plotted every triangle in the mesh on the uv map in grey, or only some of them? You should not have gradients in unused portions of the map. I wonder if you are using the right conventions for u and v? Can you plot the TexturesUV with one of the functions in https://github.com/facebookresearch/pytorch3d/blob/main/pytorch3d/vis/texture_vis.py ? |
I've plotted every triangle of my mesh (I just zoomed in so it is easier to see) and yes it is very odd that there are gradients in unused portions of the map. I am not an expert with meshes but I think I should be using the right conventions for u and v. I created the UV Map with blender Smart UV Project and export my mesh immediately afterwards. So as long as there isn't something wrong with blender UV, my mesh should be fine too. I attached my potted TexturesUV (bigger than 10MB so there is a link to it https://uni-bonn.sciebo.de/s/6ca9gDnqUKgZy4K) |
I think there's no guarantee that blender's conventions for u and v are the same as PyTorch3D's. This should be checked. The two images look the same way round, and you can see the red dots are at least roughly lined up with the colored area. I don't know what's happening here. |
So in this comment I will describe how to reproduce my issue with your tutorial. I recreated the uv-map of the cow mesh, which was used in your tutorial. I intentionally choosed some unfortunately parameter for blender uv smart project. As result I confessedly got not the very best possible uv-map. However I would expect that the gradient descent based method should still be able to deal with this uv map. I attached this resulting mesh here
just unzip the cow mesh into the data dear folder from your tutorial and run this code. Afterwards you can replace tex_map.png of the cow mesh with the tex_map.png saved by this code. Then you can use blender, MeshLab e.g. to show the mesh.
Now we have a look at the resulting texture-uv-map. When I zoomed into the left part of the texture-map, it seems to have a little offset to the right. When we look at the right part, it seems to have a little offset to the left At the top of the texture map there is an offset down And when we concentrate on the bottom there is an offset up I am not quite sure but maybe there is some minimal wrong scale within the pytorch3d rendering? Or maybe calculations are not precise enough e.g. some integer division but it should be float or maybe float16 but it should be float32? I hope you are able to reproduce my issue and if you need some further information please let me know. |
Without looking in detail at your code, I have an idea: Can you check what do you are doing in terms of align_corners conventions? They could be an inconsistency. Firstly, can you just try changing the value when you create the TexturesUV? |
I used the default value for align_corners. So this value should be true. I'll change it to false now and have a look what happens |
Here is the solution!
and
This fixes my problem. @bottler thank you for your help :) |
Hello everyone,
I have some unexpected behavior with my code. I trained a NERF PermutoSDF on a Dataset. Afterwards there is a script within PermutoSDF to extract a mesh out of the NERF. However this mesh does not have any textures... So I would like to train those textures with pytorch3d. To do so I create a UV Map in blender for the mesh I got out of PermotoSDF. I use the Smart UV Project function of blender.
Then I train the resulting mesh with the following code:
Now I get some unexpected behavior as result...
It looks like that there is some kind of offset within the TextureUV Map
I expect all triangles to be offset a little bit to the left (e.g. see red circle in image). But there are also some triangles which looks correct, so the offset does not apply to all triangles. This leads to unwanted results with the texture of my mesh:
As one can see there are a lot of grey (grey was the initial color of my texture map) textures in my mesh which supposed to be green.
I don't think it is an issue with my mesh structure, because when I try to paint some grey spots to green manually, there is no problem. Furthermore texture mapping within pytorch3d seems to be right too, because the (incorrectly) resulting texture map is mapped correctly on my mesh.
The thing which is wrong is the resulting texture map and I checked for the gradients at the Texture UV Map and these gradient seems to be offset too. So it looks like that there is something wrong with gradient calculations. I visualized the gradients with this code
I tried to optimize the TextureVertex instead of TextureUV as shown in your tutorial too. This worked fine and there wasn't any grey spots after training. But TextureVertex does not offer enough resolution, so I would prefer to optimize a higher resolution TexturesUV Map instead.
If any more information or explanation is necessary, please let me know.
Thank you for your help!
The text was updated successfully, but these errors were encountered: