Title: CSL 859: Advanced Computer Graphics
1CSL 859 Advanced Computer Graphics
- Dept of Computer Sc. Engg.
- IIT Delhi
2Basic Depth Visibility
- Z-buffer
- Linear in pixel and geometry complexity
- Front to back
- Back to front
- Depth sorting
- Want to cull groups
- Of pixels
- Hiererchical Z-buffer
- Of primitives
- Occlusion Culling
3View-Frustum Visibility
- Clipping
- Scissoring
- Culling
4Clipping
- Clip with each boundary
- Out from In
- Output Intersection
- In from Out
- Output Intersection
- Output Vertex
- Out from Out
- Discard
- In from In
- Output Vertex
x 1
x-1
5Clipping
- Clip with each boundary
- Out from In
- Output Intersection
- In from Out
- Output Intersection
- Output Vertex
- Out from Out
- Discard
- In from In
- Output Vertex
6Clipping
- Clip with each boundary
- Out from In
- Output Intersection
- In from Out
- Output Intersection
- Output Vertex
- Out from Out
- Discard
- In from In
- Output Vertex
7Clipping
- Clip with each boundary
- Out from In
- Output Intersection
- In from Out
- Output Intersection
- Output Vertex
- Out from Out
- Discard
- In from In
- Output Vertex
8Intersection
v1t v0 (1-t)
x1t x0 (1-t) -1 t (1x0)/(x0-x1) y y1t
y0 (1-t)
v1
v0
x-1
9Homogeneous Space Clipping
- Clip coordinates projective coordinates
- -1 lt x/z lt 1 (after perspective divide)
- -1 lt x/w lt 1 (clip)
- -w lt x lt w
- -w lt y lt w
- 0 lt z lt w
10View-frustum Culling
- Project all vertices
- Then cull
11Group Culling
12Group Culling
- Cull in World space
- Group polygons
- Cull groups
- Plane test
13Groups
- Bounding volume hierarchies
- Bounding sphere
- Axis-aligned bounding boxes (AABB)
- Oriented bounding boxes (OBB)
- Discrete oriented planes (k-DOPs)
- Spatial Partitioning
- Octrees
- Binary space partition tree
14Hierarchies
Sphere AABB OBB kDOP
15Bounding Sphere Computation
16Bounding Sphere Computation
- Propose a center
- Find radius that includes all vertices
- Minimal volume obtained
- if 4 supporting vertices touch the sphere
- Test also degenerate case of 2 or 3 vertices
- Start with sphere through 2 vertices
- Test inclusion of other vertices in sequence
- If v is outside
- Compute new sphere also supported by v
- Restart if a previously included vertex is
outside this new sphere
17AABB Computation
- Extrema along each primary axis
18OBB Computation
- One face and one edge of convex polyhedron are
part of OBB - OR
- Three edges of the convex polyhedron form part of
the OBB
19Separating Axis Theorem
- Disjoint convex polyhedrons, A and B, are
separated along at least one of - An axis orthogonal to a face of A
- An axis orthogonal to a face of B
- An axis formed from the cross product of one edge
from each of A and B
20SAT example Triangle/Box
- Box is axis-aligned
- 1) test the axes that are orthogonal to the faces
of the box - That is, x,y, and z
21Triangle/Box with SAT
- Assume that they overlapped on x,y,z
- Must continue testing
- 2) Axis orthogonal to face of triangle
22Triangle/Box with SAT
- If separating axis still not found
- 3) Test axis tebox x etriangle
- Example
- x-axis from box ebox(1,0,0)
- etrianglev1-v0
- Test all such combinations
- If there is at least one separating axis, then
the objects do not intersect - Otherwise they do
23Hierarchical Culling
- Test for a group
- If outside frustum
- Cull
- If inside frustum
- Display
- Otherwise,
- Subdivide group into smaller groups
- Recurse for each group
24BVH vs. Spatial Partitioning
- BVH SP
- - Object centric - Space centric
- - Spatial redundancy - Object redundancy
25BVH vs. Spatial Partitioning
- BVH SP
- - Object centric - Space centric
- - Spatial redundancy - Object redundancy
26BVH vs. Spatial Partitioning
- BVH SP
- - Object centric - Space centric
- - Spatial redundancy - Object redundancy
27BVH vs. Spatial Partitioning
- BVH SP
- - Object centric - Space centric
- - Spatial redundancy - Object redundancy
28Spatial Data Structures Subdivision
29Uniform Spatial Subdivision
- Decompose the objects (the entire simulated
environment) into identical cells arranged in a
fixed, regular grids (equal size boxes or voxels) - To represent an object, only need to decide which
cells are occupied. To perform collision
detection, check if any cell is occupied by two
object - Storage to represent an object at resolution of
n voxels per dimension requires upto n3 cells - Accuracy solids can only be approximated
30Octrees
- Quadtree is derived by subdividing a 2D-plane
in both dimensions to form quadrants - Octrees are a 3D-extension of quadtree
- Use divide-and-conquer
- Reduce storage requirements (in comparison to
grids/voxels)
31Bounding Volume Hierarchies
- Model Hierarchy
- Each node has a simple volume that bounds a set
of triangles - Children contain volumes that each bound a
different portion of the parents triangles - A binary bounding volume hierarchy
32Designing BVH
- It should fit the original model as tightly as
possible - Testing two such volumes for overlap should be as
fast as possible - It should require the BV updates as infrequently
as possible
33Observations
- Simple primitives (spheres, AABBs, etc.) do very
well with respect to the second constraint. But
they cannot fit some long skinny primitives
tightly. - More complex primitives (minimal ellipsoids,
OBBs, etc.) provide tight fits, but checking for
overlap between them is relatively expensive. - Cost of BV updates needs to be considered.
34Trade-off in Choosing BVs
- increasing complexity tightness of fit
- decreasing cost of (overlap tests BV update)
35Fitting OBBs statistically
- Sample the convex hull of the geometry
- Find the mean and covariance matrix of the
samples - The mean will be the center of the box
- The eigenvectors of the covariance matrix are the
principal directions axes - The principle directions tend to align along the
longest axis, then the next longest that is
orthogonal, and then the other orthogonal axis
36Principal Components
37Back-face Culling
Sphere
Half the sphere is not visible
38Polygonal Backfacing?
39Polygon Groups
40Hierarchical Back-face Culling
- Cluster proximate polygons
- Keep orientations similar too
- For a group, find the half-space intersection
- If the eye lies in the common HS
- Cull group
- Coherence in traversal
- Subdivide half-space into partitions
- Query which partition eye lies in
41Back-Patch Culling
p.n gt e.n for all p
c-e.n gt rn
42Back-patch Visibility
p
n
e
43Back-Patch Culling
- Create bounding volume for object
- Compute planes tangent to volume
- passing through eye
- Compute half-space intersection of these planes
- Compute bounding cone of normals of the object
- If normal cone lies in common half-space
- Cull Object
44Silhouettes
- Edges between front and back faces
- Simple hack
- Render the front-facing polygons
- Render the back-facing polygons (in black)
- A common edge gets over-written
- Render them as wide lines?
- Offset backfaces closer?
45Results
- Wireframe Translation Fattening
-
46Exact Silhouettes
- For each edge check two adjacent faces
- Can compute hierarchically
- If an entire group front or back facing
- Discard
- Otherwise
- Subdivide
- But consider boundaries between groups
47Notion of Duality
- Dual of plane ax by cz 1 0 is
- point (a, b, c)
- And Dual of a point is a plane
- If point v is in ve half-space of plane P
- Dual(P) is in ve half-space of Dual (v)
- Dual of edge e between faces f1 and f2 is
- edge Dual(plane(f1))-Dual(plane(f2))
48Dual Approach
- Geometric duals
- silhouette-edge duals cross the view-point dual
(plane) - Coherence
- consecutive view-planes form a wedge
- Edge crossing the wedge is a silhouette update
49Duality
f1
p1
50Duality
f1
O
p1
p2
51Silhouette Update
View-plane
6
4
1
7
2
3
5
52Silhouette Algorithm Details
- Double-wedge point location query
- Partition space
- Octree, BAR-tree
- If region intersected by wedge
- recur
53Silhouette Algorithm Details
Lin
Lout
Adj Container
Tree Region
Double wedge
54Quiz 5
- Explain how quadric error is used for mesh
simplification. - Define Mean curvature and Gaussian curvature of a
surface.
55Cells Portals
- Goal walk through architectural models
(buildings, cities, catacombs) - These divide naturally into cells
- Rooms, alcoves, corridors
- Transparent portals connect cells
- Doorways, entrances, windows
- Cells only see other cells through portals
56Cells Portals
57Cells Portals
- Idea
- Cells form the basic unit of PVS
- Create an adjacency graph of cells
- Starting with cell containing eyepoint, traverse
graph, rendering visible cells - A cell is only visible if it can be seen through
a sequence of portals - So cell visibility reduces to testing portal
sequences for a line of sight
58Cells Portals
A
D
E
F
C
B
G
H
E
A
B
C
D
F
G
H
59Cells Portals
A
D
E
F
C
B
G
H
E
A
B
C
D
F
G
H
60Cells Portals
A
D
E
F
C
B
G
H
E
A
B
C
D
F
G
H
61Cells Portals
A
D
E
F
C
B
G
H
E
A
B
C
D
F
G
H
62Cells Portals
A
D
E
F
C
B
G
H
E
A
B
C
D
F
G
H
63Cells Portals
A
D
E
?
F
C
B
G
H
E
A
B
C
D
F
G
?
H
64Cells Portals
A
D
E
X
F
C
B
G
H
E
A
B
C
D
F
G
X
H
65Cells Portals
- View-independent solution find all cells a
particular cell could possibly see - C can only see A, D, E, and H
A
D
E
H
66Cells Portals
- View-independent solution find all cells a
particular cell could possibly see - H will never see F
A
D
E
C
B
G
67Cells and Portals
- Factor into View-independent view-dependent
- Portal-portal visibility line stabbing
- Linear program Teller 1993
- Cell-cell visibility stored in stab trees
- View-dependent eye-portal visibility stage
further refines PVS at run time - Slow pre-process
- Pointer following at render time
68Linear Programming
- Canonical form Find x that
- Maximizes cT x
- Objective function
- subject to Ax lt b
- -ve constraints
- where xi gt 0
- ve constraints
69Occlusion Query
- HW mechanism to determining visibility of a set
of geometry - After rendering geometry, query if any of the
geometry could have or did modify the depth
buffer. - If Query answer is false, geometry could not
have affected depth buffer - If true, it could have or did modify depth
buffer - Ex Render bounding box, Query
70Occlusion Query
- Returns pixel count the no. of pixels that pass
- May issue multiple queries at once before asking
for the result of any one - Applications can overlap the time it takes for
the queries to return with other CPU work
71Occlusion Query How to Use
- (Optional) Disable Depth/Color Buffers
- (Optional) Disable any other irrelevant state
- Generate occlusion queries
- Begin ith occlusion query
- Render ith (bounding) geometry
- End occlusion query
- Do other CPU computation now
- (Optional) Enable Depth/Color Buffers
- (Optional) Re-enable any other state
- Get pixel count of ith query
- If (count gt MAX_COUNT) render ith geometry
72Occlusion Query How to Use
- Generate occlusion queries
- Gluint queriesN
- GLuint pixelCount
- glGenOcclusionQueriesNV(N, queries)
- Loop over queries
- for (i 0 i lt N i)
- glBeginOcclusionQueryNV(queriesi)
- // render bounding box for ith
geometry - glEndOcclusionQueryNV()
-
73Occlusion Query How to Use
- Get pixel counts
- for (i 0 i lt N i)
- glGetOcclusionQueryuivNV(queriesi,
GL_PIXEL_COUNT_NV, -
pixelCount) - if (pixelCount gt MAX_COUNT)
- // render ith geometry
-
74Incremental Object Culling
- How valuable is it?
- Bounding box still must be filled
- Must Query against something
- More intelligent queries possible
- Big win if you use query for object that you were
going to render in any case - Can amortize
- Skip query for visible objects for the next few
frames - Visible objects of last frame could occlude
75Incremental Object Culling
- Useful for multi-pass algorithms
- Render scene (roughly) from front to back
- Draw big occluders (walls) first
- Issue queries for other objects in the scene
- If query returns 0 in a pass, skip the object in
subsequent passes - Works well if the first pass sets up the depth
buffer only
76From Region Visibility
Rest of the Scene
Equivalent center of projection
Occluding Segment
View Segment
77Visibility From Region in 3D
78Visibility From Region in 3D
- Find all supporting planes
- occluder and occludee in the same half-space
- Find a COP in that half-space of planes
- Clip occluders with planes parallel to supporting
planes - Render Scene
- Render clipped triangles
- Re-render triangles with occlusion query