1

So, I think I'm starting to get a hang of this 3d stuff, I have now reached a point where I need to do some texture mapping. My question though is how do I create/obtain my texture coordinates. I have an understanding of [u,v] coordinates, but now the question is, "How do I make them"? Looking at my .obj files, I see that they have vt coordinates, I'm not entirely sure how those were produced, but how can I manipulate them to my liking?

I need to do the mapping programatically as the texture will be changing throughout my program. I am currently working with MayaVI , but I feel that working with this stuff is somewhat universal. Thanks for the help!

2
  • Are you sure you need to change the mapping? Changing the texture does not imply changing the UV coords. Indeed, while some shapes are easy to automatically map, some shapes are hard.
    – JasonD
    Jan 21, 2013 at 14:34
  • Yea, I have to change the mapping, the original coords that came with the obj were just completely useless. Jan 21, 2013 at 16:40

1 Answer 1

3

Texture coordinates are usually not generated but assigned manually. This happens in the 3D modelling application of your choice using a GUI (not by writing them into the 3D file). When the mesh is exported the UV coordinates are exported with the rest of the mesh data.

Automatic texture mapping of geometry is complex. It's not as simple as just flattening out all triangles. After all you want to paint a texture on the unwrapped faces, so having larger chunks of connected faces (not thousands of individual triangles) is essential. You also want to avoid seams / hide the seams. There are various tools which might do a decent job in some respects, but I personally prefer unwrapping by hand with quality 3D modelling software. More control, better results (at the cost of some design time).

For simple meshes (quads, cubes, 2D grid terrains) you can do it manually in the OBJ file or algorithmic.

What can be done automatically?

  • Normals can be generated from triangle data and positions with simple algorithms for almost any kind of mesh. (With varying results)
  • Tangents can be calculated from triangle data, normals and texture coordinates. (With great results)
  • Bitangents (just like tangents)

Also basic transformation (moving, rotating and scaling) of texture coordinates can easily be done in the vertex shader.

3
  • Is there a program that you might recommend? Currently I've played around a bit with the freeware "UVMapper Classic". It's quite simple in function, as it allows you to essentially splay out your mesh in whichever way you want, then save that mesh. From there you can take that mesh and overlay it on another image and adjust the image so as to fit the mesh accordingly. Is there a program that will let me take the mesh and assign vertices/faces to certain parts of an image? Jan 21, 2013 at 16:43
  • Most 3D modelling software packages include some kind of UV mapping functionality. Just to name a few: Blender is a free modelling software that's used by many indie developers. 3ds Max and Maya are often used in professional environments, but can be quite expensive. But there are hundreds of tools out there of varying quality and price.
    – Lucius
    Jan 21, 2013 at 16:55
  • Would you be able to suggest a way in which I can adjust the texture coordinates to fit my image as opposed to fitting my image to the texture coordinates? My program will consistently be making 2d textures, and I can't see a way for me to reshape the texture to fit with my model. Jan 21, 2013 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.