Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.

Similar presentations


Presentation on theme: "CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi."— Presentation transcript:

1 CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi

2 Basic Depth Visibility Z-buffer Z-buffer Linear in pixel and geometry complexity Linear in pixel and geometry complexity Front to back Front to back Back to front Back to front Depth sorting Depth sorting Want to cull groups Want to cull groups Of pixels Of pixels Hiererchical Z-buffer Hiererchical Z-buffer Of primitives Of primitives Occlusion Culling Occlusion Culling

3 View-Frustum Visibility Clipping Clipping Scissoring Scissoring Culling Culling

4 Clipping Clip with each boundary Clip with each boundary Out from In Out from In Output Intersection Output Intersection In from Out In from Out Output Intersection Output Intersection Output Vertex Output Vertex Out from Out Out from Out Discard Discard In from In In from In Output Vertex Output Vertex x=-1 x= 1

5 Clipping Clip with each boundary Clip with each boundary Out from In Out from In Output Intersection Output Intersection In from Out In from Out Output Intersection Output Intersection Output Vertex Output Vertex Out from Out Out from Out Discard Discard In from In In from In Output Vertex Output Vertex

6 Clipping Clip with each boundary Clip with each boundary Out from In Out from In Output Intersection Output Intersection In from Out In from Out Output Intersection Output Intersection Output Vertex Output Vertex Out from Out Out from Out Discard Discard In from In In from In Output Vertex Output Vertex

7 Clipping Clip with each boundary Clip with each boundary Out from In Out from In Output Intersection Output Intersection In from Out In from Out Output Intersection Output Intersection Output Vertex Output Vertex Out from Out Out from Out Discard Discard In from In In from In Output Vertex Output Vertex

8 Intersection v0v0 v1v1 x=-1 v 1 t + v 0 (1-t) x 1 t + x 0 (1-t) = -1 t = (1+x 0 )/(x 0 -x 1 ) y = y 1 t + y 0 (1-t)

9 Homogeneous Space Clipping Clip coordinates = projective coordinates Clip coordinates = projective coordinates -1 < x/z < +1 (after perspective divide) -1 < x/z < +1 (after perspective divide) -1 < x/w < +1 (clip) -1 < x/w < +1 (clip) -w < x < w -w < x < w -w < y < w -w < y < w 0 < z < w 0 < z < w

10 View-frustum Culling Project all vertices Project all vertices Then cull Then cull

11 Group Culling Cull in World space Cull in World space

12 Group Culling Cull in World space Cull in World space Group polygons Group polygons Cull groups Cull groups Plane test Plane test

13 Groups Bounding volume hierarchies Bounding volume hierarchies Bounding sphere Bounding sphere Axis-aligned bounding boxes (AABB) Axis-aligned bounding boxes (AABB) Oriented bounding boxes (OBB) Oriented bounding boxes (OBB) Discrete oriented planes (k-DOPs) Discrete oriented planes (k-DOPs) Spatial Partitioning Spatial Partitioning Octrees Octrees Binary space partition tree Binary space partition tree

14 Hierarchies Sphere AABB OBB kDOP

15 Bounding Sphere Computation

16 Propose a center Propose a center Find radius that includes all vertices Find radius that includes all vertices Minimal volume obtained Minimal volume obtained if 4 supporting vertices touch the sphere if 4 supporting vertices touch the sphere Test also: degenerate case of 2 or 3 vertices Test also: degenerate case of 2 or 3 vertices Start with sphere through 2 vertices Start with sphere through 2 vertices Test inclusion of other vertices in sequence Test inclusion of other vertices in sequence If v is outside: If v is outside: Compute new sphere also supported by v Compute new sphere also supported by v Restart if a previously included vertex is outside this new sphere Restart if a previously included vertex is outside this new sphere

17 AABB Computation Extrema along each primary axis Extrema along each primary axis

18 OBB Computation One face and one edge of convex polyhedron are part of OBB One face and one edge of convex polyhedron are part of OBBOR Three edges of the convex polyhedron form part of the OBB Three edges of the convex polyhedron form part of the OBB

19 Separating Axis Theorem Disjoint convex polyhedrons, A and B, are separated along at least one of: 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 A An axis orthogonal to a face of B An axis orthogonal to a face of B An axis formed from the cross product of one edge from each of A and B An axis formed from the cross product of one edge from each of A and B Non-separating axis

