computer graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · computer...
TRANSCRIPT
![Page 1: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/1.jpg)
Computer Graphics
Bing-Yu ChenNational Taiwan University
![Page 2: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/2.jpg)
Visible-Surface Determination
Back-Face CullingThe Depth-Sort AlgorithmBinary Space-Partitioning TreesThe z-Buffer AlgorithmScan-Line AlgorithmVisible-Surface Ray Tracing(Ray Casting)Warnock’s Algorithm
![Page 3: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/3.jpg)
Visible-Surface Determination = Hidden Surface Removal
Determining what to render at each pixel.A point is visible if there exists a direct line-of-sight to it, unobstructed by another other objects (visible surface determination).Moreover, some objects may be invisible because there are behind the camera, outside of the field-of-view, too far away (clipping) or back faced (back-face culling).
![Page 4: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/4.jpg)
Hidden Surfaces: why care?
Occlusion: Closer (opaque) objects along same viewing ray obscure more distant ones.Reasons for removal
Efficiency: As with clipping, avoid wasting work on invisible objects.Correctness: The image will look wrong if we don’t model occlusion properly.
![Page 5: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/5.jpg)
Back-Face Culling = Front Facingx
z G
H
E
C
B
A
D
F
![Page 6: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/6.jpg)
Back-Face Culling = Front Facing
use cross-product to get the normal of the face (not the actual normal)use inner-product to check the facing
2 1 3 1( ) ( )N v v v v= − × −v1
v2
v3
N
V
![Page 7: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/7.jpg)
Clipping (View Frustum Culling)
eye
view frustum
occlusionbackface
view frustum
![Page 8: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/8.jpg)
List-Priority Algorithms
The Painter’s AlgorithmThe Depth-Sort AlgorithmBinary Space-Partitioning Trees
![Page 9: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/9.jpg)
The Painter’s Algorithm
Draw primitives from back to front need for depth comparisons.
![Page 10: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/10.jpg)
The Painter’s Algorithm
for the planes with constant znot for real 3D, just for 2½D
sort all polygons according to the smallest (farthest) z coordinate of eachscan convert each polygon in ascending order of smallest z coordinate (i.e., back to front)
![Page 11: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/11.jpg)
The Depth-Sort Algorithmsort all polygons according to the smallest (farthest) z coordinate of eachresolve any ambiguities that sorting may cause when the polygons’ z extents overlap, splitting polygons if necessaryscan convert each polygon in ascending order of smallest z coordinate (i.e., back to front)
![Page 12: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/12.jpg)
Overlap Cases
x
x
z
PQ
y
PQ
x
y
P Q
R
![Page 13: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/13.jpg)
Overlap Detection
Do the polygons’x not overlap?Do the polygons’y not overlap?Is P entirely on the opposite side of Q’s plane from the viewpoint?Is Q entirely on the same side of P’s plane as the viewpoint?Do the projections of the polygons onto the (x,y) plane not overlap?
![Page 14: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/14.jpg)
Binary Space-Partitioning TreesAn improved painter’s algorithmKey observation:
T1
T2
Ax+By+Cz+D=0f(p): n(p-a)=0
f(p)>0f(p)<0
T3
T4
T5
![Page 15: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/15.jpg)
Binary Space-Partitioning Trees
T1
T2
T2 T3
T1 +-
T3
![Page 16: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/16.jpg)
Binary Space-Partitioning Trees
T1
T2T3
T3
T1 +-
T2 +-
![Page 17: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/17.jpg)
Splitting trianglesa
b
c
A
B
a
b
c
A
B
![Page 18: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/18.jpg)
BSP Tree ConstructionBSPtree makeBSP(L: list of polygons) {
if (L is empty) {return the empty tree;
} Choose a polygon P from L to serve as root;Split all polygons in L according to Preturn new TreeNode (
P,makeBSP(polygons on negative side of P),makeBSP(polygons on positive side of P))
}Splitting polygons is expensive! It helps to choose P wisely at each step.
Example: choose five candidates, keep the one that splits the fewest polygons.
![Page 19: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/19.jpg)
BSP Tree Displayvoid showBSP(v: Viewer, T: BSPtree) {
if (T is empty) return;P = root of T;if (viewer is in front of P) {
showBSP(back subtree of T);draw P;showBSP(front subtree of T);
} else {showBSP(front subtree of T);draw P;showBSP(back subtree of T);
}} 2D BSP demo
![Page 20: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/20.jpg)
Binary Space-Partitioning Trees
P1P2A
B
C
D
1
2
3
P1
P2 P2
A BCD3,1,2 3,2,1 1,2,3 2,1,3
front
front front
back
backback
extremely efficient for static objects
![Page 21: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/21.jpg)
Binary Space-Partitioning Trees
Same BSP tree can be used for any eye position, constructed only once if the scene if static.It does not matter whether the tree is balanced. However, splitting triangles is expensive and try to avoid it by picking up different partition planes.
![Page 22: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/22.jpg)
3
4
1
2
56
7
9
8
11
10
BSP Tree
![Page 23: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/23.jpg)
3
4
1
2
56
7
1
insideones
outsideones
9
8
11
10
BSP Tree
![Page 24: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/24.jpg)
3
4
1
2
56
7
1
234
567891011
9
8
11
10
BSP Tree
![Page 25: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/25.jpg)
3
4
1
2
9
8
11
10
56
7
9b
9a
1
5
679a1011a11a
11b89b11b
BSP Tree
![Page 26: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/26.jpg)
3
4
1
2
9
8
11
10
56
7
9b
11a
2
3
4
1
5
6
7
9a
10
11a
8
9b
11b
9a11b
BSP Tree
![Page 27: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/27.jpg)
3
4
1
2
9
8
11
10
56
7
9b
point
11a
2
3
4
1
5
6
7
9a
10
11a
8
9b
11b
9a11b
BSP Tree
![Page 28: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/28.jpg)
3
4
1
2
9
8
11
10
56
7
9b
point
11a
2
3
4
1
5
6
7
9a
10
11a
8
9b
11b
9a11b
BSP Tree Traversal
![Page 29: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/29.jpg)
1
2
9
8
11
10
56
7
9b
point
11a
2
3
4
1
5
6
7
9a
10
11a
8
9b
11b
9a11b
3
4
BSP Tree Traversal
![Page 30: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/30.jpg)
The z-Buffer Algorithm
Resolve depths at the pixel levelIdea: add Z to frame buffer, when a pixel is drawn, check whether it is closer than what’s already in the frame buffer
![Page 31: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/31.jpg)
The z-Buffer Algorithm
+
+ =
=
![Page 32: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/32.jpg)
The z-Buffer Algorithmvoid zBuffer() {
int pz;for (each polygon) {
for (each pixel in polygon’s projection) {pz=polygon’s z-value at (x,y);if (pz>=ReadZ(x,y)) {
WriteZ(x,y,pz);WritePixel(x,y,color);
}}
}}
![Page 33: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/33.jpg)
The z-Buffer Algorithm
y
y1
y2
y3
ys
z1
z2
z3
zazp zb Scan line
ab
pbabbp
sb
sa
xxxx
zzzz
yyyyzzzz
yyyyzzzz
−
−−−=
−−
−−=
−−
−−=
)(
)(
)(
31
1311
21
1211
![Page 34: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/34.jpg)
z-Buffer: Example
color buffer depth buffer
![Page 35: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/35.jpg)
The z-Buffer AlgorithmBenefits
Easy to implementWorks for any geometric primitiveParallel operation in hardware
independent of order of polygon drawn
LimitationsMemory required for depth bufferQuantization and aliasing artifactsOverfillTransparency does not work well
![Page 36: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/36.jpg)
Scan-Line Algorithm
x
y
A
B
C
D
E
α
β
γ
γ+2γ+1
F
![Page 37: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/37.jpg)
Scan-Line Algorithm
ET = edge tablePT = polygon tableAET = active-edge table
ET entry x ymax Δx ID
PT entry ID Plane eq. Shading info In-out
AET contents
Scan line Entries
AB
AB
AB
AB
AC
AC
DE
CB
FD
CB
DE
FE
FE
FE
α
β
γ,γ+1
γ+2
![Page 38: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/38.jpg)
General Scan-Line Algorithmadd surfaces to polygon table (PT);initialize active-edge table (AET);
for (each scan line) {update AET;
for (each pixel on scan line) {determine surfaces in AET that project to pixel;find closest such surface;determine closest surface’s shade at pixel;
}}
![Page 39: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/39.jpg)
Ray Tracing = Ray Castingselect center of projection and window on viewplane;for (each scan line in image) {
for (each pixel in scan line) {determine ray from center of projection through pixel;for (each object in scene) {
if (object is intersected and is closest considered thus far)record intersection and object name;
}set pixel’s color to that at closest object intersection;
}}
![Page 40: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/40.jpg)
Ray Casting
Window
Center ofprojection
![Page 41: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/41.jpg)
Ray Casting (Appel, 1968)
![Page 42: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/42.jpg)
Ray Casting (Appel, 1968)
![Page 43: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/43.jpg)
Ray Casting (Appel, 1968)
![Page 44: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/44.jpg)
Ray Casting (Appel, 1968)
( ) ( )( )∑=
⋅+⋅+nls
i
nisidiaa VRkNLkIIk
1
![Page 45: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/45.jpg)
Ray Casting (Appel, 1968)
direct illumination
![Page 46: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/46.jpg)
Spatial Partitioning
![Page 47: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/47.jpg)
Spatial Partitioning
R
A B
C
![Page 48: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/48.jpg)
Spatial Partitioning
1
23
A
B
![Page 49: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/49.jpg)
Space Subdivision Approaches
Uniform grid K-d tree
![Page 50: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/50.jpg)
Space Subdivision Approaches
Quadtree (2D)Octree (3D)
BSP tree
![Page 51: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/51.jpg)
Uniform Grid
![Page 52: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/52.jpg)
Preprocess scene1. Find bounding box
Uniform Grid
![Page 53: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/53.jpg)
Preprocess scene1. Find bounding box2. Determine grid resolution
Uniform Grid
![Page 54: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/54.jpg)
Uniform Grid
Preprocess scene1. Find bounding box2. Determine grid resolution3. Place object in cell if its
bounding box overlaps the cell
![Page 55: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/55.jpg)
Uniform Grid
Preprocess scene1. Find bounding box2. Determine grid resolution3. Place object in cell if its
bounding box overlaps the cell
4. Check that object overlaps cell (expensive!)
![Page 56: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/56.jpg)
Uniform Grid Traversal
Preprocess sceneTraverse grid
3D line = 3D-DDA
![Page 57: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/57.jpg)
From Uniform Grid to Quadtree
![Page 58: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/58.jpg)
Quadtree (Octrees)
subdivide the space adaptively
![Page 59: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/59.jpg)
Quadtree Data Structure
Quadrant Numbering
![Page 60: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/60.jpg)
Quadtree Data Structure
Quadrant Numbering
![Page 61: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/61.jpg)
Quadtree Data Structure
Quadrant Numbering
![Page 62: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/62.jpg)
Quadtree Data Structure
Quadrant Numbering
![Page 63: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/63.jpg)
From Quadtree to Octree
x
y
z
![Page 64: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/64.jpg)
A
A
Leaf nodes correspond to unique regions in space
K-d Tree
![Page 65: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/65.jpg)
Leaf nodes correspond to unique regions in space
A
A
B
K-d Tree
![Page 66: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/66.jpg)
Leaf nodes correspond to unique regions in space
A
B
A
B
K-d Tree
![Page 67: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/67.jpg)
A
B
A
B
C
K-d Tree
![Page 68: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/68.jpg)
A
B
C A
B
C
K-d Tree
![Page 69: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/69.jpg)
A
B
C A
B
C
D
K-d Tree
![Page 70: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/70.jpg)
A
B
C
D
A
B
C
D
K-d Tree
![Page 71: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/71.jpg)
A
B C
D
A
B
C
D
Leaf nodes correspond to unique regions in space
K-d Tree
![Page 72: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/72.jpg)
A
B C
D
A
B
C
D
Leaf nodes correspond to unique regions in space
K-d Tree Traversal
![Page 73: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/73.jpg)
Warnock’s Algorithm
an area-subdivision algorithm
![Page 74: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/74.jpg)
Warnock’s Algorithm1. all the polygons are disjoint from the area2. there is only one intersecting or only one
contained polygon3. there is a single surrounding polygon, but
no intersecting or contained polygons4. more than one polygon is intersecting,
contained in, or surrounding the area, but one is a surrounding polygon that is in front of all the other polygons
![Page 75: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/75.jpg)
Warnock’s Algorithm
surrounding intersecting contained disjoint
![Page 76: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/76.jpg)
Warnock’s Algorithm
x
z
x
zSurroundingpolygon
Surroundingpolygon
Intersectingpolygon
Intersectingpolygon
Containedpolygon
![Page 77: Computer Graphicsgraphics.im.ntu.edu.tw/~robin/courses/3dcg08/ppt/3dcg08_05vsd.pdf · Computer Graphics Bing-Yu Chen National Taiwan University Visible-Surface Determination Back-Face](https://reader033.vdocument.in/reader033/viewer/2022060311/5f0ab8927e708231d42d0377/html5/thumbnails/77.jpg)
Performance of Four Algorithmsfor Visible-Surface Determination
AlgorithmNumber of Polygons
100 2,500 60,000
Depth sort 1 10 507
z-buffer 54 54 54
Scan line 5 21 100
Warnock area subdivision 11 64 307