school of computer science university of seoul. 1. classical and computer viewing 2. viewing with a...
TRANSCRIPT
![Page 1: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/1.jpg)
Computer Graphics(fall 2009)
School of Computer ScienceUniversity of Seoul
![Page 2: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/2.jpg)
Chap 5: Viewing
1. Classical and Computer Viewing2. Viewing with a Computer3. Positioning of the Camera4. Simple Projections5. Projections in OpenGL6. Hidden-Surface Removal7. Interactive Mesh Displays8. Parallel-Projection Matrices9. Perspective-Projection Matrices10. Projections and Shadows
![Page 3: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/3.jpg)
5.1 Classical and Computer Viewing
![Page 4: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/4.jpg)
Basic Elements
Object Projector Projection Plane COP (Center of Projection) or DOP (Direc-
tion of Projection) Principal faces/directions
![Page 5: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/5.jpg)
Classical Viewing
1. Orthographic projections2. Axonometric projections
Isometric, dimetric, trimetric
3. Oblique projections4. Perspective projections
One-, two-, three-point perspectives
![Page 6: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/6.jpg)
1. Orthographic Projections
Projectors perpendicular to the projection plane
Multiview orthographic projection
(image courtesy of http://img19.imageshack.us/i/importedpsk.jpg)
![Page 7: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/7.jpg)
2. Axonometric Projections
Projectors orthogonal to the projection plane
Projection plane can have any orientation with respect to the object
Isometric, dimetric, trimetric How many principal faces is the projection
plane is placed symmetrically with respect to
![Page 8: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/8.jpg)
3. Oblique Projections
Most general parallel views Projector can have an arbitrary angle with
the projection plane
![Page 9: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/9.jpg)
4. Perspective Viewing
To achieve real-looking images One-, two-, three-point perspectives
Number of vanishing points How many of three principal directions in the
object are parallel to the projection plane?
![Page 10: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/10.jpg)
5.2 Viewing with a Camera
![Page 11: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/11.jpg)
All the classical viewing can be implemented HOW??? (§5.9 & §5.10)
Default camera Orthographic Projection plane: “z=0” At the origin pointing to –z-direction Up direction: +y-direction Viewing volume: cube with side 2 objects outside of this box cannot be rendered! (“clipping”)
Objects behind the camera can be rendered! (only for orthog-onal projections)
OpenGL Viewing
![Page 12: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/12.jpg)
5.3 Positioning of the Camera
![Page 13: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/13.jpg)
Positioning the Camera
No separate “viewing” transformation con-catenated into model-view matrices
Object coords.world coords.eye coords. What matters is the relative position of ob-
jects and the camera At any given time, the state of the model-
view matrix encapsulates the relationship between the camera frame and the object frame
![Page 14: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/14.jpg)
Positioning the Camera (cont’d)
Separate matrices For model & viewing
Model-view matrix (OpenGL)
glMatrixMode(GL_MODEL);glMultMatrix(Mo);render_object();
glMatrixMode(GL_VIEW);glMultMatrix(Mc);
glMatrixMode(GL_MODELVIEW);glMultMatrix(inv(Mc));glMultMatrix(Mo);render_object();
![Page 15: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/15.jpg)
Viewing-Coordinate System Defined by
Position (VRP: view-reference point, p) Viewing direction (VPN: view-plane normal , n) Up direction (VUP: view-up vector, vup)
Projected on the view plane (v) 3rd orthogonal direction (u) obtained by cross product
View-orientation matrixderivation? (advanced)
x, y, z axes u, v, n gluLookAt
Needs to be called before transforming objects Error in the book (p.251)
![Page 16: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/16.jpg)
Other Viewing APIs
Roll, pitch, yaw To specify the orientation Ex) flight simulation
Elevation, azimuth, twist Direction from the viewer Ex) star in the sky
![Page 17: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/17.jpg)
5.4 Simple Projections
![Page 18: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/18.jpg)
Perspective Projections
All projectors pass through the origin (x,y,z)(xp,yp,zp) Nonlinear, not affine, irreversible Perspective division required “Extended” homogeneous coordinates re-
quired 3D points = 4D lines (through the origin): (x,y,z,1)(x,y,z,z/d)=(xp,yp,zp,1)
How does the matrix look like?
![Page 19: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/19.jpg)
Orthogonal Projections
No division required (x,y,z)(x,y,0)=(xp,yp,zp) How does the matrix look like?
![Page 20: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/20.jpg)
5.5 Projections in OpenGL
![Page 21: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/21.jpg)
Projections in OpenGL
Parameters in eye coordinates Near/far clipping planes
![Page 22: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/22.jpg)
Perspective Viewing in OpenGL
glFrustum Need not be symmetric
gluPerspective Symmetric Defined using fov (field of view) error in the figure 5.28 of the textbook
Calls glFrustum internallynear & far parameters must be positive
(image courtesy of the redbook)
![Page 23: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/23.jpg)
Parallel Viewing in OpenGL
glOrthogluOrtho2D No sign restrictions on near & far param-
eters
![Page 24: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/24.jpg)
5.6 Hidden-Surface Removal
![Page 25: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/25.jpg)
Hidden-Surface Removal How to determine which object is closer than others? What happens without hidden-surface removal? Two classes
Object space algorithm BSP (Binary Space Partitioning) tree restriction?
Image space algorithm Z-buffer algorithm used in (most) interactive graphics system including
OpenGL Complexity proportional to the resolution Small overhead More in Chap 7
Culling Back faces of closed objects not rendered Number of primitives reduced early
![Page 26: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/26.jpg)
5.7 Interactive Mesh Displays
![Page 27: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/27.jpg)
5.8 Parallel-Projection Matri-ces
![Page 28: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/28.jpg)
Projection Normalization
All projections are converted into orthogo-nal projections by first distorting the objects such that the orthogonal projection of the distorted objects is the same as the desired projection of the original objects.
Simplifies clipping & hidden-surface removal(Chap 7)
![Page 29: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/29.jpg)
Orthogonal-Projection Matrices
1. Normalization(by OpenGL projection matrix) Converts the specified viewing volume to canonical
view volume ([-1,1]x[-1,1]x[-1,1] cube) Translation followed by scaling
2. Orthographic projection (x,y,z) (x,y,0)
1000
200
02
0
002
nearfar
nearfar
nearfar
bottomtop
bottomtop
bottomtop
rightleft
rightleft
rightleft
P
![Page 30: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/30.jpg)
Oblique Projections
We can either Define the 4x4 matrix directly or Implement by shear followed by orthographic
projection (In practice, normalization is re-quired in between)
1000
0000
0cot10
0cot01
P
1000
0100
0cot10
0cot01
1000
0000
0010
0001
,
HMP ortho
![Page 31: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/31.jpg)
5.9 Perspective-Projection Matrices
![Page 32: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/32.jpg)
Simple Perspective Projection
Frustum defined by x=±z, y=±z, z_max, z_min
For the perspective-normalization matrix N,what converts the planes as follows? x=±z x’’=±1 y=±z y’’=±1 z=z_max z’’=1 z=z_minz’’=-1
0100
00
0010
0001
N
minmax
minmax
zz
zz
minmax
minmax2
zz
zz
![Page 33: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/33.jpg)
Perspective Projection
Depth ordering preserved by perspective-projection matrix hidden-surface removal works in the normalized volume
General perspective projection1. Apply shear to convert the asymmetric frus-
tum to a symmetric one2. Scale to the “simple” frustum
![Page 34: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/34.jpg)
5.10 Projections and Shad-ows
![Page 35: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/35.jpg)
Shadows
A point is in shadow if it is not illuminated by any light source, or equivalently if a viewer at that point cannot see any light source.
Shadow polygon
![Page 36: School of Computer Science University of Seoul. 1. Classical and Computer Viewing 2. Viewing with a Computer 3. Positioning of the Camera 4. Simple Projections](https://reader030.vdocuments.site/reader030/viewer/2022032707/56649e555503460f94b4d03d/html5/thumbnails/36.jpg)
Rendering Shadow
Render twice: object polygon and shadow polygon
How to find the shadow polygon? perspec-tive projection (with light source as the camera)
Works only for shadowson flat surface
More on Chap 12