20 SAT example: Triangle/Box Box is axis-aligned Box is axis-aligned 1) test the axes that are orthogonal to the faces of the box 1) test the axes that are orthogonal to the faces of the box That is, x,y, and z That is, x,y, and z

21 Triangle/Box with SAT Assume that they overlapped on x,y,z Assume that they overlapped on x,y,z Must continue testing Must continue testing 2) Axis orthogonal to face of triangle 2) Axis orthogonal to face of triangle Triangle seen from side axis

22 Triangle/Box with SAT If separating axis still not found… If separating axis still not found… 3) Test axis: t=e box x e triangle 3) Test axis: t=e box x e triangle Example: Example: x-axis from box: e box =(1,0,0) x-axis from box: e box =(1,0,0) e triangle = v 1 -v 0 e triangle = v 1 -v 0 Test all such combinations Test all such combinations If there is at least one separating axis, then the objects do not intersect If there is at least one separating axis, then the objects do not intersect Otherwise they do Otherwise they do

23 Hierarchical Culling Test for a group Test for a group If outside frustum If outside frustum Cull Cull If inside frustum If inside frustum Display Display Otherwise, Otherwise, Subdivide group into smaller groups Subdivide group into smaller groups Recurse for each group Recurse for each group

24 BVH vs. Spatial Partitioning BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy

25 BVH vs. Spatial Partitioning BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy

26 BVH vs. Spatial Partitioning BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy

27 BVH vs. Spatial Partitioning BVH: SP: - Object centric - Space centric - Spatial redundancy - Object redundancy

28 Spatial Data Structures & Subdivision Many others …… Many others …… Uniform Spatial Sub Quadtree/Octree kd-tree BSP-tree

29 Uniform Spatial Subdivision Decompose the objects (the entire simulated environment) into identical cells arranged in a fixed, regular grids (equal size boxes or voxels) 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 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 n 3 cells Storage: to represent an object at resolution of n voxels per dimension requires upto n 3 cells Accuracy: solids can only be “ approximated ” Accuracy: solids can only be “ approximated ”

30 Octrees Quadtree is derived by subdividing a 2D-plane in both dimensions to form quadrants Quadtree is derived by subdividing a 2D-plane in both dimensions to form quadrants Octrees are a 3D-extension of quadtree Octrees are a 3D-extension of quadtree Use divide-and-conquer Use divide-and-conquer Reduce storage requirements (in comparison to grids/voxels) Reduce storage requirements (in comparison to grids/voxels)

31 Bounding Volume Hierarchies Model Hierarchy: Model Hierarchy: Each node has a simple volume that bounds a set of triangles 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 Children contain volumes that each bound a different portion of the parent’s triangles A binary bounding volume hierarchy: A binary bounding volume hierarchy:

32 Designing BVH It should fit the original model as tightly as possible It should fit the original model as tightly as possible Testing two such volumes for overlap should be as fast as possible Testing two such volumes for overlap should be as fast as possible It should require the BV updates as infrequently as possible It should require the BV updates as infrequently as possible

33 Observations Simple primitives (spheres, AABBs, etc.) do very well with respect to the second constraint. But they cannot fit some long skinny primitives tightly. 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. 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. Cost of BV updates needs to be considered.

34 Trade-off in Choosing BV’s increasing complexity & tightness of fit increasing complexity & tightness of fit decreasing cost of (overlap tests + BV update) decreasing cost of (overlap tests + BV update) AABB OBB Sphere Convex Hull 6-dop

35 Fitting OBBs statistically Sample the convex hull of the geometry Sample the convex hull of the geometry Find the mean and covariance matrix of the samples Find the mean and covariance matrix of the samples The mean will be the center of the box The mean will be the center of the box The eigenvectors of the covariance matrix are the principal directions – axes 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 The principle directions tend to align along the longest axis, then the next longest that is orthogonal, and then the other orthogonal axis

36 Principal Components

37 Back-face Culling Sphere Half the sphere is not visible

38 Polygonal Backfacing? ev.n > 0

39 Polygon Groups

40 Hierarchical Back-face Culling Cluster proximate polygons Cluster proximate polygons Keep orientations similar too Keep orientations similar too For a group, find the half-space intersection For a group, find the half-space intersection If the eye lies in the common HS If the eye lies in the common HS Cull group Cull group Coherence in traversal Coherence in traversal Subdivide half-space into partitions Subdivide half-space into partitions Query which partition eye lies in Query which partition eye lies in

