PDA

View Full Version : How to simulating focal length in OpenGL ?



ddguan
07-30-2014, 02:17 AM
Dear All:
My application need me to simulate a virtual camera in OpenGL.
How to simulate or compute the focal length based on glulookat and gluperspective?
In computer vision, if a 3d point locate at (X,Y,Z) (in camera coordinate system),
then this point should be project to the image pixel (u,v)=(f*X/Z,f*Y/Z).
How to simulate this? I mean if the camera position ,direction and focal f are given, how to calculate the fovy and znear?

Dark Photon
07-30-2014, 05:01 AM
Websearch "depth of field" techniques. Possibly in combination with "OpenGL". Also search "bokeh" possibly in combination with "pettineo". Lots of good stuff out there. The basic concept is that you have a depth that is perfectly in-focus but as you get further from the plane, you get more and more out-of-focus. Blur is often used to simulate the out-of-focus effect.