0
$\begingroup$

I am trying to understand how a texture image is mapped on an OBJ file. For example, if you map below color grid image (texture) on the capsule obj model (screenshot #1), it looks like the screenshot #2.

QUESTION: How do we know where the first pixel on the top left corner of the texture file will stay on the OBJ model surface? Does the OBJ file carry such a data? Or are there certain rules/protocols about texture mapping? Or does Blender have internal logic? I'd like to know the fundamental principle of texture mapping. Any help would be appreciated.

enter image description here Grid Image (texture)

enter image description here Screenshot #1

enter image description here Screenshot #2

Model source: http://paulbourke.net/dataformats/obj/minobj.html

$\endgroup$
2
$\begingroup$

The reason is because the capsule object already has a UV Map, as shown in the image below. The OBJ file format keeps the UV coordinates, which are assigned during unwrapping of your model in the UV space.

capsuleuvs

The answer to "How do we know where the first pixel on the top left corner of the texture file will stay on the OBJ model surface?" is unwrapping. Basically, when you unwrap your model, you unfold it so you can have a 2D projection of it. A simple object like the capsule is fairly simple to unwrap to a single part. But if you have a more complex object (such as Suzanne), you have to separate your mesh in several parts by creating Seams, and unfold one part at a time, to get a result like this:

suzanneuvs

This procedure is fundamental to apply textures on your model: any other texture will be applied based on the UV map coordinates that you have created. My suggestion is to use a checker color grid while you unwrap your model, so you can have a nice preview of how the textures will be applied on your model:

checkercreation

checker

Keep in mind this concept: any other texture will be applied in the same exact way the color grid is applied. You have to take control of the distortions: it's normal to have some distortion while unwrapping your model (because you convert your model from 3D to 2D). Adding seams reduce a lot the distortions on your unwrap. Anyway, common mistakes at the beginning are:

  • stretched and/or squashed uvs (first image below)
  • not uniform scale of the projections (second image below)

squash scale

The model is correctly unwrapped when you see perfect squared numbers of the color grid texture over all the parts of your model.

Useful resources:

$\endgroup$
  • $\begingroup$ Thanks so much, @G. Garone. Beautifully explained!! I have another question—do other file formats such as gltf, fbx, and dae contain UV mapping data in the models? $\endgroup$ – cypark Apr 14 at 14:31
  • 1
    $\begingroup$ You're welcome! Yes, FBX, GLTF, OBJ and DAE keep UV mapping data. PLY file format too, but sometimes getting this information is a bit more tricky. However this format is mostly used in 3D scanning context. $\endgroup$ – G. Garone Apr 14 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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