Docsity

Clipping In 3D - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Clipping In 3D - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Clipping In 3D

Docsity.com

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

Docsity.com

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

Docsity.com

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

Docsity.com

The Clipping Volume

  • 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

Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) Docsity.com

Normalisation

  • The transformed volume is then normalised around position (0, 0, 0) and the z axis is reversed

Images taken from Hearn & Baker, “Computer Graphics with OpenGL” (2004) Docsity.com

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:

bit 6 Far

bit 5 Near

bit 4 Top

bit 3 Bottom

bit 2 Right

bit 1 Left

Docsity.com

Dividing Up The World (cont..)

  • Because we have a normalised clipping volume we can test for these regions as follows:
  • Rearranging these we get:

− 1 ≤ ≤ 1 h

xh − 1 ≤ ≤ 1 h

y (^) h − 1 ≤ ≤ 1 h

zh

− h ≤ xh ≤ h − h ≤ yh ≤ h − h ≤ zh ≤ h if h >^0

h ≤ xh ≤ − h h ≤ yh ≤ − h h ≤ zh ≤ − h if h <^0

Docsity.com

Point Clipping

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

Docsity.com

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 P 3 [010101] to P 4 [100110] can be rejected Docsity.com

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 P 1 (x1 (^) h,

y1 h, z1h, h1 ) and P 2 (x2 h, y2 h, z2h, h2 ) the

parametric equation describing any point on the line is: P = P 1 + ( P 2 − P 1 ) u 0 ≤ u ≤ 1

Docsity.com

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:

h h h h u

z z z z u

y y y y u

x x x x u

h h h h

h h h h

h h h h

Docsity.com

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 y p

and zp similarly

h h h u

x x x u h

x x (^) p h h h h

x h x h

x h u h h

h − − −

Docsity.com

3D Line Clipping Example (cont…)

  • When then simply continue as per the two dimensional line clipping algorithm

Docsity.com