I’m fairly new to openGL. For my phd I have to try to put a face of someone else on top of my face in a way it looks ‘realistic’. I have a problem with the shading part (at least to start with). At some point in the software the face from the camera is taken and with some points on the face a model is calculated. This model is then drawn with openGL and a texture (of someones face) is applied to the model. So I thought that the shading would also be possible to do with openGL. But when I enable the lighting in openGL and put a light on the right side of the model (together with an ambient light) it does not work as I intended. When I move the head to the back (away from the camera) it seems as if light doesn’t reach the model. I looked at the max and min coordinate values of the model and saw that this problem arises when the model is behind the origin (thus z-values are negative). I have made some videos to visualize the problem for you:
the videos are available at http://staff.science.uva.nl/~aazcarat/openGL/
under0continue.avi - video of the problem without stopping
under0exit.avi - video of the problem stopped at the point where the maxZ value of the model is below 0.0
In this directory you can also find the debug output from the software. In this txt file all the openGL calls that are in the software are printed in order of flow:
Debug-under0continue.txt - the debug output gotten with the under0continue.avi file
Debug-under0exit.txt - the debug output gotten with the under0exit.avi file (as soon as the maxX is under 0 the program is stopped (–max-X-Y-Z-> 48.6611,61.7238 -2.97314))
When you see in the output something like this:
glFrustum(0 - GetHalfHeight() * GetWHRatio(), GetHalfHeight() * GetWHRatio(),0 - GetHalfHeight(), GetHalfHeight(), GetFocusLength(), GetDepth() + 50000)
----> -10.6667,10.6667 -8
----> 8,30 50600
This means that 0 - GetHalfHeight() * GetWHRatio() is the first value after the ----->. Thus 0 - GetHalfHeight() * GetWHRatio() is -10.6667 and GetHalfHeight() * GetWHRatio() is 10.6667 etc.
The openGL calls that are of importance (at least thats what I think) are the ones under these lines:
====HERE THE TEXTURE IS UPDATED WITH THE FACE FROM THE IMAGE=====
===============FROM THIS POINT THE PROBLEM ARISES===============
Each frame the model and texture is redrawn. This line
is the point where the face has finished drawing ,thus after these lines the next frame is taken from the webcam and ‘everything’ is recalculated and redrawn. That is why a lot is done repeatedly.
I hope someone can help me and that I have explained my problem as well as possible. I’m not able to give the code because it is not publicly available (it is not my code, I just have to improve it).
All help is welcome. If I have to explain it in more detail just mention it. Thanks in advance for the help.
P.S: I don’t know if this problem is in the right forum subgroup. If so, sorry for that.