1 of 26

1

Tong-Yee Lee

2 of 26

2

3 of 26

3

4 of 26

4

  1. 2D Clipping but waste division for outside viewing window
  2. Avoid divided by “0”

5 of 26

5

3D Clipping

3D Culling

6 of 26

6

Clipping

7 of 26

7

This manner is OK. But, it needs “Divisionbefore clipping.

Sometimes, it is kind of waste.

For example, red color shapes below.

Z = -n

Z=-f

Z=0

8 of 26

8

9 of 26

9

10 of 26

10

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.

11 of 26

11

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

12 of 26

12

13 of 26

13

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

14 of 26

14

A

B

15 of 26

15

P’: output

first

A

B

P: output

second

16 of 26

16

A

B

P: output

17 of 26

17

A

B

P’: output

18 of 26

18

A

B

No output

19 of 26

19

A

B

No output

20 of 26

20

21 of 26

21

Polygon Clipping in

Homogeneous Coordinates

(Clipping Space Coordinates

22 of 26

22

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)

23 of 26

23

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

24 of 26

24

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

………..

………..

25 of 26

25

A

B

P: output

Inside

Outside

Case 1

!Aout = !Bout

Aout!=Bout

Then, Bout is also input into the polygon!

26 of 26

26

At most,it will have 6 extra

vertex after clipping with

six planes

Circulate each

Input polygon

Vertex according

To Sutherland-

Hodgman polygon

clipping