Visible Surface Determination CS418 Computer Graphics John C. Hart - - PowerPoint PPT Presentation

visible surface determination
SMART_READER_LITE
LIVE PREVIEW

Visible Surface Determination CS418 Computer Graphics John C. Hart - - PowerPoint PPT Presentation

Visible Surface Determination CS418 Computer Graphics John C. Hart Painters Algorithm Painters Algorithm Painters Algorithm Painters Algorithm Painters Algorithm Painters Algorithm Backface Culling Q: How does Bob


slide-1
SLIDE 1

Visible Surface Determination

CS418 Computer Graphics John C. Hart

slide-2
SLIDE 2

Painter’s Algorithm

slide-3
SLIDE 3

Painter’s Algorithm

slide-4
SLIDE 4

Painter’s Algorithm

slide-5
SLIDE 5

Painter’s Algorithm

slide-6
SLIDE 6

Painter’s Algorithm

slide-7
SLIDE 7

Painter’s Algorithm

Backface Culling

  • Q: How does Bob Ross paint the trees so

fast?

  • A: He doesn’t paint the back sides of the

trees.

  • Cull triangles that face away from the

viewer v ⋅ n(view) ≤ 0 v

slide-8
SLIDE 8

Painter’s Algorithm

  • Display polygons in

back-to-front order

slide-9
SLIDE 9

Painter’s Algorithm

  • Display polygons in

back-to-front order

slide-10
SLIDE 10

Painter’s Algorithm

  • Display polygons in

back-to-front order

slide-11
SLIDE 11

Painter’s Algorithm

  • Display polygons in

back-to-front order

  • Sort polygons by z-value

– O(n log n) – Which vertex?

slide-12
SLIDE 12

Painter’s Algorithm

  • Display polygons in

back-to-front order

  • Sort polygons by z-value

– O(n log n) – Which vertex?

  • Problems…
slide-13
SLIDE 13

Quadtree Algorithm

  • Subdivide screen until each region is

simple (e.g. one polygon) or is a pixel

  • Invented by

John Warnock in 1969

slide-14
SLIDE 14

Z-Buffer

Key Observation: Each pixel displays color of only one triangle, ignores everything behind it

  • Don’t need to sort triangles, just find for each pixel

the closest triangle

  • Z-buffer: one fixed or floating point value per pixel
  • Algorithm:

For each rasterized fragment (x,y) If z > zbuffer(x,y) then framebuffer(x,y) = fragment color zbuffer(x,y) = z

  • far
  • far
  • far
  • far
  • far
  • far
  • far
  • far
  • far
  • far
  • far
  • far

framebuffer zbuffer

slide-15
SLIDE 15

Z-Buffer

Key Observation: Each pixel displays color of only one triangle, ignores everything behind it

  • Don’t need to sort triangles, just find for each pixel

the closest triangle

  • Z-buffer: one fixed or floating point value per pixel
  • Algorithm:

For each rasterized fragment (x,y) If z > zbuffer(x,y) then framebuffer(x,y) = fragment color zbuffer(x,y) = z

  • far
  • .1
  • .2
  • .3
  • .4
  • .5
  • .6
  • .7
  • .8
  • far
  • far
  • far

framebuffer zbuffer

slide-16
SLIDE 16

Z-Buffer

Key Observation: Each pixel displays color of only one triangle, ignores everything behind it

  • Don’t need to sort triangles, just find for each pixel

the closest triangle

  • Z-buffer: one fixed or floating point value per pixel
  • Algorithm:

For each rasterized fragment (x,y) If z > zbuffer(x,y) then framebuffer(x,y) = fragment color zbuffer(x,y) = z

  • far
  • .1
  • .2
  • .3
  • .4
  • .3
  • .1
  • .7
  • .8
  • far
  • far
  • far

framebuffer zbuffer

slide-17
SLIDE 17

Z-Buffer

  • Get fragment z-values by interpolating z-values at

vertices during rasterization

  • Perspective projection destroys

z-values, setting them all to –d

  • Need a perspective distortion that preserves at least

the ordering of z-values

  • far
  • .1
  • .2
  • .3
  • .4
  • .3
  • .1
  • .7
  • .8
  • far
  • far
  • far

framebuffer zbuffer

slide-18
SLIDE 18

Normalized View Volume

x y z x y z

W2V           Model           View           Persp          

Model Coords World Coords Viewing Coords Clip Coords Screen Coords

(0,0,-far) (-1,1,1) z 1

  • 1

x 1

  • 1

y

  • 1

1

slide-19
SLIDE 19

Perspective Projection

screen

  • z

y zview yview d yclip

clip view view view clip view /

y y d z y y z d = − = −

view view view view view view view view view view view

/ 1 1 / 1 / 1/ 1 1 x z d x x y y y z d z z d z d d     −                       = ≡   −               − − −            

slide-20
SLIDE 20

Perspective Distortion

screen

  • z

y zview yview 1 yclip

view clip view

y y z = −

view view view view view view view view view view view view

1 1 1 1 1 x z x x y y y z z z z z α β α β β α     −                         − = ≡   +               − − − −              

slide-21
SLIDE 21

Distorted z-Values

view clip view

y y z = −

view view view view view view view view view view view view

1 1 1 1 1 x z x x y y y z z z z z α β α β β α     −                         − = ≡   +               − − − −              

  • z
  • α – β/z
  • α

1/-z curve z1 z2

  • α – β/z2
  • α – β/z1

if z1 > z2 then

  • α – β/z1 > -α – β/z2
slide-22
SLIDE 22

Normalized Perspective Distortion

2 near right left right left right left 2 near top bottom top bottom top bottom far near 2 far near far near far near 1 − × +     − −   − × +     − −   + × ×   −   − −   −  

x y z x y z

(0,0,-far) (-1,1,1) z 1

  • 1

x 1

  • 1

y

  • 1

1

slide-23
SLIDE 23

Hierarchical Z-Buffer

  • Invented by Ned Green in 1994
  • Creates a MIP-map of the z-buffer

– z-value equal to farthest z-value of its four children

  • Before rasterizing a triangle…

– Check z-value of its nearest vertex against z-value of the smallest quadtree cell containing the triangle – If z-test fails, then the entire triangle is hidden and need not be rasterized

  • Works best when displaying

front-to-back

  • .2
  • .3
  • .4
  • .5
  • .6
  • .7
  • .8
  • far

framebuffer hierarchical zbuffer

  • .3
  • .5
  • .7
  • far
  • .5
  • far
  • far