10: The OpenGL Pipeline
01: Projective Pipeline
COMP5822M: High Performance Graphics
Synthetic Camera
Use Geometry to Place Camera
(View Transformation)
Use Geometry to Place Models
(Model Transformation)
Use Projection to Describe Camera
(Projection Transformation)
Use Projection to Describe Screen
(Viewport Transformation)
COMP5822M: High Performance Graphics
Coordinate Systems
OCS is the Object Coordinate System
WCS is the World Coordinate System
VCS is the View Coordinate System
CCS is the Clipping Coordinate System
NDCS is the Normalized DCS
DCS is the Device Coordinate System
COMP5822M: High Performance Graphics
Coordinate Systems
Model
Matrix
View
Matrix
Object Model
World Model
View Model
Clipping
Projection
Matrix
Perspective
Division
Viewport
Transformation
Image Plane
Screen
COMP5822M: High Performance Graphics
Projective Rendering
Fundamental trick behind video card
Project each triangle to image plane
Triangles always project as triangles
We need to rasterise (draw) lines & triangles
COMP5822M: High Performance Graphics
Depth (Z-) Buffering
For each pixel, set Z = -∞
For each triangle
Transform to image coordinates
Rasterise to fragments – possible pixels
For each fragment (X, Y, Z, R, G, B)
If depth(X,Y) < Z, discard
Else depth(X,Y) = Z, colour(X,Y) = (R,G,B)
COMP5822M: High Performance Graphics
The Projective Pipeline
COMP5822M: High Performance Graphics
Fixed Function Pipeline
This is the original hardware design
Deeply pipelined, massively parallel
Now simulated by GP processors
COMP5822M: High Performance Graphics
Let’s Implement It
We’ll look at one stage at a time
Vertex Data
Geometry Transformation
Rasterisation
Textures
Fragments
Framebuffer
COMP5822M: High Performance Graphics
Assumptions
Each stage runs separately
On its own thread (or many threads)
We use locking queues to transfer data:
Vertices, Triangles, Fragments
User code is single-threaded
And we’ve got a GUI of some sort
But I’ll abstract that a lot
COMP5822M: High Performance Graphics
Example of OpenGL
COMP5822M: High Performance Graphics
Example of OpenGL, II
COMP5822M: High Performance Graphics
Render Code Example
COMP5822M: High Performance Graphics
GUI / Startup
COMP5822M: High Performance Graphics
Queues (Types Later)
COMP5822M: High Performance Graphics
Transformation Matrices
COMP5822M: High Performance Graphics
Setting the Matrices
COMP5822M: High Performance Graphics
Vertex State
COMP5822M: High Performance Graphics
Setting Vertex State
COMP5822M: High Performance Graphics
Setting Vertex State, II
COMP5822M: High Performance Graphics
The glVertex() Call
COMP5822M: High Performance Graphics
Lighting State
COMP5822M: High Performance Graphics
Enable/Disable
COMP5822M: High Performance Graphics
The Geometry Loop
COMP5822M: High Performance Graphics
Transforms for Lighting
COMP5822M: High Performance Graphics
View Transforms
COMP5822M: High Performance Graphics
Raster Loop
COMP5822M: High Performance Graphics
Barycentric Interpolation
COMP5822M: High Performance Graphics
Fragment Interpolation
COMP5822M: High Performance Graphics
Fragment Data
COMP5822M: High Performance Graphics
Fragment Loop
COMP5822M: High Performance Graphics
Fragment Loop, II
COMP5822M: High Performance Graphics
Framebuffer Operations
COMP5822M: High Performance Graphics
Evolved Pipeline
(Tessellation)
Vertex
Stream
Geometry
Shader
Vertex
Shader
Post Transform
Cache
Rasteriser
Fragment
Stream
Depth Test
Fragment
Shader
Frame Buffer
Image Input
Texture
Storage
Compute Shader
COMP5822M: High Performance Graphics