Professional Documents
Culture Documents
Two components of viewing - Set of geometric objects that form the content of the scene - Viewer through which the scene is imaged
Transforms primitives to the cameras coordinate system, prepares them for rasterization Culls primitives facing away from the camera or lying outside the view frustum
The rasterizer
Fragment processor
Checks if fragments are visible Determines color All fragments treated identically, irrespective of the original primitive
Frame buffer
Memory buffer used for the construction of the image. Not all data that passes through the frame buffer is displayed. It is like a sandbox in which the image is constructed. Used by the window system for display.
Double buffering
Rendering Window system
Back buffer
Front buffer
Render into the back buffer while the window system points to the front buffer. When the next frame is assembled, swap. Avoids terrible visual artifacts
Double buffering
Rendering Window system
Front buffer
Back buffer
Render into the back buffer while the window system points to the front buffer. When the next frame is assembled, swap. Avoids terrible visual artifacts
Great for parallel processing Primitives processed independently Fragments processed independently Does not support interactions between multiple objects in the scene Global illumination, shadows, reection, refraction
Global illumination
Consider indirect illumination that is transmitted by means of other objects Primitives are no longer independent
Ray tracing
Rays are cast from the viewpoint and followed recursively through the scene. Whitted ray tracing: Compute direct illumination from light sources at every point hit by traced rays
CC image from Wikipedia (author: Mimigu)
Radiosity
Discretize scene into patches. Compute strength of interaction between patches. Shoot light from source patches, deposit in other patches. Iterate until light is absorbed.
Cornell University Program of Computer Graphics
Photon mapping
Stage 1: Trace photons from light sources and deposit onto photon map when photons interact with diffuse surfaces Stage 2: Cast rays from viewpoint and estimate radiance
OpenGL
Save developers from having to implement standard functionality Facilitate portability through abstraction
#include <GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); glEnd(); glFlush(); } void init() { glClearColor (0.0, 0.0, 0.0, 0.0); glColor3f(1.0, 1.0, 1.0); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); }
Code sample
int main(int argc, char** argv) { glutInit(&argc,argv); glutCreateWindow("simple"); glutDisplayFunc(display); init(); glutMainLoop(); }
Enable applications to run on a variety of platforms Describe rendering operations succinctly Accommodate extensions as graphics hardware evolves Maximize performance by closely modeling the capabilities and characteristics of graphics hardware
OpenGL was designed to work with a variety of window systems - Interaction with the window system is handled by GLUT No facilities for obtaining user input Does not handle the actual display, merely assembles an image
A rendering API
The OpenGL API supports the display of geometric primitives - Takes a specication of geometric objects - Computes illumination - Images the scene Modeling and animation largely left to the application
Separates object description from viewer specication Two types of functions - Describe objects in the world (the input) - Specify how the objects should be processed for constructing an image (the state)
State machine with inputs and outputs - Input is geometric objects, output is a set of pixels - State machine converts a collection of geometric objects in three dimensions to an image. This process is controlled by the state. - State species how objects are projected onto the image plane, how the are colored, etc.
Segal and Akeley, The Design of the OpenGL Graphics Interface, 1994
EnableClientState DisableClientState
EdgeFlagPointer TexCoordPointer ColorPointer IndexPointer NormalPointer VertexPointer InterLeavedArrays Evaluator EvalMesh ArrayElement DrawElements DrawArrays Map Evaluation EvalCoord EvalPoint Grid Application Control Vertex Array Control MapGrid
The OpenGL! graphics system diagram, Version 1.1. Copyright " 1996 Silicon Graphics, Inc. All rights reserved.
Map Enable/Disable
EdgeFlag
TexCoord1
TexCoord2
TexCoord3
1 Current TexGen
TexCoord4
Texture Coordinates
Vertices
Evaluators & Vertex Arrays
Material Parameters Control
Color3
Color4
LightModel Begin/End
Index
Light Enable/Disable
Light Parameters
Material Parameters
Lighting
RGBA Lighting Equation Normal3 Convert normal coords to float Current Normal b M Color Index Lighting Equation M*b Normalize
Vertex2 RasterPos2
MT M FrontFace
Enable/Disable (Lighting)
Matrix Control
Vertex3 RasterPos3
Rasteriz ation
Vertex4 RasterPos4
OBJECT COORDINATES
M M
M*b
EYE COORDINATES
Pixels
Rect
Rectangle Generation
Primitives
Model View Matrix Stack
Fragments
Matrix Control
LoadIdentity LoadMatrix M*N N M Clip Planes Projection Matrix Stack Viewport DepthRange
ShadeModel
POLYGONS
Flatshading
Polygon Clipping
M M*b
Polygon View Volume Clipping Line View Volume Clipping Point View Volume Culling
Apply Viewport
M*b
Texel Generation
Texture Application
Fog
Scissor Test
Stencil Test
Dithering
Logic Op
Notes: 1. Commands (and constants) are shown without the gl (or GL_) prefix. 2. The following commands do not appear in this diagram: glAccum, glClearAccum, glHint, display list commands, texture object commands, commands for obtaining OpenGL state (glGet commands and glIsEnabled), and glPushAttrib and glPopAttrib. Utility library routines are not shown. 3. After their exectution, glDrawArrays and glDrawElements leave affected current values indeterminate. 4. This diagram is schematic; it may not directly correspond to any actual OpenGL implementation.
PixelZoom
Clear Values
DepthMask StencilMask
Frame Buffer
ColorMask IndexMask
ReadPixels
Pack Pixels
ReadBuffer
Segal and Akeley, The OpenGL Graphics System: A Specication (Version 1.1)
OpenGL is imperative - Operations specify how rendering should be conducted (by changing the state) - Operations do not execute individual rendering operations In declarative APIs (cf. RenderMan), the application commands the graphics system what to do, not just how to do what it does The OpenGL abstraction controls what appears to happen, not what actually happens. Leaves signicant freedom for optimization by OpenGL implementations.
Graphics hardware
Rendering server
Central assumptions: The client is computationally weak, the server is computationally powerful Bandwidth is low
Graphics hardware
Rendering server
Examples Color is part of the state, not associated with the primitive. When a new transformation matrix is specied, the default behavior is to multiply, rather than replace
Persisting primitives