![Page 1: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/1.jpg)
Computer GraphicsComputer Graphics
Zhen JiangZhen Jiang
West Chester UniversityWest Chester University
![Page 2: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/2.jpg)
TopicsTopics
• Projection
• Visibility
![Page 3: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/3.jpg)
ProjectionProjection
Film Plane
Pinhole
Multiple raysof projection
![Page 4: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/4.jpg)
ProjectionProjection
Film Plane
Pinhole
One rayof projection
![Page 5: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/5.jpg)
ProjectionProjection
• Field of View• Field of View
Film Plane
Field of ViewPinhole
FocalLength
![Page 6: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/6.jpg)
ProjectionProjection
Film Plane
Field of ViewPinhole
FocalLength
![Page 7: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/7.jpg)
ProjectionProjection• Varying distance to film plane
• What does this do?
• Varying distance to film plane
• What does this do?
Film Plane
d1 Field of ViewPinhole
d2
![Page 8: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/8.jpg)
ProjectionProjection• We use
– Center of Projection (COP)– Projection Plane
• We use – Center of Projection (COP)– Projection Plane
COP
ProjectionPlane
![Page 9: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/9.jpg)
ProjectionProjection• Perspective vs. Orthographic Views• Perspective vs. Orthographic Views
Perspective
When COP at infinity, Orthographic View
![Page 10: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/10.jpg)
ProjectionProjection• One-point Perpective
– One Vanishing Point
• Two-point Perspective– Two Vanishing Points
• One-point Perpective– One Vanishing Point
• Two-point Perspective– Two Vanishing Points
http://www.sanford-artedventures.com/create/tech_2pt_perspective.html
![Page 11: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/11.jpg)
ProjectionProjection
• Our camera must model perspective
• Our camera must model perspective
![Page 12: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/12.jpg)
ProjectionProjection
How tall shouldthis bunny be?
COP
ProjectionPlane
![Page 13: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/13.jpg)
ProjectionProjection
d
P (x, y, z)X
Z
Viewplane
(0,0,0) x’ = ?
![Page 14: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/14.jpg)
ProjectionProjection• Desired result for a point [x, y, z, 1]T projected
onto the view plane:
• What could a matrix look like to do this?
• Desired result for a point [x, y, z, 1]T projected onto the view plane:
• What could a matrix look like to do this?
dzdz
y
z
ydy
dz
x
z
xdx
z
y
d
y
z
x
d
x
,','
',
'
![Page 15: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/15.jpg)
ProjectionProjection
0100
0100
0010
0001
d
M eperspectiv
![Page 16: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/16.jpg)
ProjectionProjection• Example:
• Or, in 3-D coordinates:
• Example:
• Or, in 3-D coordinates:
10100
0100
0010
0001
z
y
x
ddz
z
y
x
d
dz
y
dz
x,,
![Page 17: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/17.jpg)
ProjectionProjection
• Orthographic Camera ProjectionOrthographic Camera Projection
11000
0000
0010
0001
1
z
y
x
z
y
x
p
p
p
![Page 18: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/18.jpg)
ProjectionProjection
• glFrustum – for perspective projections– xmin– xmax– ymin– ymax– near – far
• glFrustum – for perspective projections– xmin– xmax– ymin– ymax– near – far
– Camera looks along –z– min/max need not be
symmetric about any axis– near and far planes are parallel
to plane z=0
– Camera looks along –z– min/max need not be
symmetric about any axis– near and far planes are parallel
to plane z=0
![Page 19: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/19.jpg)
ProjectionProjection
• gluPerspective – for perspective projections– fovy– aspect– near– far
• gluPerspective – for perspective projections– fovy– aspect– near– far
– fovy is the angle between top and bottom of viewing volume
– aspect is ratio of width over height
– This volume is symmetrical– View plane is parallel to
camera
– fovy is the angle between top and bottom of viewing volume
– aspect is ratio of width over height
– This volume is symmetrical– View plane is parallel to
camera
![Page 20: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/20.jpg)
ProjectionProjection
• glOrtho – for orthographic projections– left– right– bottom– top– near– far
• glOrtho – for orthographic projections– left– right– bottom– top– near– far
– (left, bottom) and (right, top) define dimensions of projection plane
– near and far used to clip
– (left, bottom) and (right, top) define dimensions of projection plane
– near and far used to clip
![Page 21: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/21.jpg)
VisibilityVisibility• Why might a polygon be invisible?
– Polygon outside the field of view– Polygon is backfacing– Polygon is occluded by object(s) nearer the
viewpoint
• For efficiency reasons, we want to avoid spending work on polygons outside field of view or backfacing
• For efficiency and correctness reasons, we need to know when polygons are occluded
• Why might a polygon be invisible?– Polygon outside the field of view– Polygon is backfacing– Polygon is occluded by object(s) nearer the
viewpoint
• For efficiency reasons, we want to avoid spending work on polygons outside field of view or backfacing
• For efficiency and correctness reasons, we need to know when polygons are occluded
![Page 22: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/22.jpg)
VisibilityVisibility
• Remove polygons entirely outside frustum– Note that this includes polygons “behind” eye
(actually behind near plane)
• Pass through polygons entirely inside frustum
• Modify remaining polygonsto include only portions intersecting view frustum
• Remove polygons entirely outside frustum– Note that this includes polygons “behind” eye
(actually behind near plane)
• Pass through polygons entirely inside frustum
• Modify remaining polygonsto include only portions intersecting view frustum
![Page 23: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/23.jpg)
VisibilityVisibility• Most objects in scene are typically
“solid”• More rigorously: compact,
orientable manifolds– Must not cut through itself– Must have two distinct sides
• A sphere is orientable since it has two sides, 'inside' and 'outside'.
• A Mobius strip or a Klein bottle is not orientable
– Cannot “walk” from one side to the other
• A sphere is a closed manifold whereas a plane is not
• Most objects in scene are typically “solid”
• More rigorously: compact, orientable manifolds– Must not cut through itself– Must have two distinct sides
• A sphere is orientable since it has two sides, 'inside' and 'outside'.
• A Mobius strip or a Klein bottle is not orientable
– Cannot “walk” from one side to the other
• A sphere is a closed manifold whereas a plane is not
![Page 24: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/24.jpg)
VisibilityVisibility• For most interesting scenes, some polygons will
overlap:
• To show the correct image, we need to determine which polygons occlude which
• For most interesting scenes, some polygons will overlap:
• To show the correct image, we need to determine which polygons occlude which
![Page 25: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/25.jpg)
VisibilityVisibility
• Simple approach: display the polygons from back to front, “painting over” previous polygons:
– Draw blue, then green, then orange
• Will this work in the general case?
• Simple approach: display the polygons from back to front, “painting over” previous polygons:
– Draw blue, then green, then orange
• Will this work in the general case?
![Page 26: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/26.jpg)
VisibilityVisibility• Intersecting polygons present a problem
• Even non-intersecting polygons can form a cycle with no valid visibility order:
• Intersecting polygons present a problem
• Even non-intersecting polygons can form a cycle with no valid visibility order:
![Page 27: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/27.jpg)
VisibilityVisibility• Early visibility algorithms computed the set of
visible polygon fragments directly, then showed the fragments to a display:
• Early visibility algorithms computed the set of visible polygon fragments directly, then showed the fragments to a display:
![Page 28: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/28.jpg)
VisibilityVisibility• So, for about a decade (late 60s to
late 70s) there was intense interest in finding efficient algorithms for hidden surface removal
• Examples: – Binary Space-Partition (BSP) Trees
http://symbolcraft.com/graphics/bsp– The Z-buffer Algorithm
• So, for about a decade (late 60s to late 70s) there was intense interest in finding efficient algorithms for hidden surface removal
• Examples: – Binary Space-Partition (BSP) Trees
http://symbolcraft.com/graphics/bsp– The Z-buffer Algorithm
![Page 29: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/29.jpg)
VisibilityVisibility
• We know how to rasterize polygons into an image discretized into pixels:
• We know how to rasterize polygons into an image discretized into pixels:
![Page 30: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/30.jpg)
VisibilityVisibility
• What happens if multiple primitives occupy the same pixel on the screen? Which is allowed to paint the pixel?
• What happens if multiple primitives occupy the same pixel on the screen? Which is allowed to paint the pixel?
![Page 31: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/31.jpg)
VisibilityVisibility
• Simple!!!
• Easy to implement in hardware
• Polygons can be processed in arbitrary order
• Easily handles polygon interpenetration
• Simple!!!
• Easy to implement in hardware
• Polygons can be processed in arbitrary order
• Easily handles polygon interpenetration
![Page 32: Computer Graphics Zhen Jiang West Chester University](https://reader034.vdocument.in/reader034/viewer/2022042717/56649f425503460f94c621e8/html5/thumbnails/32.jpg)
VisibilityVisibility
• Lots of memory (e.g. 1280x1024x32 bits)– With 16 bits cannot discern millimeter differences in
objects at 1 km distance
• Read-Modify-Write in inner loop requires fast memory• Hard to do analysisi
– We don’t know which polygon to map pixel back to
• Shared edges are handled inconsistently– Ordering dependent
• Hard to simulate translucent polygons– We throw away color of polygons behind closest one
• Lots of memory (e.g. 1280x1024x32 bits)– With 16 bits cannot discern millimeter differences in
objects at 1 km distance
• Read-Modify-Write in inner loop requires fast memory• Hard to do analysisi
– We don’t know which polygon to map pixel back to
• Shared edges are handled inconsistently– Ordering dependent
• Hard to simulate translucent polygons– We throw away color of polygons behind closest one