the rendering pipeline cs 445/645 introduction to computer graphics david luebke, spring 2003
TRANSCRIPT
The Rendering Pipeline
CS 445/645Introduction to Computer Graphics
David Luebke, Spring 2003
David Luebke 2 04/20/23
Admin
● Call roll● Assignment 0: questions?
David Luebke 3 04/20/23
Framebuffers
● So far we’ve talked about the physical display device● How does the interface between the device and the
computer’s notion of an image look?● Framebuffer: A memory array in which the computer
stores an image■ On most computers, separate memory bank from main
memory (why?)■ Many different variations, motivated by cost of memory
David Luebke 4 04/20/23
Framebuffers: True-Color
● A true-color (aka 24-bit or 32-bit) framebuffer stores one byte each for red, green, and blue
● Each pixel can thus be one of 224 colors● Pay attention to
Endian-ness● How can 24-bit
and 32-bit mean the same thing here?
David Luebke 5 04/20/23
Framebuffers: Indexed-Color
● An indexed-color (8-bit or PseudoColor) framebuffer stores one byte per pixel (also: GIF image format)
● This byte indexes into a color map: ● How many colors
can a pixel be?● Still common on
low-end displays (cell phones, PDAs,GameBoys)
● Cute trick: color-map animation
David Luebke 6 04/20/23
Framebuffers: Hi-Color
● Hi-Color is/was a popular PC SVGA standard● Packs pixels into 16 bits:
■ 5 Red, 6 Green, 5 Blue (why would green get more?)■ Sometimes just 5,5,5
● Each pixel can be one of 216 colors● Hi-color images can exhibit worse quantization
artifacts than a well-mapped 8-bit image
David Luebke 7 04/20/23
Recap: Matrices
● By convention, matrix element Mrc is located at row r and column c:
● By (OpenGL) convention, vectors are columns:
mnm2m1
2n2221
1n1211
MMM
MMM
MMM
M
3
2
v
v
v
v
1
David Luebke 8 04/20/23
Recap: Matrices
● Matrix-vector multiplication applies a linear transformation to a vector:
● Recall how to do matrix multiplication
z
y
x
v
v
v
MMM
MMM
MMM
vM
333231
232221
131211
David Luebke 9 04/20/23
Recap: Matrix Transformations
● A sequence or composition of linear transformations corresponds to the product of the corresponding matrices
■ Note: the matrices to the right affect vector first, e.g:
rotation about x, then translation along y, then rotation about z
■ Note: order of matrices matters!
● The identity matrix I has no effect in multiplication
● Some (not all) matrices have an inverse:
vvMM 1
' z y xp pR T R
x xPQ QP
x xI
David Luebke 10 04/20/23
Vectors and Matrices
● Vector algebra operations can be expressed in this matrix form■ Dot product:
■ Cross product:○ Note: use
right-handrule!
z
y
x
zyx
b
b
b
aaaba
0
0
0
z y x x
z x y y
y x z z
a a b c
a a b c
a a b c
a b c
a c 0
b c 0
David Luebke 11 04/20/23
The Rendering Pipeline: A Whirlwind Tour
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
David Luebke 12 04/20/23
The Display You Know
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
David Luebke 13 04/20/23
The Framebuffer You Know
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
David Luebke 14 04/20/23
The Rendering Pipeline
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
David Luebke 15 04/20/23
2-D Rendering: Rasterization(Coming Soon)
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
David Luebke 16 04/20/23
The Rendering Pipeline: 3-D
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & CameraModel & CameraParametersParameters Rendering PipelineRendering Pipeline FramebufferFramebuffer DisplayDisplay
David Luebke 17 04/20/23
The Rendering Pipeline: 3-D
ModelingTransforms
Scene graphObject geometry
LightingCalculations
ViewingTransform
Clipping
ProjectionTransform
Result:Result:
• All vertices of scene in shared 3-D “world” coordinate All vertices of scene in shared 3-D “world” coordinate systemsystem
• Vertices shaded according to lighting modelVertices shaded according to lighting model
• Scene vertices in 3-D “view” or “camera” coordinate Scene vertices in 3-D “view” or “camera” coordinate systemsystem
• Exactly those vertices & portions of polygons in view Exactly those vertices & portions of polygons in view frustumfrustum
• 2-D screen coordinates of clipped vertices2-D screen coordinates of clipped vertices
David Luebke 18 04/20/23
The Rendering Pipeline: 3-D
Scene graphObject geometry
LightingCalculations
Clipping
Result:Result:
• All vertices of scene in shared 3-D “world” coordinate All vertices of scene in shared 3-D “world” coordinate systemsystem
• Vertices shaded according to lighting modelVertices shaded according to lighting model
• Scene vertices in 3-D “view” or “camera” coordinate Scene vertices in 3-D “view” or “camera” coordinate systemsystem
• Exactly those vertices & portions of polygons in view Exactly those vertices & portions of polygons in view frustumfrustum
• 2-D screen coordinates of clipped vertices2-D screen coordinates of clipped vertices
ModelingTransforms
ViewingTransform
ProjectionTransform
David Luebke 19 04/20/23
Rendering: Transformations
● So far, discussion has been in screen space● But model is stored in model space
(a.k.a. object space or world space)● Three sets of geometric transformations:
■ Modeling transforms■ Viewing transforms■ Projection transforms
David Luebke 20 04/20/23
Rendering: Transformations
● Modeling transforms■ Size, place, scale, and rotate objects parts of the model
w.r.t. each other■ Object coordinates world coordinates
Z
X
Y
X
Z
Y
David Luebke 21 04/20/23
Rendering: Transformations
● Viewing transform■ Rotate & translate the world to lie directly in front of the
camera○ Typically place camera at origin○ Typically looking down -Z axis
■ World coordinates view coordinates
David Luebke 22 04/20/23
Rendering: Transformations
● Projection transform■ Apply perspective foreshortening
○ Distant = small: the pinhole camera model
■ View coordinates screen coordinates
David Luebke 23 04/20/23
Rendering: Transformations
● All these transformations involve shifting coordinate systems (i.e., basis sets)
● That’s what matrices do…● Represent coordinates as vectors, transforms as
matrices
● Multiply matrices = concatenate transforms!
Y
X
Y
X
cossin
sincos