topic 8: visibility - dynamic graphics projectkaran/courses/csc418/418/lectures/lecture5.… ·...
TRANSCRIPT
![Page 1: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/1.jpg)
Topic 8:
Visibility
• Elementary visibility computations:ClippingBackface culling
• Algorithms for visibility determinationZ-BufferingPainter’s algorithmBSP Trees
![Page 2: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/2.jpg)
Visibility Problem
What is NOT visible?
![Page 3: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/3.jpg)
Visibility Problem
What is NOT visible?
primitives outside of the field of view
back-facing primitives
primitives occluded by other objects closer to the camera
![Page 4: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/4.jpg)
Polygon Clipping (wrt to a single plane)
p0
p1
p2
p12
p3
p4
p45p5
IN
OUT
in, in
edge (pk, pk+1)
Input Output
pk+1
in, out pintersect
out, outout, in pintersect , pk+1
![Page 5: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/5.jpg)
Polygon Clipping (wrt to a volume)
Clip with respect to each plane of the volume in sequence!
Does the order of the planes matter?
Does it work for concave polygons?
Does it work for concave volumes?
![Page 6: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/6.jpg)
Polygon Clipping (when to clip?)
![Page 7: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/7.jpg)
Backface culling
![Page 8: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/8.jpg)
Backface culling
![Page 9: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/9.jpg)
Backface culling
V
N
E
![Page 10: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/10.jpg)
Backface culling
N.V > 0 is a back face?
V
N
![Page 11: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/11.jpg)
Backface culling
N.(P-E) >0
V
N
E
P
![Page 12: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/12.jpg)
Backface culling (when to cull?)
Where in the graphics pipeline can we do backface culling?
canonical
projection
![Page 13: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/13.jpg)
Occluded faces
Does backface culling always determine visibility completely for a single object?
![Page 14: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/14.jpg)
Occluded faces
In typical scenes some polygons will overlap, we must determine which portion of each polygon is visible to eye!
![Page 15: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/15.jpg)
Painters Algorithm
Sort primitives in Z.
Draw primitives back to front (CBA).
A
B
C
![Page 16: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/16.jpg)
Painters Algorithm
Problems
• Large faces
• Intersecting faces
• Cycles
![Page 17: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/17.jpg)
BSP tree
![Page 18: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/18.jpg)
Visibility Problem
Z-Buffer
Scanline
![Page 19: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/19.jpg)
19
Rasterization or Scan Conversion
Rasterization takes shapes like triangles and determines which pixels to fill.
![Page 20: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/20.jpg)
20
Filling Polygons
First approach:
1. Polygon Scan-Conversion
• Rasterize a polygon scan line by scan line, determining which pixels to fill on each line.
![Page 21: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/21.jpg)
21
Filling Polygons
Second Approach:
2. Polygon Fill
• Select a pixel inside the polygon. Grow outward until the whole polygon is filled.
![Page 22: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/22.jpg)
22
Coherence
Scan-line
Edge
Span
![Page 23: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/23.jpg)
23
Polygon Scan Conversion
Intersection Points
Other points in the span
![Page 24: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/24.jpg)
24
Polygon Scan Conversion
Process each scan line
1. Find the intersections of the scan line with all polygon edges.
2. Sort the intersections by x coordinate.
3. Fill in pixels between pairs of intersections using an odd-parity rule.
- Set parity even initially.
- Each intersection flips the
parity.
- Draw when parity is odd.
![Page 25: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/25.jpg)
25
Special Cases: Vertices
How do we count the intersecting vertex in the parity computation?
Count it zero or two times.
Scan line
vertex
![Page 26: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/26.jpg)
26
Special Cases: Vertices
What about:
Here it counts once.
Scan line
vertex
![Page 27: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/27.jpg)
27
Computing Intersections
For each scan line, we need to know if it intersects the polygon edges.
It is expensive to compute a complete line-line intersection computation for each scan line.
After computing the intersection between a scan line and an edge, we can use that information in the next scan line.
![Page 28: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/28.jpg)
28
Triangles
Always convex: No matter how you rotate a triangle, it only has one span per scan line.
Any polygon can be decomposed into triangles.
Convex Concave
![Page 29: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/29.jpg)
Visibility Problem
A-buffer
![Page 30: Topic 8: Visibility - Dynamic Graphics Projectkaran/courses/csc418/418/Lectures/lecture5.… · Topic 8: Visibility •Elementary visibility computations: Clipping Backface culling](https://reader033.vdocuments.us/reader033/viewer/2022060318/5f0c72017e708231d4357004/html5/thumbnails/30.jpg)
Visibility Problem
Image space algorithms
• Operate in display terms pixels, scanlines
• Visibility resolved to display resolution
• Examples: Z-buffer, ray-tracing
• O(n*resolution)
Object Space algorithms
• Analytically compute visible fragments
• Examples: painters algorithm, BSP
• O(n2 )