I'm turning to you as a newbie in CG, with a question that might easily be answerable for pros.

What I need to do is the following: I have a (rather simple) quad mesh in a 3D modelling software, say, Blender. Now I export that mesh to use it in another application (I therefore won't have access to the texture mapping algorithm that was used to texture the mesh). To export, I currently use the .obj file format.

Now, within that other application, I will be given a texture coordinate (in [0,1]), and need to determine its world position and normal, do to some further processing. The way I currently go about this is the following:

My .obj file tells me how many faces there are, and which vertices (in world pos., and texture coordinates) these faces consist of. It also tells me the face normal. Now, for the newly given uv coordinates, I do a (kind of) rasterization, and check for all faces whether the new uv coordinates lie within the uv-range that the face's vertices map to. After that, I use these vertices and their world position to interpolate the new world position of the given uv coordinates. The normal at the given uv coordinates is the face normal.

This works, but feels kind of clumsy. As I said, I'm rather new to CG, so my question is: Is there a simpler way of determining world space position and normal, given a UV coordinate and no access to the texture mapping algorithm?

  • $\begingroup$ Usually the object space position and normal are included in the .obj file. Your code just needs to convert object space to world space by multiplying it with a matrix which is usually called the "model matrix" and is the "M" in the MVP matrix. $\endgroup$
    – pmw1234
    Feb 26 '21 at 11:55

Your Answer

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

Browse other questions tagged or ask your own question.