Top Banner
L8: Visible Surface Determination Painter’s Algorithm Binary Space Partitioning (BSP) Trees Z-Buffer Ray Tracing 1
44

Visible Surface Determination - Otago

Jan 02, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Visible Surface Determination - Otago

L8:

Visible Surface Determination

• Painter’s Algorithm• Binary Space Partitioning (BSP) Trees• Z-Buffer• Ray Tracing

1

Page 2: Visible Surface Determination - Otago

L8:

Image or object space

• Ideally an object space method converts the 3D scene into a list of 2D areas to be painted.

• Image space decides for each pixel which surface to paint.

2

Page 3: Visible Surface Determination - Otago

L8:

Image or object space

• Painter’s Algorithm! ! Hybrid• BSP Trees ! ! ! ! Hybrid• Z-Buffer ! ! ! ! Image• Ray Tracing! ! ! ! Object

3

Page 4: Visible Surface Determination - Otago

L8:

Painter’s Algorithm

4

Page 5: Visible Surface Determination - Otago

L8:

Painter’s Algorithm

4

Page 6: Visible Surface Determination - Otago

L8:

Painter’s Algorithm

4

Page 7: Visible Surface Determination - Otago

L8: 5

x

y

Page 8: Visible Surface Determination - Otago

L8: 6

Page 9: Visible Surface Determination - Otago

L8:

Depth Sorting

• Completely in front–put in front• Not overlapping in x, y–either• Intersecting–divide along intersection• overlapping–divide along plane of one

polygon.

7

Page 10: Visible Surface Determination - Otago

L8:

Which side of a plane?

8

x

y

zp

(p - n).n = 0

n

Page 11: Visible Surface Determination - Otago

L8:

Plane Equation

(p - n).n = 0p.n - n.n = 0p = (x, y, z)n = (a, b, c)ax + by + cz - (a2 + b2 + c2) = 0ax + by + cz + d = 0

9

Page 12: Visible Surface Determination - Otago

L8:

For points p and q

if (p-n).n > 0 and (q-n).n > 0or if (p-n).n < 0 and (q-n).n < 0

p and q are on the same side

10

Page 13: Visible Surface Determination - Otago

L8:

BSP trees

11

Page 14: Visible Surface Determination - Otago

L8:

BSP trees

11

Page 15: Visible Surface Determination - Otago

L8:

BSP trees

11

Page 16: Visible Surface Determination - Otago

L8:

BSP trees

11

Page 17: Visible Surface Determination - Otago

L8:

BSP trees

11

Page 18: Visible Surface Determination - Otago

L8:

BSP trees

11

Page 19: Visible Surface Determination - Otago

L8:

Divide scene with a plane

• Everything on the same side of that plane as the eye is in front of everything else (from that eye’s view)

• Divide front and back with more planes• If necessary split polygons by planes

12

Page 20: Visible Surface Determination - Otago

L8:

• BSP trees are order n*log(n) in the number of polygons

• They are good for VR ‘walkthroughs’ because you only re-compute traversal when the eye crosses a separating plane

Efficiency

13

Page 21: Visible Surface Determination - Otago

L8:

Z-Buffer

• Record r,g,b and z (depth) for each pixel.• Process each polygon line by line and if

closer replace r,g,b,z in the buffer.

14

Page 22: Visible Surface Determination - Otago

L8:

Scan in screen space

15

Page 23: Visible Surface Determination - Otago

L8:

Finding the depth

• Plane equation is Ax + By + Cz + D = 0z = - (Ax + By + D)/C

• replace x by x+1z' = - (A(x+1) + By + D)/CΔz = z' - z = -A/C

• New z is found by adding a constant.16

Page 24: Visible Surface Determination - Otago

L8:

What about the lost z?

17

xyz1

1!0!0!00!1!0!00!0!1!00!0!1!0

=xyzz

≡ (x/z, y/z, 1)

Page 25: Visible Surface Determination - Otago

L8:

Perspective Transformation

• Preserve x', y'• Preserve straight lines• z' independent of x, y

18

Page 26: Visible Surface Determination - Otago

L8:

Perspective Transformation

• Preserve x', y'• Preserve straight lines• z' independent of x, y

18

Page 27: Visible Surface Determination - Otago

L8:

Perspective Transformation

• h = hither or near plane• v = projection plane

19

h

v

Page 28: Visible Surface Determination - Otago

L8:

Perspective Transformation

• h = hither or near plane• v = projection plane

19

h

v

Page 29: Visible Surface Determination - Otago

L8:

20

h vy,z

y'z'

yh'

yh

z-axis0

y' = yv/zyh' = yhv/h(v-z')/y' = v/yh'yh/(v-h) = y/(v-z)

Page 30: Visible Surface Determination - Otago

L8:

21

1. y' = yv/z2. yh' = yhv/h3. (v-z')/y' = v/yh'4. yh/(v-h) = y/(v-z)

Page 31: Visible Surface Determination - Otago

L8:

22

1. y' = yv/z2. yh' = yhv/h3. (v-z')/y' = v/yh'4. yh/(v-h) = y/(v-z)(v-z')/(yv/z) = v/(yhv/h)(v-z')/(yv/z) = v/((y(v-h)/(v-z))v/h)(v-z')/(v/z) = v/(((v-h)/(v-z))v/h)(v-z')z = vh/((v-h)/(v-z))

Page 32: Visible Surface Determination - Otago

L8:

23

(v-z')z = vh/((v-h)/(v-z))(v-z')z(v-h)/(v-z) = vh(v-z')z(v-h) = vh(v-z)v-z' = vh(v-z)/z(v-h)z' = v - vh(v-z)/z(v-h)z' = (vz(v-h) - vh(v-z))/z(v-h)z'z = (v2z - vzh - v2h + vhz)/(v-h)z'z = (v2z - v2h)/(v-h)z'z = v2z/(v-h) - v2h/(v-h)

Page 33: Visible Surface Determination - Otago

L8:

24

1 0 !0! 00 1 0! 00 0 1/(1-h)! !-h/(1-h)0 0 1! 0

z'z = v2z/(v-h) - v2h/(v-h)In the case where v = 1 (PHIGS GL?)z'z = z/(1-h) - h/(1-h)

Page 34: Visible Surface Determination - Otago

L8: 25

xyz1

xyz/(1-h)-h/(1-h)z

=

1 0 !0! 00 1 0! 00 0 1/(1-h)!-h/(1-h)0 0 1! 0

Page 35: Visible Surface Determination - Otago

L8:

Many appropriate matrices

26

• Similar matrices appear in many different forms• Different possible eye position, near plane and

view plane configurations• some books include an additional

transformation to screen coordinates• There is not one right answer!

Page 36: Visible Surface Determination - Otago

L8: 27

Page 37: Visible Surface Determination - Otago

L8: 28

Page 38: Visible Surface Determination - Otago

L8: 29

Page 39: Visible Surface Determination - Otago
Page 40: Visible Surface Determination - Otago
Page 41: Visible Surface Determination - Otago

L8: 32

Page 42: Visible Surface Determination - Otago

L8: 33

Page 43: Visible Surface Determination - Otago
Page 44: Visible Surface Determination - Otago

L8:

We move ontoRay Tracing

next...

35