4

I need to make a human 2D face to 3D face. I used this link to load an ".obj" file and map the textures. This example is only for cube and pyramid. I loaded a human face ".obj" file.

This loads the .obj file and can get the human face properly as below. enter image description here

But my problem here is I need to display different human faces without changing the ".obj" file. just by texture mapping.

But the texture is not getting mapped properly, as the obj file is of different model. I just tried changing the ".png" file which is used as texture and the below is the result, where the texture is mapped but not exactly what I expected, as shown below.

enter image description here

The below are my few questions on it :

1) I need to load texture on same model( with same .obj file ) with different images. Is it possible in opengles?

2) If the solution for above problem is "shape matching", how can I do it with opengles?

3) And finally a basic question, I need to display the image in large area, how to make the display area bigger?

2vision2
  • 4,933
  • 16
  • 83
  • 164

1 Answers1

9

mtl2opengl is actually my project, so thanks for using it!

1) The only way you can achieve perfect texture swapping without distortion is if both textures are mapped onto the UV vertices in exactly the same way. Have a look at the images below:

Texture Swapping with misaligned vertices

As you can see, textures are made to fit the model. So any swapping to a different geometry target will result in distortion. Simplified, human heads/faces have two components: Interior (Bone/Geometry) and Exterior (Skin/Texture). The interior aspect obviously defines the exterior, so perfect texture swapping on the same .obj file will not work unless you change the geometry of the model with the swap.

2) This is possible with a technique called displacement mapping that can be implemented in OpenGL ES, although with anticipated difficulty for multiple heads/faces. This would require your target .obj geometry to start with a pretty generic model, like a mannequin, and then use each texture to shift the position of the model vertices. I think you need to be very comfortable with Modeling, Graphics, Shaders, and Math to pull this one off!

enter image description here

3) I will add more transform options (scale & translate) in the next update. The Xcode project was actually made to show off the PERL script, not as a primer for OpenGL ES on iOS. For now, find the modelViewMatrix and fiddle with this little bit:

GLKMatrix4Scale(_modelViewMatrix, 0.30, 0.33, 0.30);

Hope that answers all your questions!

Ricardo RendonCepeda
  • 3,271
  • 4
  • 23
  • 30
  • Thanks! I hope you make good progress on your project as it looks very interesting. I will also try to expand `mtl2opengl` and include a doc in the future – Ricardo RendonCepeda Mar 15 '13 at 14:27
  • Yeah. Thanks a lot. Its going good so far. Am getting fumbled in opengles. And I didnt fix this issue http://stackoverflow.com/questions/15384079/texture-mapping-not-working-in-glkit-only-in-devices still now. And you can always view my questions section, I have added few questions now!!! A sample here http://stackoverflow.com/questions/15432468/make-a-layer-over-an-image-and-adjust-its-co-ordinates-by-touch – 2vision2 Mar 15 '13 at 14:40
  • Hi is it possible to achieve the above with a unique obj file that fits all the human models? Do you have any such obj files? If it there can you please provide me? – 2vision2 Mar 20 '13 at 06:48
  • Sorry for the late reply... This [female mannequin head](http://www.turbosquid.com/3d-models/3d-female-mannequin/423652) could be a good starting point, but it's not free and it's more suitable to the female models in my answer rather than the male models in your question. Also, a small matter, but do you think you could 'accept' my answer too? Thanks! – Ricardo RendonCepeda Mar 25 '13 at 16:12
  • Is there any OpenGLES API available for displacement mapping .. Can you provide any reference... – 2vision2 Apr 12 '13 at 08:09
  • I'll have a look and see what I can find, but you should probably ask this as a separate question. It'll draw more attention and keep things nicely organized :) – Ricardo RendonCepeda Apr 12 '13 at 13:49
  • Thanks... actually I posted the question [here](http://stackoverflow.com/questions/15614090/displacement-texture-mapping-in-opengles?lq=1).. and got no response.. If possible, can you tell me how to improve the question.. or Answer it :) – 2vision2 Apr 13 '13 at 05:34