einf hrung in visual computing clipping
play

Einfhrung in Visual Computing Clipping Werner Purgathofer - PDF document

Einfhrung in Visual Computing Clipping Werner Purgathofer Institut fr Computergraphik und Algorithmen 6. Vorlesungseinheit Computergraphik Clipping in the Rendering Pipeline Clipping object capture/creation partly visible or


  1. Einführung in Visual Computing Clipping Werner Purgathofer Institut für Computergraphik und Algorithmen 6. Vorlesungseinheit “Computergraphik” Clipping in the Rendering Pipeline Clipping object capture/creation partly visible or completely invisible parts scene objects in object space modeling must not be ignored and must not be drawn vertex stage viewing („vertex shader“) ignored scrolled projection transformed vertices in clip space transformed vertices in clip space clipping + homogenization scene in normalized device coordinates vertices edges viewport transformation  must be cut off rasterization pixel stage shading (as early as possible) („fragment shader“) raster image in pixel coordinates Werner Purgathofer 2 Werner Purgathofer 3 Clipping Operations 3 Principle Possibilities for Clipping remove objects outside a clip window analytically in world coordinates reduces WC  DC transformations clip window: rectangle, polygon, curved boundaries applied somewhere in the viewing pipeline analytically in clip coordinates can be combined with scan conversion can be combined with scan conversion simple comparisons simple comparisons objects to clip: points, lines, triangles, polygons, curves, text, ... during raster conversation = as part of the rasterization algorithm may be efficient for complex primitives Werner Purgathofer 4 Werner Purgathofer 5 1

  2. Line Clipping (1) Line Clipping (2) P 9 goals eliminate simple cases fast P 4 P 2 P 2 avoid intersection calculations P 10 P ´ 8 P 8 P 1 P 1 P 6 P 6 for endpoints (x 0 ,y 0 ), (x end ,y end ) for endpoints (x y ) (x y ) P 3 P 3 6 6 P ´ 5 intersect parametric representation P 5 P 7 P ´ 7 x = x 0 + u  (x end  x 0 ) y = y 0 + u  (y end  y 0 ) before clipping after clipping with window borders: intersection  0  u  1 [line clipping against a rectangular clip window] Werner Purgathofer 6 Werner Purgathofer 7 Cohen-Sutherland Line Clipping Cohen-Sutherland Line Clipping assignment of region codes to line endpoints “or” of codes of both points = 0000  bit1: left line entirely visible bit2: right “and” of codes of both bit3: below bit3: below points  0000  bit4: above line entirely invisible all others  intersect! binary region codes assigned to line endpoints according to relative position with respect to the clipping rectangle Werner Purgathofer 8 Werner Purgathofer 9 Cohen-Sutherland Line Clipping Cohen-Sutherland Line Clipping remaining lines intersection test with bounding lines of clipping [lines extending window from one coordinate left, right, bottom, top region to another may pass through may pass through discard an outside part discard an outside part the clip window, or repeat intersection test up to four times they may intersect clipping boundaries without entering the window] vertical: y = y 0 + m(xw min – x 0 ), y = y 0 + m(xw max – x 0 ) horiz.: x = x 0 + (yw min – y 0 )/m, x = x 0 + (yw max – y 0 )/m Werner Purgathofer 10 Werner Purgathofer 11 2

  3. Cohen-Sutherland Line Clipping Polygon Clipping modification of line clipping goal: one or more closed areas passes through clipping window intersects boundaries without entering clipping window [display of a polygon [display of a correctly vertical: y = y 0 + m(xw min – x 0 ), y = y 0 + m(xw max – x 0 ) processed by a line- clipped polygon] horiz.: x = x 0 + (yw min – y 0 )/m, x = x 0 + (yw max – y 0 )/m clipping algorithm] Werner Purgathofer 12 Werner Purgathofer 13 Sutherland-Hodgman Polygon Clipping Sutherland-Hodgman Polygon Clipping four possible edge cases processing polygon boundary as a whole against each window edge V 2 V 1 V’ 1 output: list of vertices V 2 V 1 V 2 V V V 1 V’ 1 V 1 V 2 out  in in  in in  out out  out clip original clip left clip right clip top output: V’ 1 , V 2 V 2 V’ 1 no output bottom polygon successive processing of pairs of polygon clipping a polygon against successive vertices against the left window boundary window boundaries Werner Purgathofer 14 Werner Purgathofer 15 Sutherland-Hodgman Polygon Clipping V 2 := 1 st vertex Sutherland-Hodgman for 1 edge: V 1 :=V 2 V 2  result list V 2 :=next vertex [clipping a polygon against the left boundary of a window, no yes V 2 visible? starting with vertex 1. starting with vertex 1. Primed numbers are no yes no yes used to label the points V 1 visible? V 1 visible? in the output vertex list for this window V’ 1 = clip edge  V 1 V 2 boundary]  result list Werner Purgathofer 16 Werner Purgathofer 17 3

  4. Polygon Clip: Combination of 4 Passes Sutherland-Hodgman Clipping Example pipeline of the polygon is clipped against each of the 4 boundary borders separately, 2 1 st clip: clippers to that would produce 3 intermediate results. left 2’ avoid intermediate by calling the 4 tests recursively , by calling the 4 tests recursively vertex lists 1’ 1’ 2” (or by using a clipping pipeline) 2 nd clip: 3 every result point is immediately processed bottom 3’ 1 on, so that only one result list is produced [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 18 Werner Purgathofer 19 Sutherland-Hodgman Polygon Clipping Clipping of Triangles extraneous lines for concave polygons: often b-reps are “triangle soups” clipping a triangle  triangle(s) split into separate parts or final check of output vertex list 4 possible cases: inside (inside) outside t id triangle quadrilateral  2 triangles [clipping the concave polygon with the Sutherland- Hodgeman clipper produces three connected areas] Werner Purgathofer 20 Werner Purgathofer 21 Clipping of Triangles From Object Space to Screen Space modeling camera corner cases need no extra handling! transformation transformation object space world space camera space projection transformation viewport transformation screen space clip space Werner Purgathofer 22 23 Werner Purgathofer 4

  5. Clipping in Clip-Space clipping against x = ± 1, y = ± 1, z = ± 1 (x,y,z) inside?  only compare one value! Antialiasing is done before homogenization: x = ± h, y = ± h, z = ± h clips points that are behind the camera! reduces homogenization divisions Werner Purgathofer 24 Antialiasing in the Rendering Pipeline Aliasing and Antialiasing object capture/creation scene objects in object space what is aliasing? ['eiliæsi η ] modeling vertex stage viewing („vertex shader“) projection what is the reason for aliasing? transformed vertices in clip space transformed vertices in clip space clipping + homogenization what can we do against it? scene in normalized device coordinates viewport transformation rasterization pixel stage shading („fragment shader“) raster image in pixel coordinates Werner Purgathofer 26 Werner Purgathofer / Computergraphik 1 27 What is Aliasing? Aliasing: Staircase Effect 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 / Computergraphik 1 28 Werner Purgathofer / Computergraphik 1 29 5

  6. Various Aliasing Effects Aliasing from too few Colors artificial color borders can appear Werner Purgathofer / Computergraphik 1 30 Werner Purgathofer / Computergraphik 1 31 Aliasing in Animations Solutions against Aliasing? jumping images 1. improve the devices "worming“ expensive higher resolution or more color levels t incompatible faster image sequence 2. improve the images = antialiasing backwards rotating wheels postprocessing software prefiltering ! Werner Purgathofer / Computergraphik 1 32 Werner Purgathofer / Computergraphik 1 33 Shannon Sampling Theorem Shannon Sampling Theorem a signal can only be reconstructed without original signal information loss if the sampling reconstructed signal frequency is at least twice the highest frequency of the signal Nyquist Nyquist sampling rate   sampling this border frequency is called "Nyquist Limit" interval Werner Purgathofer / Computergraphik 1 34 Werner Purgathofer / Computergraphik 1 35 6

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