Saturday, November 22, 2008

Synthetic Camera

Synthetic camera

Difference between Normal Camera (Pin Hole Camera) and synthetic camera is show in figure 1. From the figure you can easily distinguish where images in both camera's get generated. In case of pin hole camera rays of light from the outside go through the hole and land on the image plane, which is the entire back of the the box. And in case of synthetic camera image plane is placed in between pin hole and object to be viewed. This way we can get mathematical projection of the object. Not reverse projection as in case of pin hole camera.

Figure 1.

Important terms related to synthetic camera paradigm.

  • Position of camera

  • View Direction (direction camera lens is pointed in)

  • orientation (which way is up)

  • field of view (wide angle, normal...)

  • depth of field (clipping planes, sort of)

  • View Plane Normal (if not normal to view direction)

  • perspective or parallel projection? (camera near objects or an infinite distance away)

Figure 2.

  1. Center of Projection.

    Is the point where all rays converges. In case of parallel projection instead of center of projection direction of projection in considered.

  2. View Plane or Projection plane

      Plane on which 2d Image will be generated. Generally most of the application treat Near Plane as view plane.

Figure 3
    1. View plane is defined by a point called view reference point (VRP) and view plane normal (VPN) a vector perpendicular to the plane. And view window is described by maximum and minimum of u & v values.

  1. Near Plane

    near distant clipping plane.

  2. Far Plane

    far distant clipping plane.

  3. Look Vector

    Direction in which camera is directed. View Direction.

  4. Visibility Frustum

    which means "sawed off cone". Area bound by near plane and far plane. Defining visibility frustum helps us in identifying which objects will be discarded, clipped or rendered while generating image.

Implementation in OpenGL

In order to define the "synthetic camera", we specify the viewing frustrum or viewing volume. The frustum is a simplified means of providing all the camera parameters for the full synthetic camera - View Up, Viewplane Normal, VRP, etc. See the picture below
To specify the frustum, we need six numbers: left, right, top, bottom, near and far coordinates. The "x and y" parameters (min and max of each) apply to the near plane, which will serve both as the near clipping plane and the viewscreen.

glMatrixMode(GL_PROJECTION);

glLOadIdentity();

glFrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 7.0);

where declaration of glFrustum is
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
GLdouble near, GLdouble far)
left, right : the coordinates for the left and right vertical clipping planes.
bottom, top: the coordinates for the bottom and top horizontal clipping planes.
near, far: the distances to the near and far depth clipping planes. Both distances must be positive.

which means that everything we want to see will have z coordinates between 2 and 7. Its X and Y coordinate maxima vary, depending on where in Z the point is. The sides of the frustum slope, after all.

OpenGL has now used these frustum parameters to set up the Synthetic Camera - a mapping which will bring 3d data into 2d screen coordinates when we draw it.