1 / 101

Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn USC and prof. Han-Wei Sh

Rasterization. Okay, you have three points (vertices) at screen space. How can you fill the triangle?. . v0. v2. E2. E1. E0. v0. v1. E0. E1. E2. . v1. v2. E1. . 1. . 1. . 2. 2. . . . . . . . . . Simple Solution. int draw_tri(render,t) GzRender *render; GzTriangle t;{

kaz
Download Presentation

Course Note Credit: Some of slides are extracted from the course notes of prof. Mathieu Desburn USC and prof. Han-Wei Sh

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    2. Rasterization Okay, you have three points (vertices) at screen space. How can you fill the triangle?

    5. Interpolater

    7. Better & still simple approach Find left edge & right edge from v0 You can not tell when y==v0.y But you can tell by comparing x values when y == v0.1+1 You need to treat horizontal edges carefully (divide by zero).

    10. Back-face Culling If a surface’s normal is pointing to the same direction as our eye direction, then this is a back face The test is quite simple: if N * V > 0 then we reject the surface

    21. Rasterizing Polygons

    22. Scan Line Algorithms

    23. Scan Line Algorithms

    24. Scan Line Algorithms

    25. Scanline Rasterization Special Handling Intersection is an edge end point, say: (p0, p1, p2) ?? (p0,p1,p1,p2), so we can still fill pairwise In fact, if we compute the intersection of the scanline with edge e1 and e2 separately, we will get the intersection point p1 twice. Keep both of the p1.

    26. Scanline Rasterization Special Handling But what about this case: still (p0,p1,p1,p2)

    27. Rule Rule: If the intersection is the ymin of the edge’s endpoint, count it. Otherwise, don’t. Don’t count p1 for e2

    28. Data Structure Edge table: all edges sorted by their ymin coordinates. keep a separate bucket for each scanline within each bucket, edges are sorted by increasing x of the ymin endpoint

    29. Edge Table

    30. Active Edge Table (AET) A list of edges active for current scanline, sorted in increasing x

    32. Polygon Scan-conversion Algorithm Construct the Edge Table (ET); Active Edge Table (AET) = null; for y = Ymin to Ymax Merge-sort ET[y] into AET by x value Fill between pairs of x in AET for each edge in AET if edge.ymax = y remove edge from AET else edge.x = edge.x + dx/dy sort AET by x value end scan_fill

    33. Scan Line Algorithms

    34. Convex Polygons

    35. Crow’s Algorithm

    36. Crow’s Algorithm

    37. Crow’s Algorithm

    38. Crow’s Algorithm

    39. Crow’s Algorithm

    40. Crow’s Algorithm

    41. Crow’s Algorithm

    42. Scan Line Algorithm Low memory cost Uses scan-line coherence but not vertical coherence Has several side advantages: filling the polygons reflections texture mapping Renderman (Toy Story) = scan line

    43. Visibility Clipping Culling

    44. Clipping Objects may lie partially inside and partially outside the view volume We want to “clip” away the parts outside

    45. Cohen-Sutherland Clipping Clip line against convex region Clip against each edge Line crosses edge replace outside vertex with intersection Both endpoints outside trivial reject Both endpoints inside trivial accept

    46. Cohen-Sutherland Clipping

    47. Cohen-Sutherland Clipping Store inside/outside bitwise for each edge Trivial accept outside(v1) | outside(v2) == 0 Trivial reject outside(v1) & outside(v2) Compute intersection (eg. x = a) (a, y1 + (a-x1) * (y2-y1)/(x2-x1))

    48. Classifies each vertex of a primitive, by generating an outcode. An outcode identifies the appropriate half space location of each vertex relative to all of the clipping planes. Outcodes are usually stored as bit vectors. Outcode Algorithm

    51. The Maybe case

    52. The Maybe Case

    53. Culling Removing completely invisible objects/polygons

    54. Culling Check whether all vertices lie outside the clip plane

    55. Backface Culling For closed objects, back facing polygons are not visible

    56. Flood Fill

    57. Flood Fill

    58. Area Subdivision (Warnock) (mixed object/image space)

    59. Area Subdivision (Warnock) Initialize the area to be the image plane Four cases: No polygons in area: done One polygon in area: draw it Pixel sized area: draw closest polygon Front polygon covers area: draw it Otherwise, subdivide and recurse

    60. BSP (Binary Space Partition) Trees

    61. BSP Trees

    62. BSP Trees

    63. BSP Trees

    64. Spatial Data Structures Data structures for efficiently storing geometric information. They are useful for Collision detection (will the spaceships collide?) Location queries (which is the nearest post office?) Chemical simulations (which protein will this drug molecule interact with?) Rendering (is this aircraft carrier on-screen?), and more Good data structures can give speed up rendering by 10x, 100x, or more

    65. Bounding Volume Simple notion: wrap things that are hard to check for ray intersection in things that are easy to check. Example: wrap a complicated polygonal mesh in a box. Ray can’t hit the real object unless it hits the box Adds some overhead, but generally pays for itself . Can build bounding volume hierarchies

    66. Bounding Volumes Choose Bounding Volume(s) Spheres Boxes Parallelepipeds Oriented boxes Ellipsoids Convex hulls

    67. Quad-trees Quad-tree is the 2-D generalization of binary tree node (cell) is a square recursively split into four equal sub-squares stop when leaves get “simple enough”

    68. Octrees Octree is the 3-D generalization of quad-tree node (cell) is a cube, recursively split into eight equal sub- cubes stop splitting when the number of objects intersecting the cell gets “small enough” or the tree depth exceeds a limit internal nodes store pointers to children, leaves store list of surfaces more expensive to traverse than a grid adapts to non-homogeneous, clumpy scenes better

    69. K-D tree The K-D approach is to make the problem space a rectangular parallelepiped whose sides are, in general, of unequal length. The length of the sides is the maximum spatial extent of the particles in each spatial dimension.

    70. K-D tree

    71. K-D Tree in 3-D Similarly, the problem space in three dimensions is a parallelepiped whose sides are the greatest particle separation in each of the three spatial dimensions.

    72. Motivation for Scene Graph Three-fold Performance Generality Ease of use How to model a scene ? Java3D, Open Inventor, Open Performer, VRML, etc.

    73. Scene Graph Example

    74. Scene Graph Example

    75. Scene Graph Example

    76. Scene Graph Example

    77. Scene Description Set of Primitives Specify for each primitive • Transformation • Lighting attributes • Surface attributes Material (BRDF) Texture Texture transformation

    78. Scene Graphs Scene Elements Interior Nodes Have children that inherit state transform, lights, fog, color, … Leaf nodes Terminal geometry, text Attributes Additional sharable state (textures)

    79. Scene Element Class Hierarchy

    80. Scene Graph Graph Representation What do edges mean? Inherit state along edges group all red object instances together group logical entities together parts of a car Capture intent with the structure

    81. Scene Graph

    82. Scene Graph (VRML 2.0)

    83. Example Scene Graph

    84. Simulation Animation Intersection Collision detection Picking Image Generation Culling Detail elision Attributes Scene Graph Traversal

    85. Scene Graph Considerations Functional Organization Semantics Bounding Volumes Culling Intersection Levels of Detail Detail elision Intersection Attribute Management Eliminate redundancies

    86. Functional Organization Semantics: Logical parts Named parts

    87. Functional Organization Articulated Transformations Animation Difficult to optimize animated objects

    88. Bounding Volume Hierarchies

    89. View Frustum Culling

    90. Level Of Detail (LOD) Each LOD nodes have distance ranges

    91. Attribute Management Minimize transformations Each transformation is expensive during rendering, intersection, etc. Need automatic algorithms to collapse/adjust transform hierarchy.

    92. Attribute Management Minimize attribute changes Each state change is expensive during rendering

    93. Question: How do you manage your light sources? OpenGL supports only 8 lights. What if there are 200 lights? The modeler must ‘scope’ the lights in the scene graph?

    94. Sample Scene Graph

    95. Think! How to handle optimization of scene graphs with multiple competing goals Function Bounding volumes Levels of Detail Attributes

    96. Scene Graphs Traversal Perform operations on graph with traversal Like STL iterator Visit all nodes Collect inherited state while traversing edges Also works on a sub-graph

    97. Typical Traversal Operations Typical operations Render Search (pick, find by name) View-frustum cull Tessellate Preprocess (optimize)

    98. Scene Graphs Organization Tree structure best No cycles for simple traversal Implied depth-first traversal (not essential) Includes lists, single node, etc as degenerate trees If allow multiple references (instancing) Directed acyclic graph (DAG) Difficult to represent cell/portal structures

    99. Portals

    100. Portals

    101. Portals

More Related