3d polygon rendering pipeline
play

3D Polygon Rendering Pipeline Clipping 3D Rendering Pipeline (for - PowerPoint PPT Presentation

2009/2010 ' 6 3D Polygon Rendering Pipeline Clipping 3D Rendering Pipeline (for direct illumination) 3D Primitives 3D Modeling Coordinates Modeling


  1. 2009/2010 רטסמסא ' תבשחוממ הקיפרג סרוק אריפש רואיל רועיש 6 3D Polygon Rendering Pipeline Clipping

  2. 3D Rendering Pipeline (for direct illumination) 3D Primitives 3D Modeling Coordinates Modeling Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Camera Coordinates Projection Transformation 2D Screen Coordinates Clipping 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion 2D Image Coordinates Image

  3. 3D Rendering Pipeline (for direct illumination) 3D Primitives 3D Modeling Coordinates Modeling Transformation 3D World Coordinates Lighting 3D World Coordinates Viewing Transformation 3D Camera Coordinates Projection Transformation 2D Screen Coordinates Clipping 2D Screen Coordinates Viewport Transformation 2D Image Coordinates Scan Conversion 2D Image Coordinates Image

  4. 2D Rendering Pipeline 3D Primitives 2D Primitives Clip portions of geometric primitives Clipping residing outside the window Viewport Transform the clipped primitives Transformation from screen to image coordinates Scan Fill pixels representing primitives Conversion in screen coordinates Image

  5. 2D Rendering Pipeline 3D Primitives 2D Primitives Clip portions of geometric primitives Clipping residing outside the window Viewport Transform the clipped primitives Transformation from screen to image coordinates Scan Fill pixels representing primitives Conversion in screen coordinates Image

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

  7. Clipping  Avoid drawing parts of primitives outside window ◦ Window defines part of scene being viewed ◦ Must draw geometric primitives only inside window Viewing Window

  8. Clipping  Avoid drawing parts of primitives outside window ◦ Points ◦ Lines ◦ Polygons ◦ Circles ◦ etc. Viewing Window

  9. Point Clipping  Is point (x,y) inside the clip window? wy2 inside = (x >= wx1) && (x,y) (x <= wx2) && (y >= wy1) && (y <= wy2); wy1 wx1 wx2 Window

  10. Line Clipping  Find the part of a line inside the clip window P 7 P 1 P 8 P 4 P 3 P 2 P 10 P 6 P 5 P 9 Before Clipping

  11. Line Clipping  Find the part of a line inside the clip window P’ 7 P’ 8 P 4 P 3 P 6 P’ 5 After Clipping

  12. Cohen-Sutherland Line Clipping  Use simple tests to classify easy cases first P 7 P 1 P 8 P 4 P 3 P 2 P 10 P 6 P 5 P 9

  13. Cohen-Sutherland Line Clipping  Use simple tests to classify easy cases first Clipping is performed by the computation of the intersections with four boundary segments of the window: Li, i=1,2,3,4 Purpose: Fast treatment of lines that are trivially inside/outside the window. Let P=(x,y) be a point to be classified against window W. Idea: Assign P a binary code consisting of a bit for each edge of W, whose value is determined according to the following table:

  14. bit 1 0 y ≥ y min 1 y < y min y ≤ y max y > y max 2 x ≤ x max 3 x > x max x ≥ x min x < x min 4 4 3 0101 0100 0110 y max 2 0001 0000 0010 y min 1 1001 1000 1010 x min x max

  15. 0101 0100 0110 0001 0000 0010 1001 1000 1010  Given a line segment S from p 0 =(x 0 ,y 0 ) to p 1 =(x 1 ,y 1 ) to be clipped against a window W .  If code( p 0 ) AND code( p 1 ) is not zero - then S is trivially rejected.  If code( p 0 ) OR code( p 1 ) is zero - then S is trivially accepted.

  16. Cohen Sutherland Line Clipping  Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 0001 0101 P 7 Bit 4 P 1 P 8 P 4 P 3 1000 0000 0100 P 2 P 10 P 6 Bit 3 1010 P 5 0010 P 9 0110 Bit 1 Bit 2

  17. Cohen Sutherland Line Clipping  Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 0001 0101 P 7 Bit 4 P 1 P 8 P 4 P 3 1000 0000 0100 P 2 P 10 P 6 Bit 3 1010 P 5 0010 P 9 0110 Bit 1 Bit 2

  18. Cohen Sutherland Line Clipping  Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 1010 P 5 0010 P 9 0110 Bit 1 Bit 2

  19. Cohen Sutherland Line Clipping  Classify some lines quickly by AND of bit codes representing regions of two endpoints (must be 0) 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 1010 P 5 0010 P 9 0110 Bit 1 Bit 2

  20. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 1010 P 5 0010 P 9 0110 Bit 1 Bit 2

  21. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 1010 P 5 0010 P 9 0110 Bit 1 Bit 2

  22. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  23. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  24. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  25. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  26. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  27. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  28. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  29. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  30. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  31. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 1010 0010 P 9 0110 Bit 1 Bit 2

  32. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 P 9 1010 0010 0110 Bit 1 Bit 2

  33. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 10 P 6 Bit 3 P’ 5 P 9 1010 0010 0110 Bit 1 Bit 2

  34. Cohen Sutherland Line Clipping  Compute intersections with window boundary for lines that can’t be classified quickly 1001 0001 0101 P’ 7 Bit 4 P’ 8 P 4 P 3 1000 0000 0100 P 6 Bit 3 P’ 5 1010 0010 0110 Bit 1 Bit 2

  35. Cohen-Sutherland Algorithm CompOutCode (x, y : real; var code : outcode); /* Compute outcode for the point (x,y) */ begin code := 0; if Y > Ymax then code := code | B1000 else if Y < Ymin then code := code | B0100; if X > Xmax then code := code | B0010 else if X < Xmin then code := code | B0001; end;

  36. Cohen-Sutherland Algorithm (cont.) CS (x0,y0,x1,y1,xmin,xmax,ymin,ymax) { boolean accept, done :; float outcode0, outcode1, x, y; accept := false ; done := false ; CompOutCod (x0,y0,outcode0); CompOutCod (x1,y1,outcode1); repeat if ((outcode0 | outcode1 ) == 0) { /* Trivial accept */ accept := true ; done := true ; } else if ((outcode0 & outcode1 ) <> 0){ /* Trivial reject */ done := true } else /* Failed both tests, so calculate the line segment to clip from an outside point to an intersection with clip edge */

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