clipping
play

Clipping Werner Purgathofer Viewing in the Rendering Pipeline - PowerPoint PPT Presentation

Einfhrung in Visual Computing 186.822 Clipping Werner Purgathofer Viewing in the Rendering Pipeline object capture/creation scene objects in object space modeling vertex stage viewing (vertex shader) projection transformed


  1. Einführung in Visual Computing 186.822 Clipping Werner Purgathofer

  2. Viewing in the Rendering Pipeline object capture/creation scene objects in object space modeling vertex stage viewing („vertex shader“) projection transformed vertices in clip space clipping + homogenization scene in normalized device coordinates viewport transformation rasterization pixel stage shading („fragment shader“) raster image in pixel coordinates Werner Purgathofer 2

  3. Overview: Clipping line clipping polygon clipping triangle clipping Werner Purgathofer 3

  4. Clipping partly visible or completely invisible parts must not be ignored and must not be drawn ignored?: scrolled?: vertices edges ⇒ must be cut off (as early as possible) . Werner Purgathofer 4

  5. Clipping Operations remove objects outside a clip window clip window: rectangle, polygon, curved boundaries applied somewhere in the viewing pipeline can be combined with scan conversion objects to clip: points, lines, triangles, polygons, curves, text, ... Werner Purgathofer 5

  6. 3 Principle Possibilities for Clipping analytically in world coordinates reduces WC → DC transformations analytically in clip coordinates simple comparisons during raster conversation = as part of the rasterization algorithm may be efficient for complex primitives Werner Purgathofer 6

  7. Line Clipping (1) P 9 P 10 P 4 P 2 P 2 P 8 P ' 8 P 1 P 1 P 6 P 6 P 3 P ' 5 P 5 P 7 P ' 7 before clipping after clipping [line clipping against a rectangular clip window] Werner Purgathofer 7

  8. Line Clipping (2) goals eliminate simple cases fast avoid intersection calculations for endpoints (x 0 ,y 0 ), (x end ,y end ) intersect parametric representation x = x 0 + u · (x end - x 0 ) y = y 0 + u · (y end - y 0 ) with window borders: intersection ⇔ 0 < u < 1 Werner Purgathofer 8

  9. Cohen-Sutherland Line Clipping assignment of region codes to line vertices 1001 1000 1010 bit1: left Window bit2: right 0001 0000 0010 bit3: below bit4: above 0101 0100 0110 binary region codes assigned to line endpoints according to relative position with respect to the clipping rectangle Werner Purgathofer 9

  10. Cohen-Sutherland Line Clipping “or” of codes of both points = 0000 ⇒ line entirely visible 1001 1000 1010 Window 0001 0000 0010 “and” of codes of both points ≠ 0000 ⇒ line entirely invisible 0101 0100 0110 all others ⇒ intersect! Werner Purgathofer 10

  11. Cohen-Sutherland Line Clipping P 2 P' 2 lines extending from one P" 2 coordinate region to another window may pass through the clip window, or they may intersect clipping boundaries without entering the window P 3 P' 1 P' 3 P 1 P 4 Werner Purgathofer 11

  12. Cohen-Sutherland Line Clipping remaining lines intersection test with bounding lines of clipping window left, right, bottom, top xw min discard an outside part (xw min ,y) repeat intersection test up to four times (x 0 ,y 0 ) m(xw min –x 0 ) vertical: (x = xw min ) (xw min –x 0 ) y = y 0 + m(xw min – x 0 ) vertical: y = y 0 + m(xw min – x 0 ), y = y 0 + m(xw max – x 0 ) horizontal: x = x 0 + (yw min – y 0 )/m, x = x 0 + (yw max – y 0 )/m Werner Purgathofer 12

  13. Cohen-Sutherland Line Clipping P 2 P' 2 passes through clipping window P" 2 window intersects boundaries without entering clipping window P 3 P' 1 P' 3 P 1 P 4 vertical: y = y 0 + m(xw min – x 0 ), y = y 0 + m(xw max – x 0 ) horizontal: x = x 0 + (yw min – y 0 )/m, x = x 0 + (yw max – y 0 )/m Werner Purgathofer 13

  14. Polygon Clipping modification of line clipping goal: one or more closed areas display of a polygon processed display of a correctly by a line-clipping algorithm clipped polygon Werner Purgathofer 14

  15. Sutherland-Hodgman Polygon Clipping processing polygon boundary as a whole against each window edge output: list of vertices original clip left clip right clip bottom clip top polygon clipping a polygon against successive window boundaries Werner Purgathofer 15

  16. Sutherland-Hodgman Polygon Clipping four possible edge cases V 2 V 1 V new V 2 V 1 V 2 V 1 V new V 1 V 2 out → in in → in in → out out → out output: V new , V 2 no output V 2 V new successive processing of pairs of polygon vertices against the left window boundary Werner Purgathofer 16

  17. Sutherland-Hodgman Polygon Clipping V 2 := 1 st vertex for 1 edge: V 1 :=V 2 V 1 V 2 :=next vertex no V 2 visible? no V 2 V 1 visible? Werner Purgathofer 17

  18. Sutherland-Hodgman Polygon Clipping V 2 := 1 st vertex for 1 edge: V 1 :=V 2 V 2 V 2 :=next vertex V new V 1 no V 2 visible? no yes V 1 visible? V new = clip edge ∩ V 1 V 2 → result list Werner Purgathofer 18

  19. Sutherland-Hodgman Polygon Clipping V 2 := 1 st vertex for 1 edge: V 1 :=V 2 V 2 → result list V 2 :=next vertex V 2 no yes V 2 visible? V 1 no yes yes V 1 visible? V 1 visible? V’ 1 = clip edge ∩ V 1 V 2 → result list Werner Purgathofer 19

  20. Sutherland-Hodgman Polygon Clipping V 2 := 1 st vertex for 1 edge: V 1 :=V 2 V 2 → result list V 2 :=next vertex no yes V 2 visible? V 2 V new no yes yes no V 1 V 1 visible? V 1 visible? V’ 1 = clip edge ∩ V 1 V 2 → result list Werner Purgathofer 20

  21. Sutherland-Hodgman Polygon Clipping window clipping a polygon against the left boundary of a 3 window, starting with 1' 2' vertex 1. 2 primed numbers are used 1 3' 4 to label the points in the 6 output vertex list for this 5' 4' window boundary 5 Werner Purgathofer 21

  22. Polygon Clip: Combination of 4 Passes the polygon is clipped against each of the 4 borders separately, that would produce 3 intermediate results. by calling the 4 tests recursively , (or by using a clipping pipeline) every result point is immediately processed on, so that only one result list is produced Werner Purgathofer 22

  23. Sutherland-Hodgman Clipping Example pipeline of boundary window 1 st clip: clippers to avoid 2 intermediate vertex lists left 2' 1' 2" 3 2 nd clip: 3' bottom 1 Processing the polygon vertices through a boundary-clipping pipeline. After all vertices are processed through the pipeline, the vertex list for the clipped polygon is {1', 2, 2', 2"} Werner Purgathofer 23

  24. Sutherland-Hodgman Polygon Clipping extraneous lines for concave polygons: split into separate parts or final check of output vertex list clipping the concave polygon with the Sutherland-Hodgeman clipper produces three connected areas Werner Purgathofer 24

  25. Clipping of Triangles often b-reps are “triangle soups” clipping a triangle  triangle(s) 4 possible cases: inside (inside) outside triangle quadrilateral  2 triangles Werner Purgathofer 25

  26. Clipping of Triangles corner cases need no extra handling! Werner Purgathofer 26

  27. From Object Space to Screen Space „view frustum“ modeling camera transformation transformation object space world space camera space projection viewport transformation transformation clip space screen space 27 Werner Purgathofer

  28. Clipping in Clip-Space clipping against x = ± 1, y = ± 1, z = ± 1 (x,y,z) inside?  only compare one value per border! is done before homogenization: x = ± h, y = ± h, z = ± h clips points that are behind the camera! reduces homogenization divisions Werner Purgathofer 28

  29. Einführung in Visual Computing 186.822 Antialiasing Werner Purgathofer

  30. Antialiasing in the Rendering Pipeline object capture/creation scene objects in object space modeling vertex stage viewing („vertex shader“) projection transformed vertices in clip space clipping + homogenization scene in normalized device coordinates viewport transformation rasterization pixel stage shading („fragment shader“) raster image in pixel coordinates Werner Purgathofer 30

  31. Aliasing and Antialiasing what is aliasing? ['eiliæsiη] what is the reason for aliasing? what can we do against it? Werner Purgathofer 31

  32. What is Aliasing? errors that are caused by the discretization of analog data to digital data too bad resolution too few colors too few images / sec geometric errors numeric errors Werner Purgathofer 32

  33. Aliasing: Staircase Effect Werner Purgathofer 33

  34. Various Aliasing Effects Werner Purgathofer 34

  35. Aliasing from too few Colors artificial color borders can appear Werner Purgathofer 35

  36. Aliasing in Animations jumping images "worming“ t backwards rotating wheels Werner Purgathofer 36

  37. Solutions against Aliasing? 1. improve the devices expensive higher resolution or more color levels incompatible faster image sequence 2. improve the images = antialiasing postprocessing software ! prefiltering ! Werner Purgathofer 37

  38. Nyquist-Shannon Sampling Theorem a signal can only be reconstructed without information loss if the sampling frequency is at least twice the highest frequency of the signal this border frequency is called " Nyquist Limit " Werner Purgathofer 38

  39. Nyquist-Shannon Sampling Theorem original signal reconstructed signal ∆ Nyquist sampling rate ∆ sampling interval Werner Purgathofer 39

Recommend


More recommend