Framebuffer

advertisement
The Rendering Pipeline
CS 445/645
Introduction to Computer Graphics
David Luebke, Spring 2003
Admin
● Call roll
● Assignment 0: questions?
David Luebke
2
3/16/2016
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
3
3/16/2016
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
4
3/16/2016
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
5
3/16/2016
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
6
3/16/2016
Recap: Matrices
● By convention, matrix element Mrc is located at row r
and column c:
 M11 M12
 M21 M22
M
 


Mm1 Mm2
 M1n 
 M2n 

 

 Mmn 
● By (OpenGL) convention,
vectors are columns:
David Luebke
7
 v1 


v   v 2
 v 3 
3/16/2016
Recap: Matrices
● Matrix-vector multiplication applies a linear
transformation to a vector:
 M11 M12 M13  vx 
M  v  M 21 M 22 M 23  vy 
M31 M32 M33  vz 
● Recall how to do matrix multiplication
David Luebke
8
3/16/2016
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
p '  R z Ty R x p
■ Note: order of matrices matters!
PQx  QPx
● The identity matrix I has no effect in multiplication
Ix  x
● Some (not all) matrices have an inverse:
M 1 Mv   v
David Luebke
9
3/16/2016
Vectors and Matrices
● Vector algebra operations can be expressed in this
matrix form
■ Dot product:
■ Cross product:
○ Note: use
right-hand
rule!
a  b  ax ay
bx 
az by   
bz 
 0 az ay  bx   cx 
a  b   az
0 ax  by   cy   c
 ay ax
0  bz   cz 
ac  0
bc  0
David Luebke
10
3/16/2016
The Rendering Pipeline:
A Whirlwind Tour
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
11
Framebuffer
Display
3/16/2016
The Display You Know
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
12
Framebuffer
Display
3/16/2016
The Framebuffer You Know
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
13
Framebuffer
Display
3/16/2016
The Rendering Pipeline
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
14
Framebuffer
Display
3/16/2016
2-D Rendering: Rasterization
(Coming Soon)
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
15
Framebuffer
Display
3/16/2016
The Rendering Pipeline: 3-D
Transform
Illuminate
Transform
Clip
Project
Rasterize
Model & Camera
Parameters
David Luebke
Rendering Pipeline
16
Framebuffer
Display
3/16/2016
The Rendering Pipeline: 3-D
Scene graph
Object geometry
Result:
Modeling
Transforms
• All vertices of scene in shared 3-D “world” coordinate system
Lighting
Calculations
• Vertices shaded according to lighting model
Viewing
Transform
• Scene vertices in 3-D “view” or “camera” coordinate system
Clipping
Projection
Transform
David Luebke
• Exactly those vertices & portions of polygons in view frustum
• 2-D screen coordinates of clipped vertices
17
3/16/2016
The Rendering Pipeline: 3-D
Scene graph
Object geometry
Result:
Modeling
Transforms
• All vertices of scene in shared 3-D “world” coordinate system
Lighting
Calculations
• Vertices shaded according to lighting model
Viewing
Transform
• Scene vertices in 3-D “view” or “camera” coordinate system
Clipping
Projection
Transform
David Luebke
• Exactly those vertices & portions of polygons in view frustum
• 2-D screen coordinates of clipped vertices
18
3/16/2016
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
19
3/16/2016
Rendering: Transformations
● Modeling transforms
■ Size, place, scale, and rotate objects parts of the model
w.r.t. each other
■ Object coordinates  world coordinates
Y
Y
Z
X
X
Z
David Luebke
20
3/16/2016
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
21
3/16/2016
Rendering: Transformations
● Projection transform
■ Apply perspective foreshortening
○ Distant = small: the pinhole camera model
■ View coordinates  screen coordinates
David Luebke
22
3/16/2016
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
X  cos q
    q
Y  sin
sin q  X 
 
q
cos  Y 
● Multiply matrices = concatenate transforms!
David Luebke
23
3/16/2016
Download