6.837 Lecture Notes - MIT Computer Science and Artificial

Download Report

Transcript 6.837 Lecture Notes - MIT Computer Science and Artificial

The Rendering Pipeline
Local Illumination Models
MIT EECS 6.837
Lecture 4, September 17th 2002
MIT EECS 6.837, Durand and Teller
1
Administrative Notes
ROOM CHANGE:
th
19 ,
Starting this Thursday Sept.
6.837 will meet in room 2-190
(We will post signage to remind you.)
MIT EECS 6.837, Durand and Teller
2
Administrative Notes
• Assignment 1: Due this Friday (9/20) at 5pm
– Questions about the assignment?
– Use turnin as directed on course page
• Final projects will be due December 4th
– Presentations scheduled for December 4th –10th
• Staff Office Hours
–
–
–
–
Durand: R 4-5 in 4-035 cluster; R 5-6 in NE43-254
Teller: W 3-4 in NE43-252; R 4-5 in 4-035 cluster
Ngan: R 2-6pm (location TBD)
Yu: TBD
MIT EECS 6.837, Durand and Teller
3
Inventor Resources for Assignment 1
• Example Files & Documentation
– Athena IRIX: /usr/share/data/models/
– Athena Linux: /mit/inventor/distrib/share/data/models
– athena% man SoCube, man SoTranslation, etc.
(must have /usr/share/catman or /mit/inventor/man in $MANPATH)
• On reserve at LCS reading room:
– Open Inventor C++ Reference Manual (The “green
book”)
– Inventor Mentor (The “orange book”)
• On Web:
– Various helpful links from course page
– Many illustrative Inventor files exist on-line
MIT EECS 6.837, Durand and Teller
4
Lecture Plan
• Last week:
– Object-space to world-space transformations
– Object modeling using Inventor language, tools
• Today:
– Overview of classical “rendering pipeline”
– Local illumination models (simplified)
• Thursday:
– Eye-space & perspective transformations
– Segment (2D) and polygon (frustum) clipping
MIT EECS 6.837, Durand and Teller
5
Rendering abstraction I
?
Input
Renderin
g
Pipeline
MIT EECS 6.837, Durand and Teller
Output
6
Rendering inputs
•
•
•
•
Scene description
Lighting description & lighting model
Synthetic camera parameters
Raster viewport parameters
MIT EECS 6.837, Durand and Teller
7
Scene description
• Object geometry, placement, material
properties
MIT EECS 6.837, Durand and Teller
8
Lighting description & model
• Light source locations and characteristics
MIT EECS 6.837, Durand and Teller
9
Synthetic camera parameters
• Synthetic camera parameters
– Eye position and view frustum
MIT EECS 6.837, Durand and Teller
10
Raster viewport parameters
• Resolution (width x height) of pixel grid
onto which image plane is to be mapped
MIT EECS 6.837, Durand and Teller
11
Rendering output
• Framebuffer assignment
– Per-pixel intensity values suitable for display
• For example, an RGB value for each framebuffer
pixel
– Optionally, a depth (or z-value) at each pixel
MIT EECS 6.837, Durand and Teller
12
Rendering abstraction I
Scene description
Lighting description
Synthetic camera parameters
Raster viewport parameters
Input
Renderin
g
Pipeline
MIT EECS 6.837, Durand and Teller
Output
13
Rendering Pipeline (Abstracted)
MIT EECS 6.837, Durand and Teller
14
Lighting
MIT EECS 6.837, Durand and Teller
15
Transforming normal vectors
• Suppose M takes object to world
coordinates:
p’ = M p
• How are normal vectors transformed?
n’ = ?
M
?
MIT EECS 6.837, Durand and Teller
16
Transforming normal vectors
• First attempt: just use transform M (e.g., shear):
 x'   1
  
 y '  0
 z '  = 0
  
 1  0
1
1
0
0
0 0  x 
 
0 0  y 
1 0  z 
 
0 1  1 
Normals (0,1) and (1,0)
transform to (1,1) and (1,0)!
MIT EECS 6.837, Durand and Teller
17
Transforming normal vectors
• We know that for p on H, n normal to H
nT p = 0
• And for any non-singular transform M that
nT (M-1 M) p = 0
• Which can be rewritten as
( nT M-1 ) ( M p ) = 0
• Thus the transpose of the transformed normal is
( nT M-1 )
• And the transformed normal itself is the transpose
( nT M-1 )T = M-T n
MIT EECS 6.837, Durand and Teller
18
Transforming normal vectors
• Thus under action of M, points transform as
p’ = M p
• And normal vectors transform as
n’ = M-T n
M
p’ = M p
n’ = M-T n
MIT EECS 6.837, Durand and Teller
19
Correct transformation
• Using same shear transform M as before:
Normals (0,1) and (1,0)
transform to (0,1) and (1,-1)
… are we done?
M-1
1

0
=
0

0
-1
1
0
0
0 0

0 0
1 0

0 1
M-T
1

-1
=
0

0
MIT EECS 6.837, Durand and Teller
0
1
0
0
0 0

0 0
1 0

0 1
20
Lighting: Putting it all together
• Issue scene geometry to graphics pipeline,
transforming geometry, normals correctly
• Apply lighting equation at polygon vertices
by evaluating Phong illumination model there
• Interpolate vertex colors across polygon
interiors to produce color at each pixel
MIT EECS 6.837, Durand and Teller
21
Faceted and smooth shading
MIT EECS 6.837, Durand and Teller
22
Faceted and smooth shading
• Per-face normals:
# .../ivexamples/facetedpear.iv
Coordinate3 { ... }
NormalBinding { value PER_FACE }
IndexedFaceSet { coordIndex [ 0, 1, 2, -1,…
• Per-vertex normals
# .../ivexamples/smoothpear.iv
Coordinate3 { ... } # x y z per vertex
Normal { ... } # dx dy dz per vertex
NormalBinding { value PER_VERTEX }
IndexedFaceSet { coordIndex [ 0, 1, 2, -1,…
MIT EECS 6.837, Durand and Teller
23
When to Apply Lighting Equation?
• Apply in object space
– Adv: easy to compute normals
– Disadv: Must transform lights to object space
• So: apply in world coordinates
– Adv: lights usually specified in world space
• This is most common practice, but:
– 1) What if some vertices lie outside frustum?
– 2) Must transform normals to world space
MIT EECS 6.837, Durand and Teller
24
Next time, we’ll:
• Continue our trip down the graphics pipeline
• Study further relevant transformations
• See efficient segment and polygon clipping
MIT EECS 6.837, Durand and Teller
25