41 Back-Patch Culling p.n > e.n for all p c-e.n > r|n|

42 Back-patch Visibility p e n

43 Back-Patch Culling Create bounding volume for object Create bounding volume for object Compute planes tangent to volume Compute planes tangent to volume passing through eye passing through eye Compute half-space intersection of these planes Compute half-space intersection of these planes Compute bounding cone of normals of the object Compute bounding cone of normals of the object If normal cone lies in common half-space If normal cone lies in common half-space Cull Object Cull Object

44 Silhouettes Edges between front and back faces Edges between front and back faces Simple hack: Simple hack: Render the front-facing polygons Render the front-facing polygons Render the back-facing polygons (in black) Render the back-facing polygons (in black) A common edge gets over-written A common edge gets over-written Render them as wide lines? Render them as wide lines? Offset backfaces closer? Offset backfaces closer?

45 Results Wireframe Translation Fattening

46 Exact Silhouettes For each edge check two adjacent faces For each edge check two adjacent faces Can compute hierarchically: Can compute hierarchically: If an entire group front or back facing If an entire group front or back facing Discard Discard Otherwise Otherwise Subdivide Subdivide But consider boundaries between groups But consider boundaries between groups

47 Notion of Duality Dual of plane ax + by + cz + 1 = 0 is Dual of plane ax + by + cz + 1 = 0 is point (a, b, c) point (a, b, c) And Dual of a point is a plane And Dual of a point is a plane If point v is in +ve half-space of plane P If point v is in +ve half-space of plane P Dual(P) is in +ve half-space of Dual (v) Dual(P) is in +ve half-space of Dual (v) Dual of edge e between faces f1 and f2 is Dual of edge e between faces f1 and f2 is edge Dual(plane(f1))-Dual(plane(f2)) edge Dual(plane(f1))-Dual(plane(f2))

48 “Dual” Approach Geometric duals Geometric duals silhouette-edge duals cross the view-point dual (plane) silhouette-edge duals cross the view-point dual (plane) Coherence Coherence consecutive view-planes form a wedge consecutive view-planes form a wedge Edge crossing the wedge is a silhouette update Edge crossing the wedge is a silhouette update

49 Duality f1 p1 p2 f2

50 Duality f1 p1 p2 f2 O

51 F Silhouette Update View-plane F 1 7 2 4 6 3 5

52 Silhouette Algorithm Details Double-wedge point location query Double-wedge point location query Partition space Partition space Octree, BAR-tree Octree, BAR-tree If region intersected by wedge If region intersected by wedge recur recur

53 Silhouette Algorithm Details L in Adj Container L out Double wedge Tree Region

54 Quiz 5 1. Explain how quadric error is used for mesh simplification. 2. Define Mean curvature and Gaussian curvature of a surface.

55 Cells & Portals Goal: walk through architectural models (buildings, cities, catacombs) Goal: walk through architectural models (buildings, cities, catacombs) These divide naturally into cells These divide naturally into cells Rooms, alcoves, corridors… Rooms, alcoves, corridors… Transparent portals connect cells Transparent portals connect cells Doorways, entrances, windows… Doorways, entrances, windows… Cells only see other cells through portals Cells only see other cells through portals

56 Cells & Portals An example: An example:

57 Cells & Portals Idea: Idea: Cells form the basic unit of PVS Cells form the basic unit of PVS Create an adjacency graph Create an adjacency graph of cells Starting with cell containing eyepoint, traverse graph, rendering visible 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 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… So cell visibility reduces to testing portal sequences for a line of sight…

58 Cells & Portals A D H F CB E G H BCDFG EA

59 A D H F CB E G H BCDFG EA

60 A D H F CB E G H BCDFG EA

61 A D H F CB E G H BCDFG EA

62 A D H F CB E G H BCDFG EA

63 A D H F CB E G H BCDFG EA ? ?

64 A D H F CB E G H BCDFG EA X X

65 View-independent solution: find all cells a particular cell could possibly see: View-independent solution: find all cells a particular cell could possibly see: C can only see A, D, E, and H A D H F CB E G A D H E

66 Cells & Portals View-independent solution: find all cells a particular cell could possibly see: View-independent solution: find all cells a particular cell could possibly see: H will never see F A D H F CB E G A D CB E G

