Graphics Rendering Pipeline
- OpenGL's general goal is the representation of a 3D scene on a 2D plane.
- Accomplished using a pipeline to compose transformations
from object space to screen space.
- Mathematically, simply a set of transformations (makes use of homogeneous coordinates)
- Currently, several stages are
programmable
- add arbitrary (assembly) code in addition to matrix composition
- limits on information available and computation that can be done
- amazing results (will study in detail later)
Coordinate Spaces
Object Space (3D)
- Also called modeling space
- Object of unit size centered at origin
- Model of object constructed using, typically, triangle strips
- glVertex3f(-0.25, 0, 0)
World Space (3D)
- Position, rotate, scale object in relation to other objects
- Light objects
- glMatrixMode(GL_MODELVIEW)
Eye Space (3D)
- Also called normalized viewing space
- Position, rotate, scale object as seen by camera
- Clip, remove, objects not visible within camera frustrum
- glMatrixMode(GL_PROJECTION)
Viewport Space (3D)
- Also called image space
- Project objects onto camera's 2D viewport
- Clip, remove, hidden surfaces
Screen Space (2D)
- Scale object to device coordinates, based on dimensions of window on screen
- Scan convert, rasterize, object from geometry to pixels
- Color object based on capabilities of hardware
- glViewport(0, 0, theWindowWidth, theWindowHeight)
Homogeneous Coordinates
- History
- Invented in 1827 independently by both Mòbius and Karl Wilhelm Feuerbach
- Developed more completely in 1946 by EA Maxwell
- Allows the coordinates of points, including points at infinity, to be represented finitely
- Novel because provides insight to allow geometry to be computed algebraically
- Allows all graphics transforms to be handled uniformly and, in general, often lead to simpler and more symmetric formulae than their Cartesian counterpart
- Short summary (from OpenGL
Programming Guide by M. Woo et al)
- OpenGL works in the homogeneous coordinates of three-dimensional projective geometry, so for internal calculations, all vertices are represented with four floating-point coordinates (x, y, z, w). If w is different from zero, these coordinates correspond to the Euclidean three-dimensional point (x/w, y/w, z/w). You can specify the w coordinate in OpenGL commands, but that's rarely done. If the w coordinate isn't specified, it's understood to be 1.0.
- Motivation (from A
Unified Algebraic Framework for Classical Geometry by D Hestenes et
al)
- The standard algebraic model for Euclidean space En is an n-dimensional real vector space Rn or, equivalently, a set of real coordinates. One trouble with this model is that, algebraically, the origin is a distinguished element, whereas all the points of En are identical. This deficiency in the vector space model was corrected early in the 19th century by removing the origin from the plane and placing it one dimension higher. Formally, that was done by introducing homogeneous coordinates. The vector space model also lacks adequate representation for Euclidean points or lines at infinity. We solve both problems here with a new model for En employing the tools of geometric algebra. We call it the homogeneous model of En.
- Relationship between points and vectors (from OpenGL
Programming Guide by M. Woo et al)
- As long as w is nonzero, the homogeneous vertex (x, y, z, w)T corresponds to the three-dimensional point (x/w, y/w, z/w)T. If w = 0.0, it corresponds to no Euclidean point, but rather to some idealized "point at infinity." To understand this point at infinity, consider the point (1, 2, 0, 0), and note that the sequence of points (1, 2, 0, 1), (1, 2, 0, 0.01), and (1, 2.0, 0.0, 0.0001), corresponds to the Euclidean points (1, 2), (100, 200), and (10000, 20000). This sequence represents points rapidly moving toward infinity along the line 2x = y. Thus, you can think of (1, 2, 0, 0) as the point at infinity in the direction of that line.
If we homogenize the point (divide by W), we get a point of the form (x, y, 1). Thus, the homogenized points form a plane defined by the equation W = 1 in (x, y, W)-space.
References
- Notes on viewing by Steve Marschner
- Notes on OpenGL Matrix Structure by Robert Cox
- Planar Geometric Projections and Viewing Transformations by Ingrid Carlbom and Joseph Paciorek
- The Truth Behind Homogeneous Coordinates by Gottfried
- The Science of Art by Martin Kemp