Chapter 3
Chapter 3
• In a 2-D coordinate system the X axis generally points from left to right, and the Y axis
generally points from bottom to top.
• When we add the third coordinate, Z, we have a choice as to whether the Z-axis points into
the screen or out of the screen: Right Hand Coordinate System (RHS)
Z is coming out of the page
Counterclockwise rotations are positive
if we rotate about the X axis : the rotation Y->Z is positive
if we rotate about the Y axis : the rotation Z->X is positive
if we rotate about the Z axis : the rotation X->Y is positive
• Note that the order of matrix multiplication is reversed (remember that we need to read matrix
multiplication from right to left).
• The resulting vertex should then be assigned to gl_Position in the vertex shader and OpenGL will then
automatically perform perspective division and clipping
• And then
• The output of the vertex shader requires the coordinates to be in clip-space which is what we just
did with the transformation matrices.
• OpenGL then performs perspective division on the clip-space coordinates to transform them
to normalized-device coordinates.
• OpenGL then uses the parameters from glViewPort to map the normalized-device coordinates
to screen coordinates where each coordinate corresponds to a point on your screen.
• This process is called the viewport transform.
Viewing using a synthetic camera
• How to explain 3D viewing, projection to the computer.
• The paradigm which looks at creating a computer generated image as being similar to forming an
image using an optical system.
• Synthetic camera paradigm
• Position of camera (Center of Projection)
• Area of interest (direction camera lens is pointed in) (Projector lines)
• Orientation (which way is up)
• Field of view (wide angle, normal...)
• Depth of field (clipping planes, sort of)
• Tilt of view/film plane (if not normal to view direction)
• Perspective or parallel projection? (camera near objects or an infinite distance away)
• In case of image formation using optical systems, the image is flipped relative to the object.
• In synthetic camera model this is avoided by introducing a plane in front of the lens which is called
the image plane.
• The angle of view of the camera poses a restriction on the part of the object which can be viewed.
• This limitation is moved to the front of the camera by placing a Clipping Window in the projection
Cont’d (Position)
• Determining the Position is analogous to a photographer deciding the vantage point from
which to shoot a photo
• Three degrees of freedom: x, y, and z coordinates in 3-space
• This x, y, z coordinate system is right-handed: if you open your right hand, align your palm
and fingers with the +x axis, and curl your fingers towards the +y axis, your thumb will point
along the +z axis
Cont’d (Orientation)
• Orientation is specified by a point in 3D space to look at (or a direction to look in) and an angle
of rotation about this direction
• Default (canonical) orientation is looking down the negative z-axis and up direction pointing
straight up the y-axis
• In general the camera is located at the origin and is looking at an arbitrary point with an
arbitrary up direction
Cont’d (Orientation)
Truncated view volume means we only need to render what the camera can see
Cont’d (Truncated View Volume for Orthographic
Parallel Projection)
• Limiting view volume useful for eliminating extraneous objects
• Orthographic parallel projection has width and height view angles of zero
Cont’d (Truncated View Volume (Frustum) for
Perspective Projection)
• Removes objects too far from Position, which otherwise would merge into “blobs”
• Removes objects too close to Position (would be excessively distorted)
3-D APIs (OpenGL - basics)
• To follow the synthetic camera model discussed earlier, the API should support:
• Objects, viewers, light sources, material properties.
• OpenGL defines primitives through a list of vertices.
• Primitives: simple geometric objects having a simple relation between a list of vertices
• Simple prog to draw a triangular polygon :
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(0.0, 0.0, 1.0);
glEnd( );
• Specifying viewer or camera:
• Position - position of the COP
• Orientation – rotation of the camera along 3 axes
• Focal length – determines the size of image
• Film Plane – has a height & width & can be adjusted independent of orientation of lens.
Cont’d
• Function call for camera orientation :
gluLookAt(cop_x,cop_y,cop_z,at_x,at_y,at_z,up_x,up_y,up_z);
gluPerspective(field_of_view,aspect_ratio,near,far);
• Lights and materials :
• Types of lights
Point sources vs distributed sources
Spot lights
Near and far sources
Color properties
• Material properties
Absorption: color properties
Scattering
A small set of geometric primitives
Cont’d (OpenGL Primitives)
Cont’d (Specifying geometric primitives)
• Each geometric object is described by:
• A set of vertices
• Type of the primitive
Cont’d (Attributes)
• Attributes are part of the OpenGL state and determine the appearance of objects
• Color (points, lines, polygons)
• Size and width (points, lines)
• Stipple pattern (lines, polygons)
• Polygon mode
• Display as filled: solid color or stipple pattern
• Display edges
Question