Upload
sandeep-kaushik
View
220
Download
0
Embed Size (px)
Citation preview
8/3/2019 Pipeline and Op Engl
1/32
8/3/2019 Pipeline and Op Engl
2/32
The synthetic camera model
Two components of viewing- Set of geometric objects that form the content
of the scene
- Viewer through which the scene is imaged
8/3/2019 Pipeline and Op Engl
3/32
The graphics pipeline
Primitives
Geometry processor
Rasterizer
Fragment processor
Frame buffer
8/3/2019 Pipeline and Op Engl
4/32
The geometry processorPrimitives
Geometry
processor
Rasterizer
Fragment processor
Frame buffer
Transforms primitives to the cameras coordinatesystem, prepares them for rasterization
Culls primitives facing away from the camera or lyingoutside the view frustum
8/3/2019 Pipeline and Op Engl
5/32
The rasterizerGeometry processorRasterizer
Fragment processor
Frame buffer
Generates fragments (proto-pixels)
Primitives
8/3/2019 Pipeline and Op Engl
6/32
Fragment processorGeometry processorRasterizer
Fragmentprocessor
Frame buffer
Checks if fragments are visible
Determines color
All fragments treated identically, irrespective of the
original primitive
Primitives
8/3/2019 Pipeline and Op Engl
7/32
Frame bufferGeometry processorRasterizer
Fragment processor
Frame buffer
Memory buffer used for the construction of the image.
Not all data that passes through the frame buffer isdisplayed. It is like a sandbox in which the image isconstructed.
Used by the window system for display.
Primitives
8/3/2019 Pipeline and Op Engl
8/32
Double buffering
Front bufferBack buffer
Rendering Window system
Render into the back buffer while the window system pointsto the front buffer. When the next frame is assembled, swap.
Avoids terrible visual artifacts
Geometry processor
Rasterizer
Fragment processor
Frame buffer
Primitives
8/3/2019 Pipeline and Op Engl
9/32
Double buffering
Back bufferFront buffer
Rendering Window system
Render into the back buffer while the window system pointsto the front buffer. When the next frame is assembled, swap.
Avoids terrible visual artifacts
Geometry processor
Rasterizer
Fragment processor
Frame buffer
Primitives
8/3/2019 Pipeline and Op Engl
10/32
Advantages and disadvantages ofpipeline model
Great for parallel processing
- Primitives processed independently
- Fragments processed independently
Does not support interactions between multipleobjects in the scene
- Global illumination, shadows, reflection, refraction
Geometry processor
Rasterizer
Fragment processor
Frame buffer
Primitives
8/3/2019 Pipeline and Op Engl
11/32
The pipeline is evolving
8/3/2019 Pipeline and Op Engl
12/32Blythe, The Direct3D 10 System, SIGGRAPH 2006
8/3/2019 Pipeline and Op Engl
13/32
Alternatives to the pipeline?
8/3/2019 Pipeline and Op Engl
14/32
Global illumination
Consider indirect illumination that is transmitted bymeans of other objects
Primitives are no longer independent
8/3/2019 Pipeline and Op Engl
15/32
Rays are cast from the viewpoint and followed recursivelythrough the scene.
Whitted ray tracing: Compute direct illumination from lightsources at every point hit by traced rays
Ray tracing
CC image from Wikipedia (author: Mimigu)
8/3/2019 Pipeline and Op Engl
16/32
Discretize scene into patches. Compute strength ofinteraction between patches.
Shoot light from source patches, deposit in other patches.
Iterate until light is absorbed.
Radiosity
Cornell University Program of Computer Graphics
8/3/2019 Pipeline and Op Engl
17/32
Photon mapping
Stage 1: Trace photons from light sources and deposit ontophoton map when photons interact with diffuse surfaces
Stage 2: Cast rays from viewpoint and estimate radiance
8/3/2019 Pipeline and Op Engl
18/32
OpenGL
8/3/2019 Pipeline and Op Engl
19/32
Why a graphics API?
8/3/2019 Pipeline and Op Engl
20/32
Why a graphics API?
Save developers from having to implementstandard functionality
Facilitate portability through abstraction
8/3/2019 Pipeline and Op Engl
21/32
#include
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);
}
int main(int argc, char** argv){
glutInit(&argc,argv);
glutCreateWindow("simple");glutDisplayFunc(display);init();glutMainLoop();
}
Code sample
8/3/2019 Pipeline and Op Engl
22/32
Design considerations for OpenGL
Enable applications to run on a variety of platforms
Describe rendering operations succinctly
Accommodate extensions as graphics hardware evolves
Maximize performance by closely modeling thecapabilities and characteristics of graphics hardware
8/3/2019 Pipeline and Op Engl
23/32
Agnostic to the window system
OpenGL was designed to work with a variety ofwindow systems
- Interaction with the window system is handled byGLUT
No facilities for obtaining user input
Does not handle the actual display, merely assemblesan image
8/3/2019 Pipeline and Op Engl
24/32
A rendering API
The OpenGL API supports the display of geometric primitives
- Takes a specification of geometric objects
- Computes illumination
- Images the scene
Modeling and animation largely left to the application
8/3/2019 Pipeline and Op Engl
25/32
Separation of content and viewer
Separates object description from viewer specification
Two types of functions
- Describe objects in the world (the input)
- Specify how the objects should be processed for
constructing an image (the state)
8/3/2019 Pipeline and Op Engl
26/32
OpenGL is a state machine
State machine with inputs and outputs
-Input is geometric objects, output is a set of pixels
- State machine converts a collection of geometricobjects in three dimensions to an image. Thisprocess is controlled by the state.
- State specifies how objects are projected onto theimage plane, how the are colored, etc.
8/3/2019 Pipeline and Op Engl
27/32
Segal and Akeley, The Design of the OpenGL Graphics Interface, 1994
8/3/2019 Pipeline and Op Engl
28/32
8/3/2019 Pipeline and Op Engl
29/32
Declarative vs. Imperative programming
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 applicationcommands the graphics system whatto do, not just howtodo what it does
The OpenGL abstraction controls what appears to happen,not what actually happens. Leaves significant freedom foroptimization by OpenGL implementations.
8/3/2019 Pipeline and Op Engl
30/32
Client vs. Server
Application Graphics hardware
Rendering client Rendering server
Narrow pipe
Central assumptions:
- The client is computationally weak, the server iscomputationally powerful
- Bandwidth is low
8/3/2019 Pipeline and Op Engl
31/32
Client vs. Server
Application Graphics hardware
Rendering client Rendering server
Narrow pipe
Examples
- Color is part of the state, not associated with the primitive.
- When a new transformation matrix is specified, the defaultbehavior is to multiply, rather than replace
8/3/2019 Pipeline and Op Engl
32/32
Persisting primitives
Display lists
Vertex buffer objects