67 Cells and Portals Factor into View-independent & view- dependent Factor into View-independent & view- dependent Portal-portal visibility == line stabbing Portal-portal visibility == line stabbing Linear program [Teller 1993] Linear program [Teller 1993] Cell-cell visibility stored in stab trees Cell-cell visibility stored in stab trees View-dependent eye-portal visibility stage further refines PVS at run time View-dependent eye-portal visibility stage further refines PVS at run time Slow pre-process Slow pre-process Pointer following at render time Pointer following at render time

68 Linear Programming Canonical form: Find x that Canonical form: Find x that Maximizes c T x Maximizes c T x Objective function Objective function subject to Ax <= b subject to Ax <= b -ve constraints -ve constraints where x i >= 0 where x i >= 0 +ve constraints +ve constraints

69 Occlusion Query HW mechanism to determining “visibility” of a set of geometry 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. 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 Query answer is “false”, geometry could not have affected depth buffer If “true”, it could have or did modify depth buffer If “true”, it could have or did modify depth buffer Ex: Render bounding box, Query Ex: Render bounding box, Query

70 Occlusion Query Returns pixel count – the no. of pixels that pass Returns pixel count – the no. of pixels that pass May issue multiple queries at once before asking for the result of any one 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 Applications can overlap the time it takes for the queries to return with other CPU work

71 Occlusion Query: How to Use (Optional) Disable Depth/Color Buffers (Optional) Disable Depth/Color Buffers (Optional) Disable any other irrelevant state (Optional) Disable any other irrelevant state Generate occlusion queries Generate occlusion queries Begin i th occlusion query Begin i th occlusion query Render i th (bounding) geometry Render i th (bounding) geometry End occlusion query End occlusion query Do other CPU computation now Do other CPU computation now (Optional) Enable Depth/Color Buffers (Optional) Enable Depth/Color Buffers (Optional) Re-enable any other state (Optional) Re-enable any other state Get pixel count of i th query Get pixel count of i th query If (count > MAX_COUNT) render i th geometry If (count > MAX_COUNT) render i th geometry

72 Occlusion Query: How to Use Generate occlusion queries Generate occlusion queries Gluint queries[N]; GLuint pixelCount; glGenOcclusionQueriesNV(N, queries); Loop over queries Loop over queries for (i = 0; i < N; i++) { glBeginOcclusionQueryNV(queries[i]); glBeginOcclusionQueryNV(queries[i]); // render bounding box for i th geometry // render bounding box for i th geometry glEndOcclusionQueryNV(); glEndOcclusionQueryNV(); }

73 Occlusion Query: How to Use Get pixel counts Get pixel counts for (i = 0; i < N; i++) { glGetOcclusionQueryuivNV(queries[i], GL_PIXEL_COUNT_NV, glGetOcclusionQueryuivNV(queries[i], GL_PIXEL_COUNT_NV, &pixelCount); &pixelCount); if (pixelCount > MAX_COUNT) if (pixelCount > MAX_COUNT) // render i th geometry // render i th geometry }

74 Incremental Object Culling How valuable is it? How valuable is it? Bounding box still must be filled Bounding box still must be filled Must Query against something Must Query against something More intelligent queries possible More intelligent queries possible Big win if you use query for object that you were going to render in any case Big win if you use query for object that you were going to render in any case Can amortize: Can amortize: Skip query for visible objects for the next few frames Skip query for visible objects for the next few frames Visible objects of last frame could occlude Visible objects of last frame could occlude

75 Incremental Object Culling Useful for multi-pass algorithms Useful for multi-pass algorithms Render scene (roughly) from front to back Render scene (roughly) from front to back Draw big occluders (walls) first Draw big occluders (walls) first Issue queries for other objects in the scene Issue queries for other objects in the scene If query returns 0 in a pass, skip the object in subsequent passes 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 Works well if the first pass sets up the depth buffer only

76 From Region Visibility View Segment Occluding Segment Rest of the Scene Equivalent center of projection

77 Visibility From Region in 3D

78 Find all supporting planes Find all supporting planes occluder and occludee in the same half- space occluder and occludee in the same half- space Find a COP in that half-space of planes Find a COP in that half-space of planes Clip occluders with planes parallel to supporting planes Clip occluders with planes parallel to supporting planes Render Scene Render Scene Render clipped triangles Render clipped triangles Re-render triangles with occlusion query Re-render triangles with occlusion query


Download ppt "CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi."

Similar presentations


Ads by Google