Cliing MIT EECS 6.837 Frédo Durand and Seth Teller Some slides and images courtesy of Leonard McMillan MIT EECS 6.837, Teller and Durand 1 MIT EECS 6.837, Teller and Durand 2 Administrative Assignment 1 Gallery Assignment 2 Due Friday 27 at 5m Model a scene using iv files from assignt 1 Lighting: at least one sot and one other light MIT EECS 6.837, Teller and Durand 3 MIT EECS 6.837, Teller and Durand 4 Overview of grahics ieline? Questions about revious lectures? MIT EECS 6.837, Teller and Durand 5 MIT EECS 6.837, Teller and Durand 6
Today s lecture: Cliing Overview of grahics ieline? Overview and motivation Scene Database Camera+Viewort arameters lane euation & oint cliing 0 Traverse Geometric Model Transform to World sace Aly lighting Euation at vertices Line & segment cliing Transform to Eye sace ersective transform to NDC Cli Acceleration using outcodes Transform to 3D Screen sace Rasterize Resolve visibility olygon cliing MIT EECS 6.837, Teller and Durand 7 Framebuffer Values MIT EECS 6.837, Teller and Durand 8 Cliing Eliminate arts of rimitives outside the viewing frustum Shirley 210 Jim Blinn s Corner, A Tri Down The Grahics ieline, Morgan Kaufman, chater 13 MIT EECS 6.837, Teller and Durand 9 Why cliing? Avoid degeneracy Don t draw outside image Avoid division by 0 and overflow Efficiency Don t waste time on object outside the screen Other grahics methods (usually more comlex cases, non convex) Hidden-surface removal Shadows icking Binning CSG (Boolean) oerations (2D & 3D) MIT EECS 6.837, Teller and Durand 10 Cliing strategies lan Don t cli (and hoe for the best) Cli on the-fly during rasterization Analytical cliing: alter inut geometry This is the subject of today s lecture Overview and motivation lane euation & oint cliing 0 Line & segment cliing Acceleration using outcodes MIT EECS 6.837, Teller and Durand 11 olygon cliing MIT EECS 6.837, Teller and Durand 12
3D lane euation Imlicit lane euation H() = Ax+By+Cz+D = 0 Gradient of H? 3D lane euation Imlicit lane euation H() = Ax+By+Cz+D = 0 Gradient of H? lane defined by 0(x,y,z,1) n(a, B, C, 1) H 0 H MIT EECS 6.837, Teller and Durand 13 MIT EECS 6.837, Teller and Durand 14 lane-oint distance lane H=0 If n is normalized d=h Signed distance! Homogeneous lane euation H=(A,B,C,D) =(x,y,z,1) Dot roduct in homogeneous coordinates H.=0 ( H T =0 ) Duality between oints and hyerlanes 0 H n 0 H MIT EECS 6.837, Teller and Durand 15 MIT EECS 6.837, Teller and Durand 16 Homogeneous lane euation H=(A,B,C,D) =(x,y,z,1) Infinite number of euivalent lane exressions sax+sby+scz+sd=0 Infinite number of homogeneous coordinate (sx, sy, sz, sw) n 0 H MIT EECS 6.837, Teller and Durand 17 Cliing wrt 1 lane ass through if H 0 Cli (or cull or reject) if H<0 0 MIT EECS 6.837, Teller and Durand 18
oint cliing Test against each of the 6 lanes Normals oriented towards the interior Cli (or cull or reject) if H<0 oint cliing & transformation Transform M (e.g. from world sace to NDC) The lane euation is transformed with (M -1 ) T MIT EECS 6.837, Teller and Durand 19 MIT EECS 6.837, Teller and Durand 20 lan Overview and motivation arametric exression of line? lane euation & oint cliing 0 Line & segment cliing 1 Acceleration using outcodes 0 olygon cliing MIT EECS 6.837, Teller and Durand 21 MIT EECS 6.837, Teller and Durand 22 Line-lane intersection Insert exlicit euation of line into imlicit euation of lane 1 Segment cliing If H < 0 and H > 0, cli to lane If H < 0 and H > 0, cli to lane If H > 0 andh> 0, ass through If H < 0 and H < 0, clied out arameter t can be used to interolate attributes (color, etc.) 0 MIT EECS 6.837, Teller and Durand 23 MIT EECS 6.837, Teller and Durand 24
Segment cliing If H < 0 and H > 0, cli to lane If H < 0 and H > 0, cli to lane If H > 0 andh> 0, ass through If H < 0 and H < 0, clied out Segment cliing If H < 0 and H > 0, cli to lane If H < 0 and H > 0, cli to lane If H > 0 andh> 0, ass through If H < 0 and H < 0, clied out MIT EECS 6.837, Teller and Durand 25 MIT EECS 6.837, Teller and Durand 26 Segment cliing If H < 0 and H > 0, cli to lane If H < 0 and H > 0, cli to lane If H > 0 andh> 0, ass through If H < 0 and H < 0, clied out Segment cliing If H < 0 and H > 0, cli to lane If H < 0 and H > 0, cli to lane If H > 0 andh> 0, ass through If H < 0 and H < 0, clied out MIT EECS 6.837, Teller and Durand 27 Note ualitative contrast with oint cliing Triage" MIT EECS 6.837, Teller and Durand 28 Cliing against the frustum For each frustum lane H If H<0 and H<0, clied out; break If H>0 and>h 0, ass through If H < 0 and H > 0, cli to H If H < 0 and H > 0, cli to H Segment cliing Note: must interolate associated attributes (color, normal, texture, etc.) MIT EECS 6.837, Teller and Durand 29 MIT EECS 6.837, Teller and Durand 30
Line cliing Questions? Result is a single segment Why? MIT EECS 6.837, Teller and Durand 31 MIT EECS 6.837, Teller and Durand 32 lan Acceleration using outcodes Overview and motivation lane euation & oint cliing Line & segment cliing 0 Avoid many geometric calculations Eliminate obvious rejects We ll show it in 2D Same rincile in n-d Acceleration using outcodes olygon cliing MIT EECS 6.837, Teller and Durand 33 MIT EECS 6.837, Teller and Durand 34 Is it efficient? For each frustum lane H If H<0 and H<0, clied out; break If H>0 and>h 0, ass through If H < 0 and H > 0, cli to H If H < 0 and H > 0, cli to H Is it efficient? For each frustum lane H If H<0 and H<0, clied out; break If H>0 and>h 0, ass through If H < 0 and H > 0, cli to H If H < 0 and H > 0, cli to H MIT EECS 6.837, Teller and Durand 35 MIT EECS 6.837, Teller and Durand 36
Is it efficient? For each frustum lane H If H<0 and H<0, clied out; break If H>0 and>h 0, ass through If H < 0 and H > 0, cli to H If H < 0 and H > 0, cli to H Is it efficient? For each frustum lane H If H<0 and H<0, clied out; break If H>0 and>h 0, ass through If H < 0 and H > 0, cli to H If H < 0 and H > 0, cli to H What is the roblem? MIT EECS 6.837, Teller and Durand 37 MIT EECS 6.837, Teller and Durand 38 Is it efficient? For each frustum lane H If H<0 and H<0, clied out; break If H>0 and>h 0, ass through If H < 0 and H > 0, cli to H If H < 0 and H > 0, cli to H What is the roblem? The comutation of the intersections were unnecessary How can we detect this earlier? Outcodes Comute the n lane euations for oint Combine into an outcode (binary) 0 means : is valid wrt this lane 1010 0010 0110 Outcode of : 1010 MIT EECS 6.837, Teller and Durand 39 MIT EECS 6.837, Teller and Durand 40 Outcodes Comute the n lane euations for oint and Combine into an outcode (binary) Logical AND Outcodes When do we fail to save comutation? 1010 0010 0110 Outcode of : 1010 Outcode of : 0110 Outcode of [] : 0010 Rejected because there is a 1 MIT EECS 6.837, Teller and Durand 41 MIT EECS 6.837, Teller and Durand 42
Outcodes When do we fail to save comutation? Conservative rejection And we have the info on what to intersect Outcode of : 1000 Outcode of : 0010 Outcode of [] : 0000 Not rejected MIT EECS 6.837, Teller and Durand 43 Outcodes It works for arbitrary rimitives Outcode of : 1010 Outcode of : 1010 Outcode of r : 0110 Outcode of s : 0010 Outcode of t : 0110 Outcode of u : 0010 Outcode : 0010 Rejected MIT EECS 6.837, Teller and Durand 44 When to cli? Before ersective transform in 3D sace Use the euation of 6 lanes Advantages? roblems? In homogeneous coordinates after ersective transform (NDC) Before ersective divide Advantages? roblems In the transformed 3D screen sace after ersective division Advantages? roblems? MIT EECS 6.837, Teller and Durand 45 When to cli? Before ersective transform in 3D sace Use the euation of 6 lanes Natural, not too degenerate In homogeneous coordinates after ersective transform (Cli sace) Before ersective divide (4D sace, weird w values) Canonical,indeendent of camera The simlest to imlement in fact In the transformed 3D screen sace after ersective division roblem: objects in the lane of the camera MIT EECS 6.837, Teller and Durand 46 lan olygon cliing Overview and motivation lane euation & oint cliing 0 Line & segment cliing Acceleration using outcodes olygon cliing MIT EECS 6.837, Teller and Durand 47 MIT EECS 6.837, Teller and Durand 48
olygon cliing olygon cliing Cliing is symmetric MIT EECS 6.837, Teller and Durand 49 MIT EECS 6.837, Teller and Durand 50 olygon cliing is comlex Even when the olygons are convex olygon cliing is nasty When the olygons are concave MIT EECS 6.837, Teller and Durand 51 MIT EECS 6.837, Teller and Durand 52 Weiler-Atherton Cliing Strategy: Walk" olygon/window boundary olygons are oriented (CCW) Weiler-Atherton Cliing Comute intersection oints MIT EECS 6.837, Teller and Durand 53 MIT EECS 6.837, Teller and Durand 54
Weiler-Atherton Cliing Comute intersection oints Mark oints where olygons enters cliing window (green here) Cliing While there is still an unrocessed entering intersection Walk" olygon/window boundary MIT EECS 6.837, Teller and Durand 55 MIT EECS 6.837, Teller and Durand 56 Walking rules Out-to-in air: Record clied oint Follow olygon boundary (ccw) In-to-out air: Record clied oint Follow window boundary (ccw) Walking rules Out-to-in air: Record clied oint Follow olygon boundary (ccw) In-to-out air: Record clied oint Follow window boundary (ccw) MIT EECS 6.837, Teller and Durand 57 MIT EECS 6.837, Teller and Durand 58 Walking rules Out-to-in air: Record clied oint Follow olygon boundary (ccw) In-to-out air: Record clied oint Follow window boundary (ccw) Walking rules Out-to-in air: Record clied oint Follow olygon boundary (ccw) In-to-out air: Record clied oint Follow window boundary (ccw) MIT EECS 6.837, Teller and Durand 59 MIT EECS 6.837, Teller and Durand 60
Walking rules While there is still an unrocessed entering intersection Walk" olygon/window boundary Walking rules While there is still an unrocessed entering intersection Walk" olygon/window boundary MIT EECS 6.837, Teller and Durand 61 MIT EECS 6.837, Teller and Durand 62 Walking rules While there is still an unrocessed entering intersection Walk" olygon/window boundary Walking rules While there is still an unrocessed entering intersection Walk" olygon/window boundary MIT EECS 6.837, Teller and Durand 63 MIT EECS 6.837, Teller and Durand 64 Weiler-Atherton Cliing Imortance of good adjacency data structure (here simly list of oriented edges) Robustness, recision, degeneracies What if a vertex is on the boundary? What haens if it is almost on the boundary? roblem with floating oint recision Welcome to the real world of 3D geometry! MIT EECS 6.837, Teller and Durand 65 MIT EECS 6.837, Teller and Durand 66
Cliing Constructive Solid Geometry (CSG) Many other cliing algorithms: arametric, general windows, region-region, One-lane-at-a-Time Cliing, etc. Sort of generalized cliing Boolean oerations Very oular in CAD/CAM CSG tree Union Intersection MIT EECS 6.837, Teller and Durand 67 Difference Ari Raoort, Steven Sitz 97 MIT EECS 6.837, Teller and Durand 68 Constructive Solid Geometry (CSG) Simle with some rendering algorithms (Ray Tracing) Constructive Solid Geometry (CSG) Simle with some rendering algorithms (Ray Tracing) MIT EECS 6.837, Teller and Durand 69 MIT EECS 6.837, Teller and Durand 70 Constructive Solid Geometry (CSG) Questions? Simle with some rendering algorithms (Ray Tracing) Very hard with olygonal models Can also be done with hardware tricks MIT EECS 6.837, Teller and Durand 71 MIT EECS 6.837, Teller and Durand 72
laytime: Sunset We have seen why the sunset is red laytime: The Green Flash Novel by Jules Verne (19 th century) Movie by Rohmer, Summer Visual henomenon at sunset MIT EECS 6.837, Teller and Durand 73 MIT EECS 6.837, Teller and Durand 74 laytime: The Green Flash Green Flash htt://mintaka.sdsu.edu/gf/ htt://www.mtwilson.edu/tour/lot/green_flash/ htt://www.intersoft.it/galaxlux/greenflashgallery.htm htt://www.isc.tamu.edu/~astro/research/sandiego.html htt://www.meteores.net/rv.html htt://flzhgn.home.mindsring.com/grnray.htm MIT EECS 6.837, Teller and Durand 75 MIT EECS 6.837, Teller and Durand 76 Green flash Green flash MIT EECS 6.837, Teller and Durand 77 MIT EECS 6.837, Teller and Durand 78
Green flash Mirage Refraction temerature gradient Ω shae Deends on wavelength MIT EECS 6.837, Teller and Durand 79 MIT EECS 6.837, Teller and Durand 80 Green flash Green flash Simulation MIT EECS 6.837, Teller and Durand 81 MIT EECS 6.837, Teller and Durand 82 Green flash Why don t you see green flash at sunrise? MIT EECS 6.837, Teller and Durand 83