-
Notifications
You must be signed in to change notification settings - Fork 151
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
How to flatten a partitioned 3D mesh onto 2D UV map? #83
Comments
The workflow for the tool is generally to output the UV mapping as replacement UV values in the model output. You can use the There are a number of command-line options for the uvatlastool that provide different visualizations of the result. This includes |
@walbourn Thank you for your quick reply! Sorry I did not explain my problem clearly. The WaveFront OBJ file I used as input for UVAtlas is a per vertex color OBJ file, so it does not have corresponding .mtl or .png file. What I would like to have as a result is a new .mtl file and a new .png file. Moreover, I will also hope to be able to put different weights to different 3D vertices, so that I could place more details to certain regions of the 3D mesh, such as that shown in Fig 1 in Sander et al, 2002 (https://hhoppe.com/ssp.pdf). I followed your advice to generate OBJ output using -wf switch. I can see the 2D texture coordinate (vt in .obj file) is generated for each vertex. The 2D texture coordinates range from 0 to 1. I suppose they are the coordinates in a texture image (e.g., a .png file). However, I do not know how/where to get this texture image. I once thought maybe I could use the color at each 3D vertex (in the input OBJ file) and its corresponding 2D texture coordinate (in the output OBJ file) to construct a 2D texture image myself. However, I later noticed that the number of 3D vertices in the output OBJ file is different from the number of 3D vertices in the input OBJ file, so that I do not have the color info for each vertex in the output OBJ file. Please excuse me if my question sounds naive, as I am pretty new to UVAtlas. Thank you very much! |
I'm fairly sure the 2D image on the right of this is just a simple screenshot of a render of the output of |
Thank you so much for replying my question so fast! I am afraid that I am a bit lost because of my poor background knowledge. When you said "output of -t", did you mean using both "-t" and "-wf" switches when runnng uvatlas? The resulting OBJ file looks like a 3D model (it contains 3D coordinates for all vertices). I tried to visualize it using MeshLab, it first popped up an error message "Some materials definitions were not found, a default white material is used where no material was available", then displayed a white 3D model. FYI, the format of my input OBJ file is like this: vn 1.22 6.10 -0.78 Can you please kindly let me know how I could generate the 2D model as shown in the right figure? Thank you very much! |
The It's also possible that figure was generated with the "gutter helper" ResampleTex feature which I don't yet have implemented for this open source version of UVAtlas. |
@walbourn Thank you for your further explanation! My problem is that when I used "-t" and "-wf" switches, I got ONLY one ouput OBJ file. I did not see any _texture.obj file. Yet, when I used only "-t" switch (which should by default generate .sdkmesh output file), I had two output .sdkmesh files (.sdkmesh and _texture.sdkmesh). Using your "directxtkmodelviewer" (https://github.com/walbourn/directxtkmodelviewer), I could visualize the partitioned 3D mesh saved in .sdkmesh. But when I tried to visualize _texture.sdkmesh, all I got was a blank window. Did you mean that I should have another *_texture.obj file in my result when using "-t" and "-wf" switches? Then what did I go wrong? Thank you very much! |
Just now I did some further tests. I noticed that when I used "-t" and "-wf" switches, there was a warning message at the end of the process, which I overlooked previously. The warning message is as below: WARNING: WaveFront Object (.obj) not supported for UV visualization (requires Vertex Colors) I guess that is why I failed to get the *_texture.obj in the result. However, as we can see in the format of my input .obj file, which I showed above, that .obj file does contains vertex colors. (I assume the 6 values following flag "v" indicate 3D coordinate (x,y,z) and color (R,G,B)). FYI, the input .obj file I used in my experiment is the Standford bunny (http://graphics.stanford.edu/data/3Dscanrep/). Since the original file is in .ply format, I first had to use MeshLab to export it to .obj format. Maybe the vertex color should be set in a different way? Thank you very much! |
I realized when doing the normal visualization work that the block on writing Support for 'per-vertex-color' in WaveFrontOBJ isn't widely supported, but I have a note to look at supporting at least importing it in the future here. There's also a PR I need to work through for adding direct support for PLY to this tool. #70 |
Thank you for your further explanation! Using your latest commit, now I can generate the _texture.obj which contains the 2D model, although the color info is lost. Does this mean that right now, for per vertex color OBJ input, it is still not possible to get the 2D color UV map like shown in uvatlas2.jpg and uvatlas4.jpg? If so, in order to have 2D UV map like that, what type (format) of input OBJ file must I prepare? BTW, I am really impressed by your quick reply and commit even during weekend. Thank you very much! |
The specific images you see in those are both outputs of the Per vertex colors are only needed for the new normals visualization, but I have a work item to capture support for this in WaveFront OBJ: microsoft/DirectXMesh#75 If you can attach the Wavefront OBJ you are using that has per vertex color, I can use it for testing. Thanks! |
I see that I misinterpreted these two images. I previously thought they show an example of unwrapping a 3D colored mesh onto 2D UV map. Sorry about that. I have attached a per vertex color OBJ file (archived into a zip as I am not allowed to upload an obj file directly). This is how I prepared this file: I first downloaded pittsburghbridge.zip from pittsburghbridge.zip, then chose processed.ply from it. Next, I used Meshlab to convert the .ply to .obj (File -> Export Mesh As...). After that, I still used Meshlab to add normals to the exported .obj file (Filters -> Normals Curvatures and Orientation -> Compute normals for point sets). Finally, this point cloud was turned into mesh (Filters -> Remeshing Simplification and Reconstruction -> Surface Reconstruction: Screened Poisson). I tested using "-t -c -wf" switch on this OBJ file. I got the _texture.obj result. It shows the partitioned mesh on the uv plane, but the color is not there. I wonder if there is any way I could get the visualization similar to the "Color Map Results" in Fig 8 of Zhou et al 2004? Thank you very much! |
I must have broken something. It's not writing out the
|
Doh! I see the bug. I didn't actually WRITE the |
Try again :) |
Note that with VS 2015 or later, you can load WaveFront OBJ files directly into the IDE. |
I see now I can generate _texture.obj, _map.txt and _charts.mtl if I turn on "-t -c -m" switches. I guess with the vertex correspondences in _map.txt, I should be able to map the per vertex color from the 3D mesh to the 2D UV map. Thank you very much for your help! |
I am pretty new to UVAtlas and have limited experiences with 3D graphics. I tested using "UVAtlasCreate" to partition an input 3D mesh (.obj) and got the result in .sdkmesh file. I could use "directxtkmodelviewer" (https://github.com/walbourn/directxtkmodelviewer) to see the partitioned 3D mesh. However, what I would like to have ultimately is a 2D UV map, such as the figures in Zhou, et al, 2004 and Sander, et al, 2002. I suspect (not sure) that the 2D UV map is in the form of a .mtl file and a corresponding .png file, both of which can be used together with a texture-less .obj mesh to visualize the textured 3D mesh in a mesh viewer (e.g., MeshLab). I have read the UVAtlas Wiki and the source code, but I have not found out how to flatten the partitioned 3D mesh onto a 2D UV map. Can anyone please kindly show me how to do that? Many thanks in advance!
The text was updated successfully, but these errors were encountered: