patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.91k stars 597 forks source link

About fitting::RenderingParameters in opengl #185

Closed bigdimboom closed 6 years ago

bigdimboom commented 6 years ago
  1. I'm trying to get opengl and the fitting algorithm working. What's the correct way of using "RenderingParameters". What's coordinates convention for this class? How can I get the correct opengl model view projection from this class. I tested the rendering with my own projection matrix. It looks like mode view in this class is working fine. The projection might be reversed.

  2. Then, I will be using projection method to get the projected uv and do the textured mapping without extracting isomap first. What's projection matrix for getting UV mapping for vertices?

bigdimboom commented 6 years ago

o.k. I think I found the answer.

  1. the projection matrix in RenderingParameters is for web camera
  2. when you need use the projection for opengl rendering you need flip it.
patrikhuber commented 6 years ago

RenderingParameters has a get_modelview() and get_projection() function. They use glm actually, and for the projection, you'll get a glm::ortho(...) matrix back, which should be "OpenGL-compliant".

The projection matrix doesn't really have anything to do with Webcam.

What do you mean "flip" - transpose? And what exactly are you "flipping"?

bigdimboom commented 6 years ago
  1. no transpose on projection matrix is needed. I found out that the projection matrix can project mesh along with model_view to get the texture cords without the need of using "extract_isomap".
  2. protected texture(x,y,z,w) are homogeneous coordinates. so one must convert it to uv space first
  3. after I project and convert it to the uv space, the mapped texture is still somehow flipped vertically. So I flipped the y by (1.0 - y).
patrikhuber commented 6 years ago

Good that you figured it out :-)

The flip in "2." is probably because some libraries use the top-left corner as image origin (0, 0) while others use the bottom-left.