Giter Site home page Giter Site logo

Comments (17)

walbourn avatar walbourn commented on June 14, 2024

The workflow for the tool is generally to output the UV mapping as replacement UV values in the model output. You can use the -wf switch to get a simple WaveFront OBJ output and the texture coordinates in that output are the ones generated by UVAtlas.

There are a number of command-line options for the uvatlastool that provide different visualizations of the result. This includes -c which modifies the output materials to help you see the way the tool partitioned the original model, and -t which outputs a 2D model where the generated UVs are set as positions.

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

@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!

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

I'm fairly sure the 2D image on the right of this is just a simple screenshot of a render of the output of -t where the vertex colors are the normals.

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

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
v -0.03 0.12 0.00 0.49 0.49 0.49
vn ...
v ...
...
...
f 212//212 216//216 400//400
f ...
...

Can you please kindly let me know how I could generate the 2D model as shown in the right figure? Thank you very much!

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

The -t output is called *_texture.* which shows the UV parameters as vertex positions. I just added a -vn option to visualize normals, but it doesn't look exactly like the figure.

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.

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

acf451e

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

@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!

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

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)
):-> 'bun_zipper_texture.obj'80004001: Not implemented

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!

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

I realized when doing the normal visualization work that the block on writing _texture with WaveFront OBJ was wrong. Per-vertex colors are only needed for the new normals visualization or when using -uv2, but not for basic -t or -c -t usage. That's fixed in the same commit. I also made it a fatal error if the requested file wasn't generated.

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

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

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!

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

The specific images you see in those are both outputs of the -c option which sets the material colors to indicate the partition. The first image appears to have a texture on it as well, which I can't do in the tool but you can do with editing the resulting mtl.

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!

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

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).
processed_meshlab_normal_mesh.zip

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!

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

I must have broken something. It's not writing out the mtl file for the -c case which has materials like:

Unable to find material Chart01 (missing .MTL file?)
Unable to find material Chart02 (missing .MTL file?)
Unable to find material Chart03 (missing .MTL file?)
Unable to find material Chart04 (missing .MTL file?)
Unable to find material Chart05 (missing .MTL file?)
Unable to find material Chart06 (missing .MTL file?)
Unable to find material Chart07 (missing .MTL file?)
Unable to find material Chart08 (missing .MTL file?)

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

Doh! I see the bug. I didn't actually WRITE the mtl file for WaveFront export when I do the -c option :(

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

Try again :)

48ddb5c

from uvatlas.

walbourn avatar walbourn commented on June 14, 2024

Note that with VS 2015 or later, you can load WaveFront OBJ files directly into the IDE.

from uvatlas.

gyxiaochina avatar gyxiaochina commented on June 14, 2024

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!

from uvatlas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.