transformations in the pipeline - cs | computer...
TRANSCRIPT
![Page 1: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/1.jpg)
Transformations in the pipeline
Modeling transformation
Viewing transformation
Projection transformation
Perspective division
Viewport transformation
OCS WCS VCS CCS
NDCSDCS
(e.g. pixels)
gluLookAt()glTranslatef()…
ModelView Matrix
![Page 2: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/2.jpg)
Background (reminder)Line (in 2D)• Explicit• Implicit
• Parametric
![Page 3: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/3.jpg)
Background (reminder)Plane equationsImplicit
Parametric
Explicit
![Page 4: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/4.jpg)
Reminder: Homogeneous Coordinates
![Page 5: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/5.jpg)
Projection transformations
![Page 6: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/6.jpg)
Introduction to Projection Transformations
[Hill: 371-378, 398-404. Foley & van Dam: p. 229-242 ]Mapping: f : Rn Rm Projection: n > mPlanar Projection: Projection on
a plane. R3R2 or
R4R3 homogenous coordinates.
![Page 7: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/7.jpg)
Basic projectionsParallel
Perspective
![Page 8: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/8.jpg)
Taxonomy
![Page 9: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/9.jpg)
Examples
![Page 10: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/10.jpg)
A basic orthographic projectionx’ = xy’ = yz’ = N
Matrix Form
Z
Y
I
N
![Page 11: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/11.jpg)
A basic perspective projection
Similar trianglesx’/d = x/(-z) -> x’ = x d/(-z)y’/d = y/(-z) => y’ = y d/(-z)z’ = -d
![Page 12: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/12.jpg)
In matrix form
Matrix form of x’ = x d/(-z)y’ = y d/(-z)z’ = -d
Moving from 4D to 3D
![Page 13: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/13.jpg)
Projections in OpenGL
![Page 14: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/14.jpg)
Camera coordinate systemImage plane = near planeCamera at (0,0,0)Looking at –zImage plane at z = -N
![Page 15: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/15.jpg)
Perspective projection of a point
In eye coordinates P =[Px,Py,Pz,1]T
x/Px = N/(-Pz) => x = NPx/(-Pz)y/Px = N/(-Pz) => y = NPy/(-Pz)
![Page 16: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/16.jpg)
Observations• Perspective foreshortening• Denominator becomes
undefined for z = 0• If P is behind the eye Pz
changes sign• Near plane just scales the
picture• Straight line -> straight line
![Page 17: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/17.jpg)
Perspective projection of a line
Perspective Division, drop fourth coordinate
![Page 18: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/18.jpg)
Is it a line?
Cont’d next slide
![Page 19: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/19.jpg)
Is it a line? (cont’d)
![Page 20: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/20.jpg)
So is there a difference?
![Page 21: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/21.jpg)
So is there a difference?The speed of the lines if cz is not 0
![Page 22: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/22.jpg)
Inbetween pointsHow do points on lines transform?
Viewing system: R(g) = (1-g)A + gB
Projected (4D) : r = MR
Projected cartesian: R’(f) = (1-f)A’ + fB’
What is the relationship between g and f?
A
BR
MPerspective divisiona
b
r
A’
B’R’
![Page 23: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/23.jpg)
First stepViewing to homogeneous space (4D)
A
BR
Ma
b
r
![Page 24: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/24.jpg)
Second stepPerspective division
A
BR
Ma
b
r
Perspective division
A’
B’R’
![Page 25: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/25.jpg)
Putting all together
A
BR
Ma
b
r
Perspective division
A’
B’R’
![Page 26: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/26.jpg)
Relation between the fractions
R can be texture coordinates, color etc.THAT MEANS: For a given f in screen space and A,B in viewing space we can find the corresponding R (or g) in viewing space using the above formula.
“A” can be texture coordinates, position, color, normal etc.
g
![Page 27: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/27.jpg)
Effect of perspective projection on lines [Hill 375]
Equations
What happens to parallel lines?
![Page 28: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/28.jpg)
Effect of perspective projection on lines [Hill 375]
Parallel lines
If parallel to view plane then:
![Page 29: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/29.jpg)
Effect of perspective projection on lines [Hill 375]
Parallel lines
If not parallel to view plane then:
Vanishing point!
![Page 30: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/30.jpg)
SummaryForshorteningNon-linearLines go to linesParallel lines either intersect or remain parallelInbetweeness
![Page 31: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/31.jpg)
Projections in the Graphics Pipeline
View volumes• Our pipeline supports
two projections:– Orthographic– Perspective
• This stage also defines the view window
• What is visible with each projection?– a cube– or a pyramid
Open GL Canonical view volume (left handed!)
![Page 32: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/32.jpg)
View volumes
Open GL Canonical view volume (left handed!)
![Page 33: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/33.jpg)
Transformation vs ProjectionWe want to keep zWhy?• Pseudodepth
I
-z0 z1 < z2
P1P2
![Page 34: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/34.jpg)
Derivation of the orthographic transformation
Map each axis separately: • Scaling and translation
Let’s look at y:• y’ = ay+b such that
bottom -1top 1
![Page 35: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/35.jpg)
Derivation of the orthographic transformation
Scaling and Translation
![Page 36: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/36.jpg)
All three coordinatesScaling and Translation
![Page 37: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/37.jpg)
Matrix form
![Page 38: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/38.jpg)
Perspective transformationWarps the view volume and the objects in it.• Eye becomes a point
at infiinity, and the projection rays become parallel lines(orthographic projection)
• We also want to keep z
![Page 39: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/39.jpg)
Derivation of the perspective transformation
It is basically a mapping of planesNormalized view volume is a left handed system!
![Page 40: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/40.jpg)
Deriving the MatrixCompute F and B:
![Page 41: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/41.jpg)
Forming the second equationFrom bottom plane
![Page 42: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/42.jpg)
Solving the 2x2 systemCompute F and B:
![Page 43: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/43.jpg)
Similarly for xCompute E and A:
![Page 44: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/44.jpg)
Similarly zCompute C and D
![Page 45: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/45.jpg)
Putting everything together
![Page 46: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/46.jpg)
Putting everything together
Same as orthographic except the scaling and the position of the x,y translation parameters
![Page 47: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/47.jpg)
Orthographic projection in OpenGL
glMatrixMode(GL_PROJECTION) ;glLoadIdentity() ;Followed by one of:glOrtho(left,right,bottom,top,near,far) ; near plane at z = -near far plane at z = -far gluOrtho2D(left,right,bottom,top) ; assumes near = 0 far = 1
![Page 48: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/48.jpg)
Perspective projection in OpenGL
glMatrixMode(GL_PROJECTION) ;glLoadIdentity() ;Followed by one of:glFrustrum(left,right,bottom,top,near,far) ; near plane at z = -near far plane at z = -far gluPerspective(fovy, aspect,bottom,top) ; fov measured in degrees and center at 0
Put the code in init or reshape callback.
![Page 49: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/49.jpg)
Matrix pre-multiplies Modelview matrix
M = Mproj*CM
![Page 50: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/50.jpg)
ImportantProjection parameters are given in CAMERA Coordinate system (Viewing).
So if camera is at z = 50 and you give near = 10 where is the near plane with respect to the world?
![Page 51: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/51.jpg)
ImportantProjection parameters are given in CAMERA Coordinate system (Viewing).
So if the camera is at z = 50 and you give near = 10 where is the near plane with respect to the world?Transformed by inverse(Mvcs)
![Page 52: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/52.jpg)
Nonlinearity of perspective transformation
Tracks:Left: x= -1, y = -1Right: x = 1, y = -1Z = -inf, inf
View volume:Left = -1, right = 1Bot = -1, top = 1Near = 1, far = 4
![Page 53: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/53.jpg)
Comparison of cs’sVCS CCS NDCSX X’ = EX + AZ X’’=X’/W’Y Y’ = FY + BZ Y’’ = Y’/W’Z Z’ = CZ + D Z” = Z’/W’Point Point’ Point’’1 X’= X = 1 X’’ = -1/Z -1 Y’ = Y = -1 Y’’ = 1 /ZZ Z’ = -5Z/3 – 8/3 Z’’ = 5/3 +8/(3Z) W’ = -Z
![Page 54: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/54.jpg)
Z in NDCS vs –Z in VCS
Z’’ = 5/3 +8/(3Z)
near far
![Page 55: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/55.jpg)
X’’ = -1/Z Z = -1/X’’
Other comparisons
![Page 56: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/56.jpg)
Other comparisons
X’’ = -1/Z
Z’’ = 5/3 +8/(3Z)
Z’’ = 5/3-(8/3)X’’
![Page 57: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/57.jpg)
3D ClippingKeep what is visible
![Page 58: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/58.jpg)
Background (reminder)Plane equationsImplicit
Parametric
Explicit
![Page 59: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/59.jpg)
Intersection of line and plane
![Page 60: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/60.jpg)
Orthographic view volumePlanesNormals pointing inside left: x - left = 0 right: -x + right = 0 bottom: y - bottom = 0 top: -y + top = 0 front: -z - near = 0 back: z + far = 0
![Page 61: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/61.jpg)
Perspective View volume Planes Normals pointing inside left: x + left*z/near = 0 right: -x - right*z/near = 0 top: -y - top*z/near = 0 bottom: y + bottom*z/near = 0 front: -z - near = 0 back: z + far = 0
![Page 62: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/62.jpg)
Clipping in NDCSNormalized view volume• Constant planes• Lines in VCS lines NDCS
Problem• Z coordinate loses its sign
![Page 63: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/63.jpg)
Clipping in CCSWe'll define the clipping region in CCS by first looking at
the clipping region in NDCS:-1 <= x/w <= 1This means that in CCS, we have:-w <= x <= w
Similarly for y,z
![Page 64: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/64.jpg)
ExampleThe perspective transformation createsW = -z
Typo: they should have different z
![Page 65: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/65.jpg)
Viewport transformation
Modeling transformation
Viewing transformation
Projection transformation
Perspective division
Viewport transformation
OCS WCS VCS CCS
NDCSDCS
M-1cam
![Page 66: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/66.jpg)
Viewport
![Page 67: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/67.jpg)
Viewport matrix
Scales the x,y to the dimensions of the viewportScales z to be in [0,1]
Matrix form left as an exercise.
![Page 68: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/68.jpg)
Why viewports?Undo the distortion of the projection transformation
![Page 69: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/69.jpg)
Stereo views
![Page 70: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/70.jpg)
Viewport in OpenGLglViewport(GLint x, GLint y, GLsizei width, GLsizei height) ;
x,y: lower left corner of viewport rectangle in pixelswidth, height: width and height of viewport.
Put the code in reshape callback.
![Page 71: Transformations in the pipeline - CS | Computer Scienceweb.cs.ucla.edu/.../cs174/cs-174-lecture-projections.pdf · · 2010-03-30Transformations in the pipeline Modeling transformation](https://reader031.vdocuments.mx/reader031/viewer/2022022010/5b06f9257f8b9ae9628dc6c6/html5/thumbnails/71.jpg)
Transformations in the pipeline
Modeling transformation
Viewing transformation
Projection transformation
Perspective division
Viewport transformation
OCS WCS VCS CCS
NDCSDCS
(e.g. pixels)
gluLookAt()
glOrtho()glFrustrum()gluPerspective
glViewport()
glTranslatef()…
ModelView Matrix
A digital calibration algorithm with variable amplitude dithering for domain-extended pipeline ad cs
ECE/CS 552: Pipeline Hazards © Prof. Mikko Lipasti Lecture notes based in part on slides created by…