Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opengles display human face in iphone

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?

like image 534
2vision2 Avatar asked Jan 14 '23 23:01

2vision2


1 Answers

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

  • Model A: Blonde Girl
  • Model B: Ashley Head

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

  • Via Wikipedia

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!

like image 59
Ricardo RendonCepeda Avatar answered Jan 18 '23 22:01

Ricardo RendonCepeda