cs 184 computer graphics
play

CS-184: Computer Graphics Lecture #10: Clipping and Hidden - PowerPoint PPT Presentation

1 CS-184: Computer Graphics Lecture #10: Clipping and Hidden Surfaces Prof. James OBrien University of California, Berkeley V2015-S-10-1.0 2 Today Clipping Clipping to view volume Clipping arbitrary polygons Hidden


  1. 1 CS-184: Computer Graphics Lecture #10: Clipping and Hidden Surfaces Prof. James O’Brien University of California, Berkeley V2015-S-10-1.0 2 Today • Clipping • Clipping to view volume • Clipping arbitrary polygons • Hidden Surface Removal • Z-Buffer • BSP Trees • Others 2 10-ClippingAndHidden.key - October 12, 2016

  2. 3 Clipping • Stuff outside view volume should not be drawn • Too close: obscures view 3 4 Clipping • Stuff outside view volume should not be drawn • Too close: obscures view • Too far: • Complexity • Z-buffer problems • Too high/low/right/left: • Memory errors • Broken algorithms • Complexity 4 10-ClippingAndHidden.key - October 12, 2016

  3. 5 Clipping Line to Line/Plane Line segment to be clipped a x ( t ) = a + t ( b − a ) n ˆ b Line/plane that clips it r n · x − ˆ ˆ n · r = 0 5 6 Clipping Line to Line/Plane Line segment to be clipped a x ( t ) = a + t ( b − a ) } n ˆ b Line/plane that clips it t = f − ˆ n · a n · x − f = 0 ˆ n · d ˆ n · ( a + t ( b − a )) − f = 0 ˆ n · a + t ( ˆ ˆ n · ( b − a )) − f = 0 6 10-ClippingAndHidden.key - October 12, 2016

  4. 7 Clipping Line to Line/Plane • Segment may be on one side a t 62 [ 0 ... 1 ] n ˆ b • Lines may be parallel t = f − ˆ n · a n · d ˆ n · d = 0 ˆ | ˆ n · d | ≤ ε (Recall comments about numerical issues) 7 8 Triangle Clip/Split + + + c c c - - - a a a - - - b b b Double vertices if you want separation... 8 10-ClippingAndHidden.key - October 12, 2016

  5. 9 Polygon Clip to Convex Domain • Convex domain defined by collection of planes (or lines or hyper-planes) • Planes have outward pointing normals • Clip against each plane in turn • Check for early/trivial rejection 9 10 Polygon Clipping • Find the part of a polygon inside the clip window? Before Clipping 10-ClippingAndHidden.key - October 12, 2016

  6. 11 Polygon Clipping • Find the part of a polygon inside the clip window? After Clipping 12 Sutherland-Hodgman Clipping • Clip to each window boundary one at a time 10-ClippingAndHidden.key - October 12, 2016

  7. 13 Sutherland-Hodgman Clipping • Clip to each window boundary one at a time 14 Sutherland-Hodgman Clipping • Clip to each window boundary one at a time 10-ClippingAndHidden.key - October 12, 2016

  8. 15 Sutherland-Hodgman Clipping • Clip to each window boundary one at a time 16 Sutherland-Hodgman Clipping • Clip to each window boundary one at a time 10-ClippingAndHidden.key - October 12, 2016

  9. 17 Polygon Clip to Convex Domain Note double edges. 17 18 Polygon Clip to Convex Domain Inside Outside Inside Outside Inside Outside Inside Outside p s i s p p s i p s Output p Output i No output Output i and p 18 10-ClippingAndHidden.key - October 12, 2016

  10. 19 Polygon Clip to Convex Domain • Sutherland-Hodgman algorithm • Basically edge walking • Clipping done often... should be efficient • Liang-Barsky parametric space algorithm • See text for clipping in 4D homogenized coordinates 19 20 General Polygon Clipping A − B B A B − A A ∪ B A ∩ B 20 10-ClippingAndHidden.key - October 12, 2016

  11. 21 General Polygon Clipping • Weiler Algorithm • Double edges 21 22 Hidden Surface Removal • True 3D to 2D projection would put every thing overlapping into the view plane. • We need to determine what’s in front and display only that. 22 10-ClippingAndHidden.key - October 12, 2016

  12. 23 Z-Buffers • Add extra depth channel to image • Write Z values when writing pixels • Test Z values before writing Images from Okan Arikan 23 24 Z-Buffers • Benefits • Easy to implement • Works for most any geometric primitive • Parallel operation in hardware • Limitations • Quantization and aliasing artifacts • Overfill • Transparency does not work well 24 10-ClippingAndHidden.key - October 12, 2016

  13. 25 Z-Buffers • Transparency requires partial sorting: Front Partially Partially 3rd 1st transparent transparent Opaque Opaque 2nd 3rd Opaque Opaque 1st 2nd Good Not Good 25 26 Z-Buffers Recall depth-value distortions. It’s a feature... More resolution near viewer Best use of limited precision 26 10-ClippingAndHidden.key - October 12, 2016

  14. 27 A-Buffers • Store sorted list of “fragments” at each pixel • Draw all opaque stuff first then transparent • Stuff behind full opacity gets ignored • Nice for antialiasing... 27 28 Scan-line Algorithm • Assume polygons don’t intersect • Each time an edge is crossed determine who’s on top 28 10-ClippingAndHidden.key - October 12, 2016

  15. 29 Painter’s Algorithm • Sort Polygons Front-to-Back • Draw in order • Back-to-Front works also, but wasteful • How to sort quickly? • Intersecting polygons? • Cycles? 29 30 BSP-Trees • Binary Space Partition Trees • Split space along planes • Allows fast queries of some spatial relations • Draw Front-to-Back • Draw same-side polygons first • Draw root node polygon (if any) • Draw other-side polygons last 30 10-ClippingAndHidden.key - October 12, 2016

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend