1 / 24

Computer Graphics 9: Clipping In 3D

Computer Graphics 9: Clipping In 3D . Contents. In today’s lecture we are going to have a look at some perspective view demos and investigate how clipping works in 3-D Nate Robins’ OpenGL tutorials The clipping volume The zone labelling scheme 3-D clipping Point clipping Line clipping

step
Download Presentation

Computer Graphics 9: Clipping In 3D

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Graphics 9:Clipping In 3D

  2. Contents • In today’s lecture we are going to have a look at some perspective view demos and investigate how clipping works in 3-D • Nate Robins’ OpenGL tutorials • The clipping volume • The zone labelling scheme • 3-D clipping • Point clipping • Line clipping • Polygon clipping

  3. Nate Robins’ OpenGL Tutorials • Nate Robins has a number of great OpenGL tutorial applications posted on his website Nate Robin’s OpenGL Tutorials available at: http://www.xmission.com/~nate/tutors.html

  4. 3-D Clipping • Just like the case in two dimensions, clipping removes objects that will not be visible from the scene • The point of this is to remove computational effort • 3-D clipping is achieved in two basic steps • Discard objects that can’t be viewed • i.e. objects that are behind the camera, outside the field of view, or too far away • Clip objects that intersect with any clipping plane

  5. Discard Objects • Discarding objects that cannot possibly be seen involves comparing an objects bounding box/sphere against the dimensions of the view volume • Can be done before or after projection

  6. Clipping Objects • Objects that are partially within the viewing volume need to be clipped – just like the 2D case

  7. The Clipping Volume Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) • After the perspective transformation is complete the frustum shaped viewing volume has been converted to a parallelopiped - remember we preserved all z coordinate depth information

  8. Normalisation Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) • The transformed volume is then normalised around position (0, 0, 0) and the z axis is reversed

  9. When Do We Clip? • We perform clipping after the projection transformation and normalisation are complete • So, we have the following: • We apply all clipping to these homogeneous coordinates

  10. Dividing Up The World • Similar to the case in two dimensions, we divide the world into regions • This time we use a 6-bit region code to give us 27 different region codes • The bits in these regions codes are as follows:

  11. Dividing Up The World (cont..) • Because we have a normalised clipping volume we can test for these regions as follows: • Rearranging these we get:

  12. Region Codes Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

  13. Point Clipping • Point clipping is trivial so we won’t spend any time on it

  14. Line Clipping • To clip lines we first label all end points with the appropriate region codes • We can trivially accept all lines with both end-points in the [000000] region • We can trivially reject all lines whose end points share a common bit in any position • This is just like the 2 dimensional case as these lines can never cross the viewing volume • In the example that follows the line from P3[010101] to P4[100110] can be rejected

  15. Line Clipping Example Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004)

  16. The Equation Of The Line For 3D Clipping • For clipping equations for three dimensional line segments are given in their parametric form • For a line segment with end points P1(x1h, y1h, z1h, h1) and P2(x2h, y2h, z2h, h2) the parametric equation describing any point on the line is:

  17. The Equation Of The Line For 3D Clipping (cont…) • From this parametric equation of a line we can generate the equations for the homogeneous coordinates:

  18. 3D Line Clipping Example Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) • Consider the line P1[000010] to P2[001001] • Because the lines have different values in bit 2 we know the line crosses the right boundary

  19. 3D Line Clipping Example (cont…) • Since the right boundary is at x = 1 we now know the following holds: • which we can solve for u as follows: • using this value for u we can then solve for yp and zp similarly

  20. 3D Line Clipping Example (cont…) • When then simply continue as per the two dimensional line clipping algorithm

  21. 3D Polygon Clipping Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) • However the most common case in 3D clipping is that we are clipping graphics objects made up of polygons

  22. 3D Polygon Clipping (cont…) • In this case we first try to eliminate the entire object using its bounding volume • Next we perform clipping on the individual polygons using the Sutherland-Hodgman algorithm we studied previously

  23. Cheating with Clipping Planes • For far clipping plane introduce something to obscure far away objects – fog • Make objects very near the camera transparent

  24. Summary • In today’s lecture we examined how clipping is achieved in 3-D

More Related