Create Presentation
Download Presentation

Download Presentation
## CSL 859: Advanced Computer Graphics

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**CSL 859: Advanced Computer Graphics**Dept of Computer Sc. & Engg. IIT Delhi**Basic 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**View-Frustum Visibility**• Clipping • Scissoring • Culling**Clipping**• 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**Clipping**• 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**Clipping**• 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**Clipping**• 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**Intersection**v1t + v0(1-t) x1t + x0(1-t) = -1 t = (1+x0)/(x0-x1) y = y1t + y0(1-t) v1 v0 x=-1**Homogeneous Space Clipping**• Clip coordinates = projective coordinates • -1 < x/z < +1 (after perspective divide) • -1 < x/w < +1 (clip) • -w < x < w • -w < y < w • 0 < z < w**View-frustum Culling**• Project all vertices • Then cull**Group Culling**• Cull in World space**Group Culling**• Cull in World space • Group polygons • Cull groups • Plane test**Groups**• 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**Hierarchies**Sphere AABB OBB kDOP**Bounding 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**AABB Computation**• Extrema along each primary axis**OBB 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**Non-separating axis**Separating 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**SAT 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**axis**Triangle seen from side Triangle/Box with SAT • Assume that they overlapped on x,y,z • Must continue testing • 2) Axis orthogonal to face of triangle**Triangle/Box with SAT**• If separating axis still not found… • 3) Test axis: t=ebox x etriangle • Example: • x-axis from box: ebox=(1,0,0) • etriangle=v1-v0 • Test all such combinations • If there is at least one separating axis, then the objects do not intersect • Otherwise they do**Hierarchical Culling**• Test for a group • If outside frustum • Cull • If inside frustum • Display • Otherwise, • Subdivide group into smaller groups • Recurse for each group**BVH vs. Spatial Partitioning**BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy**BVH vs. Spatial Partitioning**BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy**BVH vs. Spatial Partitioning**BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy**BVH vs. Spatial Partitioning**BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy**Uniform Spatial Sub**Quadtree/Octree kd-tree BSP-tree Spatial Data Structures & Subdivision • Many others……**Uniform 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”**Octrees**• 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)**Bounding 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 parent’s triangles • A binary bounding volume hierarchy:**Designing 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**Observations**• 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.**Convex Hull**AABB OBB Sphere 6-dop Trade-off in Choosing BV’s increasing complexity & tightness of fit decreasing cost of (overlap tests + BV update)**Fitting 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**Back-face Culling**Sphere Half the sphere is not visible**ev.n > 0**Polygonal Backfacing?**Hierarchical 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**Back-Patch Culling**p.n > e.n for all p c-e.n > r|n|**Back-patch Visibility**p n e**Back-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**Silhouettes**• 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?**Results**Wireframe Translation Fattening**Exact 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**Notion 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))**“Dual” 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**p2**f2 Duality f1 p1**f2**Duality f1 O p1 p2