visibility culling clipping 05
play

Visibility, Culling, Clipping (05) RNDr. Martin Madaras, PhD. - PowerPoint PPT Presentation

Principles of Computer Graphics and Image Processing Visibility, Culling, Clipping (05) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk Overview Clipping Point Clipping Line Clipping Polygon Clipping Hidden Surface Removal


  1. Principles of Computer Graphics and Image Processing Visibility, Culling, Clipping (05) RNDr. Martin Madaras, PhD. martin.madaras@stuba.sk

  2. Overview  Clipping  Point Clipping  Line Clipping  Polygon Clipping  Hidden Surface Removal 2

  3. 3D rendering pipeline 3D polygons Modeling 1 Transformation Lighting Viewing Transformation Projection Rasterization (05) Transformation Clip polygons outside of camera’s view Clipping Scan Conversion 2D Image 3

  4. How the lectures should look like #1 Ask questions, please!!! - Be communicative - www.slido.com #PPGSO05 - More active you are, the better for you! - 4

  5. 2D rendering pipeline 2D geometry  Clip and remove geometry outside of the Clipping window Viewport  Transform from screen coordinates to image Transformation coordinates  Fill pixels on the screen Scan Conversion 2D Image 5

  6. 2D rendering pipeline 2D geometry  Clip and remove geometry outside of the Clipping window Viewport  Transform from screen coordinates to image Transformation coordinates  Fill pixels on the screen Scan Conversion 2D Image 6

  7. Clipping  Avoid drawing parts of primitives outside window  Window defines part of scene being viewed  Must draw geometric primitives only inside window Screen Coordinates 7

  8. Clipping  Avoid drawing parts of primitives outside window  Window defines part of scene being viewed  Must draw geometric primitives only inside window 8

  9. Clipping  Avoid drawing parts of primitives outside window  Points, Lines, Polygons, Circles etc. 9

  10. Point Clipping  Is point (x,y) inside clip window ? 10

  11. Line Clipping  Find the part of a line inside the clip window Before Clipping 11

  12. Line Clipping  Find the part of a line inside the clip window After Clipping 12

  13. Cohen-Shutherland Line Clipping  Use simple test to classify easy cases first  Danny Cohen, Ivan Sutherland 1967 13

  14. Cohen-Shutherland Line Clipping  Classify lines quickly by AND of bit codes representing regions of two endpoints (test for 0) 14

  15. Cohen-Shutherland Line Clipping  Classify lines quickly by AND of bit codes representing regions of two endpoints (test for 0) 15

  16. Cohen-Shutherland Line Clipping  Classify lines quickly by AND of bit codes representing regions of two endpoints (test for 0) 16

  17. Cohen-Shutherland Line Clipping  Compute intersections with window boundary for remaining lines 17

  18. Cohen-Shutherland Line Clipping  Intersect with boundary determined by the bits of the non zero point 18

  19. Cohen-Shutherland Line Clipping  Create new point on the boundary 19

  20. Cohen-Shutherland Line Clipping  Check using the AND operation again 20

  21. Cohen-Shutherland Line Clipping  Do the same for the next line 21

  22. Cohen-Shutherland Line Clipping  Clip using the boundary determined by P7 22

  23. Cohen-Shutherland Line Clipping  Clip using the boundary determined by P7 23

  24. Cohen-Shutherland Line Clipping  Clip using the boundary determined by P8 24

  25. Cohen-Shutherland Line Clipping  Test the line again using AND 25

  26. Cohen-Shutherland Line Clipping  Again for the last line 26

  27. Cohen-Shutherland Line Clipping  P9 AND P10 no longer zero 27

  28. Cohen-Shutherland Line Clipping  Final result 28

  29. Polygon Clipping  Find the part of a polygon inside the clip window? Before Clipping 29

  30. Polygon Clipping  Find the part of a polygon inside the clip window? After Clipping 30

  31. Sutherland – Hodgman Clipping  Clip to each window boundary one at a time 31

  32. Sutherland – Hodgman Clipping  Clip to each window boundary one at a time 32

  33. Sutherland – Hodgman Clipping  Clip to each window boundary one at a time 33

  34. Sutherland – Hodgman Clipping  Clip to each window boundary one at a time 34

  35. Sutherland – Hodgman Clipping  Clip to each window boundary one at a time 35

  36. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 36

  37. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 37

  38. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 38

  39. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 39

  40. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 40

  41. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 41

  42. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 42

  43. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 43

  44. Clipping to a Boundary  Do inside test for each point in sequence  Insert new points when crossing the boundary  Remove points outside of boundary 44

  45. 2D rendering pipeline 2D geometry  Clip and remove geometry outside of the Clipping window Viewport  Transform from screen coordinates to image Transformation coordinates  Fill pixels on the screen Scan Conversion 2D Image 45

  46. Viewport Transformation  Window to viewport mapping 46

  47. Overview  Clipping  Point Clipping  Line Clipping  Polygon Clipping  Hidden Surface Removal 47

  48. Visibility wireframe model front faces silhouette visible faces, edges 48

  49. Motivation  Surfaces may be back-facing  Surfaces may be occluded  Surfaces may overlap in the image plane  Surfaces may intersect 49

  50. 3D rendering pipeline 3D polygons Modeling 1 Transformation Lighting  Somewhere here we have to determine Viewing which objects are visible and which are Transformation hidden Projection Transformation Clipping Scan Conversion 2D Image 50

  51. Basic algorithms for HSR  Clipping  Point Clipping  Line Clipping  Polygon Clipping  Hidden Surface Removal 51

  52. Optimizing visibility  Get rid of objects that are surely not visible  Frustum culling  Occlusion culling  Back-face culling 52

  53. Frustum culling  6 planes  Inside = visible volume  Is a point is inside?  Object bounding box  Speed up 53

  54. Occlusion culling  Some objects are fully occluded by others  Spatial relations between objects  Portals, occlusion culling  Realtime rendering 54

  55. Back-face culling  Which object faces are visible?  Remember normal vector (face orientation) 55

  56. Portal culling  Some parts of the scene are not visible from some other parts of the scene 56

  57. Optimizing visibility 57

  58. Basic algorithms for HSR  Back-face culling  Depth sort  Z-Buffer 58

  59. Back-face culling  How do we test back-facing polygons ?  Dot product the normal and view direction 𝑂 •V > 0 59

  60. Surface Normals  Normal  Cross product of surface tangent vectors  Length normalized to 1 60

  61. Vertex / Fragment Normals  Dot product the normal and view direction  Fragment normals can be interpolated from vertex normals 61

  62. 3D rendering pipeline 3D polygons Modeling 1 Transformation  Back-face culling Lighting  Remove all polygons that are back-facing Viewing Transformation Projection Transformation Clipping Scan Conversion 2D Image 62

  63. Depth sort  “Painter’s algorithm”  Sort surfaces by maximum depth  Draw surfaces in back to front order 63

  64. Painter’s algorithm  Sort faces in a back-to-front order, render  New pixels over-write old pixels 64

  65. Painter’s algorithm problems  Intersecting faces  Cyclically overlapping faces  Redundant rendering 65

  66. 3D rendering pipeline 3D polygons  Sorting is often O(n log n) Modeling 1 Transformation  Usually software only Lighting  Mostly using BSP-trees Viewing Transformation Projection Transformation Clipping Depth sort Scan Conversion 2D Image 66

  67. Other algorithms  Warnock algorithm  subdivide screen into a quadtree until whole cell empty or whole cell inside polygons  Reversed painter’s algorithm  paint front-to-back and paint only empty areas  Z-buffer  remember z-value for each pixel and only paint when new z is higher 67

  68. Z-Buffer  Also known as depth buffering  Stores closest depth of objects for every pixel  Draw only pixels with less depth  Depths are interpolated between vertices 68

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