1 of 33

1

Tong-Yee Lee

2 of 33

2

2D/3D Polygon Clipping

3 of 33

3

4 of 33

4

A view frustum, with near- and far- clip planes. Only the shaded volume is rendered.

5 of 33

5

6 of 33

6

7 of 33

7

8 of 33

8

  • 2D Clipping but waste division for outside viewing window
  • We have better clip model before division by w

9 of 33

9

This manner is OK. But, it needs “Division” before clipping.

Sometimes, it is kind of waste.

For example, red color shapes below.

Z = -n

Z=-f

Z=0

10 of 33

10

11 of 33

11

12 of 33

12

Another Trivial Rejection Clipping

w = -z

What does it imply?

Remember if a point is behind eye, we can not

see it!!. i.e., z > 0, means it is behind eye.

So, we can check the fourth item (before division).

If the fourth item is negative, this point is behind

the eye point.

13 of 33

13

Removing Back-Faces

  • Idea: Compare the normal of each face with the viewing direction ��Given n, the outward-pointing normal of F ��for each face F of object �    if (n . v > 0) �        throw away the face��Does it work?

It always culls half

number of input polygons

14 of 33

14

15 of 33

15

A

B

P: output

Inside

Outside

Case 1

A

B

Inside

Outside

P’: output

Case 2

A

B

No output

Case 3

Inside

Outside

A

B

P’: output

first

P: output

second

Case 4

Inside

Outside

16 of 33

16

A

B

17 of 33

17

P’: output

first

A

B

P: output

second

18 of 33

18

A

B

P: output

19 of 33

19

A

B

P’: output

20 of 33

20

A

B

No output

21 of 33

21

A

B

No output

22 of 33

22

23 of 33

23

24 of 33

24

Polygon Clipping in

Homogeneous Coordinates

(Clipping Space Coordinates

25 of 33

25

Aout != Bout

C’ color is also linearly interpolated

such as

C’(r) = A’ (r)+(B’ (r)-A’(r))*t

C’(g) = A’(g)+(B’(g)-A’(g))*t

…………….

Or even for original 3D position (x,y,z) or texture space (u,v) or normal vector (Nx,Ny,Nz)

26 of 33

26

Case 4

Case 1

Case 2

Case 4

Return #num of vertex

Ex: left: C0=-C3

C0=A0+t(B0-A0)

C3=A3+t(B3-A3)

A0+t(B0-A0) =

-A3-t(B3-A3)

=>>

(-A3-A0)=t(B0-A0+B3-A3)

A0,A1,A2,A3

B0,B1,B2,B3

Ex: left side

27 of 33

27

A

B

P’: output

first

P: output

second

Case 4

Inside

Outside

Ex: left boundary:

C0=-C3

C0=A0+t(B0-A0)

C3=A3+t(B3-A3)

A0+t(B0-A0) =

-A3-t(B3-A3)

=>>

(-A3-A0)=t(B0-A0+B3-A3)

X : A0, B0

Y : A1, B1

Z : A2, B2

W: A3, B3

C

C

Left boundary

C0=-C3

Right boundary

C0=+C3

bottom boundary

C1=-C3

………..

………..

28 of 33

28

A

B

P: output

Inside

Outside

Case 1

!Aout = !Bout

Aout!=Bout

Then, Bout is also input into the polygon!

29 of 33

29

At most,it will have 6 extra

vertex after clipping with

six planes

Circulate each

Input polygon

Vertex according

To Sutherland-

Hodgman polygon

clipping

30 of 33

Bounding Volume

  • Simple shape that completely�encloses an object
  • Generally a box or sphere
  • We’ll use spheres:
    • Easiest to work with
    • Though hard to get�tight fits

30

31 of 33

Hierarchical bounding volumes

31

Recall class about projection example

32 of 33

32

33 of 33

33