- Home /
How do we generate a UV mapping data for a complicated mesh?
I have successfully generated the vertices and triangles of a mesh, which looks like a ring. Now, I am stuck on one last part. I am still learning about UV mapping but because the mesh is a bit more complicated, how can I generate the UV mapping data for it? This is what the mesh looks like, the numbers in green are vertices.
Image: http://tinypic.com/r/2j4ops9/8
The texture that I will be using for now is: http://i57.tinypic.com/d5rw8.png
And if it would help, I am expecting the ring to look something like this using the texture that I've provided: http://i61.tinypic.com/15hdc8o.png
It depends entirely on how you want the texture to be mapped.
Sorry, I am still learning about UV mapping. Can you explain a bit more? Like, what would cause me to want the texture to mapped in a certain way?
I think what Eric5h5 means is it depends on how your texture is laid out. If you have a texture let's say with multi-colored rings on it that should map to this ring (I'm assu$$anonymous$$g it's a 2D ring from the image you posted), then the texture coordinates will depend where the rings are located on the texture, and how they are laid out. If you laid the rings in the texture as several parallel vertical colors, the texture coordinates would be different from if you had laid the rings out in a circle in the texture. 2D Texture coordinates are just a means of saying "this vertex should be at this X,Y point on the texture" and the pixel shader will handle interpolating the areas between each vertex with a linear approximation of the location in the texture that is between vertices. If you post your texture, we can give some better help.
Thanks for the response supernat, it was very helpful. The ring that I've generate is actually 3D. I apologize for not mentioning this before but, the camera is top-down (therefore, its at the X,Z point). I... don't really have a texture for the ring yet. I thought that the first step was to create the UV mapping and then the texture. But, now that I think about it, that wouldn't make any sense. What if the texture is laid out like a horizontal rectangle? Once again, thanks.
I think I will use this texture for now: http://i57.tinypic.com/d5rw8.png
And if it would help, I am expecting the ring to look something like this using the texture that I've provided: http://i61.tinypic.com/15hdc8o.png
Well I think you have to create the texture knowing how the UV will be mapped and map the UV knowing how you plan to create the texture :).
If you just want solid colors, consider using vertex color ins$$anonymous$$d of textures. That texture will be difficult to do what you want. Well first, I'll say there's a transition between red and blue, and blue and green, but if you expect a transition between red and green that looks similar, you need to redo the texture and have the left side fade from green to red and right side fade from green to red. If you do that and you have pure green on the left edge, transitions to pure red, transitions to pure blue, transitions to pure green, and finally transitions back to pure red on the right edge, the following would work.
You would just concentrate the majority of your vertices to a single texture coordinate in the middle of a particular color (lets say red you would set the coordinate so that vertices 14, 15, 0, 1, and 2 all lie at the pure section of the red part of the texture. Then 13 would lie toward the red/green transition on the left side, and 3 would lie toward the end of the red section almost into the blue.)
The issue you'll have is mapping between the red and green areas because the pixel shader will interpolate from the left side of the texture to the right side of the texture causing a rainbox right between vertex 13 and 14. If you set the clamp mode to Repeat and add a duplicate vertex at 14 whose coordinate falls into the new area I mentioned adding to the right side of the texture above, and set the original vertex inside the area to the left side of the texture that you added, making sure that both lie at the same spot relatively speaking (same green/red transition point but one on left side of texture the other on right side).
Alternatively, you can create a texture that looks more like the mesh (where the bars go around in a circle but are angled like the mesh so not really round). Then you don't have to add new verts, because all vertices will transition on the same texture properly. Hope this all makes sense...
Your answer
Follow this Question
Related Questions
Split a mesh while using same UVs and texture position. 0 Answers
UV Mapping for 2D Meshes with 3 Vertices Only 1 Answer
stretched UV map in generated mesh 0 Answers
Apply texture to a mesh on all 3 sides 2 Answers
UV Tiling/repeat 1 Answer