430 likes | 442 Views
Learn efficient techniques for eliminating insignificant details, rendering shadows, and optimizing visibility in 3D graphics. Explore occlusion culling, from-point visibility, and pre-computation methods. Discover the duality of shadows and visibility in complex scenes.
E N D
Shadows & Visibility 3D Modeling, Graphics, and Animation Prof. Jarek Rossignac College of Computing Georgia Institute of Technology Jarek Rossignac, CoC, IIC, GT
Graphic acceleration • Eliminate insignificant details • Use lower resolution approximations computed through simplification • Use images instead of geometry • Texture maps instead of details • Imposters (billboards) • Panoramas • Images + depth • Don’t render what is not visible • Things that fall outside of viewing frustum • Back faces • Parts occluded by others Jarek Rossignac, CoC, IIC, GT
Motivation • Visibility • Most objects in a scene are hidden from any given view point • Rendering them wastes GPU cycles • Need efficient techniques for rejecting what is obviously hidden • Rejection tests can be exact, conservative (reject more), approximate • Shadows • Objects in the shadow do not reflect direct illumination • Want to know which light sources illuminate an object • Need a quick test for being “in the shadow” • Visibility and shadows are defined in terms of occluders • Surfaces or objects that may block the passage of light when placed between the object and the viewer/light Jarek Rossignac, CoC, IIC, GT
Occlusion culling in urban walkthrough • From Peter Wonka • Need only display a few facades--the rest is hidden Jarek Rossignac, CoC, IIC, GT
Shadows / visibility duality FROM POINT • 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 FROM AREA • 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 Jarek Rossignac, CoC, IIC, GT
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, and (reasonably) accurate (no popping) • Or done in background before the user starts looking around • May be pre-computed for a set of important viewpoints • Pre-computation can be slow • User will be invited to jump to these (street crossings, vistas) • or to drive along pre-computed paths (videos) • May be useful for pre-computing from-cell visibility • Identifies all objects B that are invisible when the viewpoint is in a cell A • The cell may be a cube or volume, a 2D area, or a trajectory (taxi metaphor) Jarek Rossignac, CoC, IIC, GT
From-point visibility pre-computation • Select a set of viewpoints or do it when you arrive to a new one • Make 6 images (on the walls of a small cube around viewpoint) • Write object Ids instead of colors in the frame buffer • Collect all Ids from the 6 images • Objects with Ids not collected will not be displayed Can there be errors? Can we make any guarantees about accuracy? Jarek Rossignac, CoC, IIC, GT
Outline for from-point-visibility • Simple shapes (triangle, ball) • Simple occluders (triangle, ball) • Convex occluders • Hoops (non convex surfaces) Jarek Rossignac, CoC, IIC, GT
From-point visibility • Viewpoint/light ={a}(a single point) HIDDEN DETECTED CLEAR Jarek Rossignac, CoC, IIC, GT
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? Jarek Rossignac, CoC, IIC, GT
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 Jarek Rossignac, CoC, IIC, GT
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 Jarek Rossignac, CoC, IIC, GT
A triangle appear 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•(aeaf)>0);}; • ad•(aeaf) 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 Jarek Rossignac, CoC, IIC, GT
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•(cecf)>0} f Also remember that s(c,d,e,f)==0 implies that all 4 points are co-planar! e d clockwise c Jarek Rossignac, CoC, IIC, GT
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 Jarek Rossignac, CoC, IIC, GT
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 • (edef) > r ||edef|| Jarek Rossignac, CoC, IIC, GT
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 • (adae) < r || adae || THEN RETURN FALSE • IF ac • (aeaf) < r || aeaf || THEN RETURN FALSE • IF ac • (afad) < r || afad || THEN RETURN FALSE • IF ec • (edef) < r || edef || THEN RETURN FALSE • RETURN TRUE • Explain what each line tests • Are these test correct? • Are they sufficient? Jarek Rossignac, CoC, IIC, GT
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 Jarek Rossignac, CoC, IIC, GT
Is a convex occluder hiding a polyhedron? • A polyhedron is hidden if all of its vertices are • Proof? • Will this work for subdivision surfaces? • 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? Jarek Rossignac, CoC, IIC, GT
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 • use a Hoop! • See next Andujar, Saona Navazo CAD, 32 (13), 2000 Jarek Rossignac, CoC, IIC, GT
The problem Some occluders are too thin to contain large convex objects. Jarek Rossignac, CoC, IIC, GT
The Hoops solution The occluder does not have to be convex, provided that its outline seems convex from the viewpoint Jarek Rossignac, CoC, IIC, GT
Hoops: 3D Curves as Conservative Occluders for Cell-Visibility P. Brunet, I. Navazo, J. Rossignac, C. Saona-Vázquez Software Department, Polytechnic University of Catalonia GVU Center, Georgia Institute of Technology Manchester, 7th September 2001 Jarek Rossignac, CoC, IIC, GT
When does a 3D polyloop appear convex? Each pair of consecutive edges defines a linear half-space from where their common vertex appears convex. Jarek Rossignac, CoC, IIC, GT
Testing against a hoop • Given a hoop, 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. • If so, then any simply connected surface bounded by the hoop is an occluder • Or is it? Jarek Rossignac, CoC, IIC, GT
How to grow hoops? • Grow a patch on the surface • Grow a curve on the boundary of interior octree cells and simplify it Jarek Rossignac, CoC, IIC, GT
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?) Jarek Rossignac, CoC, IIC, GT
O b a A B O b a A B Notation and assumptions • Two sets, A and B • Two points aA, bB • 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 Jarek Rossignac, CoC, IIC, GT
A B O b a O A B A B O a b B A O Definitions • HIDDEN: HO(A,B) • B is entirely hidden from A • HO(A,B) a, b: a | b • DETECTED: DO(A,B) • B can be detected from any point of A • DO(A,B) a, b: a–b • GUARDED: GO(A,B) • B can be guarded from a single point of A • GO(A,B) a, b: a–b • CLEAR: CO(A,B) • B can be guarded from any point of A • CO(A,B) a, b: a–b Jarek Rossignac, CoC, IIC, GT
Occlusion Jarek Rossignac, CoC, IIC, GT
ShieldTester:Cell-to-cell visibility test for surface occludersIsabel Navazo, Jarek Rossignac, Joan Jou, Rahim Shariff Jarek Rossignac, CoC, IIC, GT
The Occlusion Theorem Thesurface S occludes cell A from cell B, if and only if: There exists a connected component, C, of ST that is bounding a portion D of S and has no boundary in the interior of R. (The portion, DR, of the boundary of D that lies in R is exactly C.) 2. Given an arbitrary ray, RAB, from a point, a, in A to a point, b, in B, RAB has an odd number of none tangential intersections with the closed subset, DC, of S. Jarek Rossignac, CoC, IIC, GT
Various cases Jarek Rossignac, CoC, IIC, GT
ShieldTester for triangle meshes Obtain an edge eABof T from a vertex of A to a vertex of B IF eABS = THEN RETURN (“visible”) FOR EACH triangle x of S that is stabbed by eABDO{ Start a WALK that traces a connected component C of ST IF the WALK did not run into a boundary of STHEN { INVADE the portion of S to the left of the triangles crossed by the WALK along C IFthe invaded portion has no holeTHEN IF the number of triangles that were stabbed by eAB and visited by the WALK and the INVADE is odd THENRETURN (“occluded”)} RETURN (“undecided”) Jarek Rossignac, CoC, IIC, GT
c a b d e Detecting ray/triangle clash Jarek Rossignac, CoC, IIC, GT
Walking one step Jarek Rossignac, CoC, IIC, GT
c f f Clockwise from a e d e d clockwise a c Testing for ray/triangle intersection s(c,d,e,f) {RETURN cd•(cecf)>0} • 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 Jarek Rossignac, CoC, IIC, GT
Turning left on S Jarek Rossignac, CoC, IIC, GT
Invade process Jarek Rossignac, CoC, IIC, GT
Hot edges Jarek Rossignac, CoC, IIC, GT
Results Jarek Rossignac, CoC, IIC, GT
Can’t grow a patch of edge-connected triangles Leaves/branches are small and disjoint Use approximate shadow fusion Render tree(s) Mark area of rendered pixels Construct big rectangle inside it (how?) Let M= max(z-buffer inside rectangle) Push back rectangle to z=M Use it as occluder for other objects (behind the tree) Accuracy depends on screen resolution Can be improved by splitting the screen into 4 Do this recursively (quad-tree) Use bounding spheres around objects to test them Conservative part Use a hierarchy of bounding sphere (hierarchical z-buffer) Lots of small occluders Jarek Rossignac, CoC, IIC, GT
Polygons cast curved shadows! Jarek Rossignac, CoC, IIC, GT