1 / 70

Rasterization Pipeline

Rasterization Pipeline. Rasterization Clipping. Rasterization costs. Per vertex Lighting calculations Perspective transformation Slopes calculation Per pixel Interpolations of z, c (and leading trailing edges, amortized) Read, compare, right to update the z-buffer and frame buffer.

isolde
Download Presentation

Rasterization Pipeline

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


  1. Rasterization Pipeline • Rasterization • Clipping

  2. Rasterization costs • Per vertex • Lighting calculations • Perspective transformation • Slopes calculation • Per pixel • Interpolations of z, c (and leading trailing edges, amortized) • Read, compare, right to update the z-buffer and frame buffer

  3. Acceleration techniques • Reduce per pixel cost • Reduce resolution • Back-face culling • Reduce per vertex cost • T-strips and fans • Frustum culling • Simplification • Texture map • Reduce both • Occlusion culling

  4. Back-face culling • Done in screen space by hardware • Test sign of (xB-xA) (yC-yA) - (xC-xA) (yB-yA) C B A

  5. T-strips and fans • Reuse 2 vertices of last triangle strip fan Was important when hardware had only 3 registers Saves nearly 2/3 of vertex processing A vertex is still processed twice on average Less important in modern graphics boards

  6. Frustum culling • Build a tight sphere around each object • Center it at C=((xmax+xmin)/2, (ymax+ymin)/2, (zmax+zmin)/2 ) • Compute radius r as min||CV|| for all vertices V • Test the sphere against each half-space of the frustum • If N•(EC)<-r then sphere is outside C E N

  7. N A B Simplification • Collapse edges Collapse A to B if |N•(AB)|<e Or use better error estimates

  8. Vertex clustering (Rossignac-Borrel) • Subdivide box around object into grid of cells • Coalesce vertices in each cell into one “attractor” • Remove degenerate triangles • More than one vertex in a cell • Not needed for dangling edge or vertex

  9. Vertex clustering example

  10. Hausdorff distance between T-meshes • Expensive to compute, • because it can occur away from vertices and edges! A B The point of B that is furthest away from A is closest to 3 points on A that are inside faces

  11. v v’ Estimating edge-collapse error • What is the error produced by edge collapses? • Volume of the solid bounded by old and new triangles • requires computing their intersection • Exact Hausdorff distance between old and new triangles • expensive to compute precisely • Distance between v and planes of all triangles incident on collapsed vertices • one dot product per plane (expensive, but guaranteed error bound) • Quadratic distance between v and planes old triangles • evaluate one quadratic form representing all the planes (cheap but not a bound) • leads to closed form solution for computing the optimal V’ (in least square sense)

  12. Measuring Error with Quadrics (Garland) • Given plane P, and point v, we can define a quadric distance Q(v) = D(v,P)2 • P goes through point p and has normal N • D(v,P) = pvN • Q(p) = (pvN)2, which is a quadratic polynomial in the coordinatges of v • If v=(x,y,z), Q(p)=a11x2+a22y2+a33z2+2a23yz+2a13xz+2a12xy+2b1x+2b2y+2b3z+c • Q may be written represented by 3x3 matrix A,a vector b,and a scalar c • Q(v) may be evaluated as v(Av)+2bv+c • or in matrix form as:

  13. Optimal position for v • Pick v to minimize average distance to planes Q(v) • set dQ(v)/dv = 0, which yields: v = -A-1 b

  14. Q(v) measures flatness • Isosurfaces of Q • Are ellipsoids • Stretch in flat direction • Have eigenvalues proportional to the principal curvatures

  15. Texture map • Replace distant details with their images, pasted on simplified shapes or even no flat bill-boards

  16. Texture mapping textureMode(NORMALIZED); PImage maya = loadImage(maya.jpg"); beginShape(QUADS); texture(maya); vertex(-1, 1, 1, 1, 1); vertex( 1, 1, 1, 0, 1); vertex( 1, -1, 1, 0, 0 ); vertex(-1, -1, 1, 1, 0); … endShape();

  17. Occlusion culling • Is ball containing an object hidden behind the triangle?

  18. Occlusion culling in urban walkthrough • From Peter Wonka • Need only display a few facades--the rest is hidden

  19. Shadows / visibility duality • Point light source • Shadow (volume): set of points that do not see the light • From-point visibility • Occluded space: set of points hidden from the viewpoint • Area light source (assume flat for simplicity) • Umbra: set of points that do not see any light • Penumbra: set of points that see a portion of the light source • Clearing: set of points that see the entire light source • From-cell visibility (cell C) • Hidden space: set of points hidden from all points in C • Detectable space: set of points seen from at least one point in C • Exposed space: set of points visible from all points in C

  20. From-point visibility • What is visible from a given viewpoint • Not from a given area • Usually computed at run-time for each frame • Should be fast • Or done in background before the user starts looking around • May be pre-computed for a set of important viewpoints • Can be slower • User will be invited to jump to these (street crossings) • Or to navigate along pre-computed paths (videos) • May be useful for pre-computing from-cell visibility • Which identifies all objects B that are invisible when the viewpoint is in a cell A • The cell may be reduced to a trajectory (taxi metaphor)

  21. From-point visibility • Viewpoint/light ={a}(a single point) HIDDEN DETECTED CLEAR

  22. Zen break • The moon is a perfect ball • It is full and perfectly clear • You see it through your window • You wonder about the meaning of life • You trace its outline on the glass Is is a circle? Can you prove it?

  23. Nothing is perfect • In general, the outline of the moon is an ellipse • Proof: • The pencil of rays from your eye to the moon is a cone • The intersection of that cone with the window if a conic • If the moon is clear and visible through the window: it is an ellipse • When the window is orthogonal to the axis of the cone: it is a circle

  24. Cherchez la lune • The moon is a ball B(c,r) of center c and radius r • The occluder is a triangle with vertices d, e,and f • Assume viewer is at point a • Write the geometric formulae for testing whether the moon is hidden behind the triangle f c e d HIDDEN DETECTED CLEAR

  25. When does a triangle appear clockwise? • When do the vertices d, e, f, of a triangle appear clockwise when seen from a viewpoint a? f f e d d e clockwise counter-clockwise

  26. A triangle appears clockwise when • The vertices d, e, f, of a triangle appear clockwise when seen from a viewpoint a when s(a,d,e,f) is true • Procedures(a,d,e,f) {RETURN ad•(aeaf)>0} • ad•(aeaf) is a 3x3 determinant • It is called the mixed product (or the triple product) f f e d d e clockwise counter-clockwise a a

  27. Testing a point against a half-space? • Consider the plane through points d, e,and f • It splits space in 2 half-spaces • Consider the half-space H of all points that see d, e, f clockwise • How to test whether point c is in H? f e d clockwise c

  28. Testing a point against a half-space • Consider the plane through points d, e,and f • Consider the half-space H of all points that see d, e, f clockwise • A point c isin H whens(c,d,e,f) s(c,d,e,f) {RETURN cd•(cecf)>0} f e d clockwise c

  29. Is a point hidden by a triangle? • Is point c hidden from viewpoint a by triangle (d, e, f)? • Write down all the geometric test you need to perform c f e d a

  30. c f Clockwise from a e d a Test whether a point is hidden by a triangle • To test whether c is hidden from a by triangle d, e, f do • IF NOT s(a,d,e,f) THEN swap d and e • IF NOT s(a,d,e,c) THEN RETURN FALSE • IF NOT s(a,e,f,c) THEN RETURN FALSE • IF NOT s(a,f,d,c) THEN RETURN FALSE • IF s(c,d,e,f) THEN RETURN FALSE • RETURN TRUE

  31. c e d Clockwise from a f Testing a ball against a half-space? • Consider the half-space H of all points that see(d, e, f) clockwise • When is a ball of center c and radius r in H?

  32. c e d Clockwise from a f Testing a ball against a half-space • Consider the half-space H of all points that see(d, e, f) clockwise • A ball of center c and radius r is in H when: ec • (edef) > r ||edef||

  33. c f Clockwise from a e d a Is the moon hidden by a triangle? • Is the ball of center c and radius r hidden from a by trianglewith vertices d, e,and f?

  34. c f Clockwise from a e d a Is the moon hidden by a triangle? • To test whether the ball of center c and radius r hidden from a by triangle with vertices d, e, and f do: • IF NOT s(a,d,e,f) THEN swap d and e • IF ac • (adae) < r || adae || THEN RETURN FALSE • IF ac • (aeaf) < r || aeaf || THEN RETURN FALSE • IF ac • (afad) < r || afad || THEN RETURN FALSE • IF ec • (edef) < r || edef || THEN RETURN FALSE • RETURN TRUE • Explain what each line tests • Are these test correct? • Are they sufficient?

  35. Is the moon hiding a triangle? • Triangle d, e, f is hidden from viewpoint a by a ball of center c and radius r when its 3 vertices are (hidden). • Proof? • How to test it? f f c c d e d e Hidden moon Hidden triangle

  36. When is a planar set A convex? q p seg(p,q) is the line segment from p to q A is convex  ( pA qA  seg(p,q)A ) p q p q

  37. What is the convex hull of a set A? The convex hull H(A) is the intersection of all convex sets that contain A.

  38. Is a convex occluder hiding a polyhedron? • A polyhedron P is hidden by a convex occluder O if all of its vertices are • Proof? • Is a subdivision surface hidden if its control vertices are? • We do not need to test all of the vertices • Only those of a container (minimax box, bounding ball, convex hull) • Proof? • Only those on the silhouette of a convex container • Proof? • What if the occluder is not convex? • Can it still work?

  39. Strategies for non-convex occluders? What if O is not convex? • replace O by an interior ball • Not easy to compute a (nearly) largest ball inside O • The average of the vertices of O may be outside of O • replace O by an interior axis-aligned box • Not easy to compute a largest box inside • replace O by a convex set it contains • O may be too thin Andujar, Saona Navazo CAD, 32 (13), 2000

  40. The Hoop principle The occluder does not have to be convex, provided that a portion of its surface appears convex to the viewer and that the object is behind it.

  41. Hoop from non-convex occluders • Pick a candidate occluder S • large triangle mesh • close to the viewer • Select a set D of triangles of S whose border C is a hoop: • single loop • that has a convex projection on the screen • Build a shield O • on plane behind D • bounded by projection of C • O is a convex occluder • anything hidden by O • is hidden by D • and hence by S • sure? S C D O

  42. When does a 3D polyloop appear convex? Each pair of consecutive edges defines a linear half-space from where their common vertex appears convex. The portion of space from which a loop C of edges appears convex is the intersection of these half-spaces or of their complements.

  43. Two strategies for building hoops • Grow a patch D on the surface S, or • Grow a curve C on the boundary of interior octree cells • simplify it, ensuring that the simplified border lies inside the solid

  44. Testing against a hoop • Given a hoop C, we can easily test whether the viewpoint or a whole cell sees it as convex. • Test whether the viewpoint (or whether all the vertices of the cell,) lie in the intersections of all half-spaces. • But this is not sufficient if we want to construct a shield from it. • Why not? We must ensure that the shield O is behind the portion D of the original surface S that is bounded by C.

  45. n O D C Ensuring that O is behind D Store with the hoop the thickness (depth of projection of D on the normal to C) Compute normal using sum of cross-products Use it to place the shield O sufficiently behind the hoop C so that it does not intersect D D n O C

  46. n O D C Ensuring that D occludes O Store with the hoop the thickness (range of projection of D on the normal n to C) Ensure that the viewer is not in that range … or shoot a ray from viewer to O and check parity of hits with D n O D C

  47. c f Clockwise from a e d a Growing a hoop around the moon • Find the first intersection, i, betweenacand the mesh ofS • Consider the triangle (d, e, f) of S that contains i • If the triangle hides the moon, we are done (return hidden) • Otherwise grow it by adding neighboring triangles • Let C be the boundary of this patch D of triangles • Identify bad vertices of C that appearin front of the moon • Add triangles to make these vertices interior • Ensuring that C remains a simple loop • Stop when C has no bad vertices (return hidden) • or when you can’t grow (return not hidden) • Test the surface patch D bounded by C • Count intersections with ac • If odd then return hidden

  48. Cell-to-cell visibility Now, let us look at the problem of pre-computing whether any portion of a cell A is visible from a viewpoint in cell B. Why? (Applications?)

  49. O b a A B O b a A B Notation and assumptions • Two sets, A and B • Two points aA, bB • O is the occluder • A, B, and O are disjoint • ab is the line segment from a to b • a–b  O ab = , a sees b (ignore self-occlusion) • a | b  O ab ≠ , a is occluded from by O

  50. A B O b a (Jarek’s) Terminology and definitions? • HIDDEN: HO(A,B) • B is entirely hidden from A by O • ? • DETECTED: DO(A,B) • B can be detected from any point of A • ? • GUARDED: GO(A,B) • B can be guarded from a single point of A • ? • CLEAR: CO(A,B) • B can be guarded from any point of A • ? O A B A B O a b B A O

More Related