visible surface determination
DESCRIPTION
Visible Surface Determination. CS418 Computer Graphics John C. Hart. Painter’s Algorithm. Display polygons in back-to-front order Sort polygons by z-value Which vertex? O ( n log n ) Problems…. -z. Quadtree Algorithm. Sort polygons - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/1.jpg)
Visible Surface Determination
CS418 Computer Graphics
John C. Hart
![Page 2: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/2.jpg)
Painter’s Algorithm
• Display polygons inback-to-front order
• Sort polygons by z-value
– Which vertex?
– O(n log n)
• Problems…
-z
![Page 3: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/3.jpg)
Quadtree Algorithm
• Sort polygons
• Subdivide screen until each region contains one or zero edges
• Invented by John Warnock in 1969
![Page 4: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/4.jpg)
Quadtree Algorithm
• Sort polygons
• Subdivide screen until each region contains one or zero edges
• Invented by John Warnock in 1969
![Page 5: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/5.jpg)
Quadtree Algorithm
• Sort polygons
• Subdivide screen until each region contains one or zero edges
• Invented by John Warnock in 1969
![Page 6: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/6.jpg)
Quadtree Algorithm
• Sort polygons
• Subdivide screen until each region contains one or zero edges
• Invented by John Warnock in 1969
![Page 7: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/7.jpg)
Quadtree Algorithm
• Sort polygons
• Subdivide screen until each region contains one or zero edges
• Invented by John Warnock in 1969
![Page 8: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/8.jpg)
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
fram
ebuf
fer
zbuf
fer
![Page 9: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/9.jpg)
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
fram
ebuf
fer
zbuf
fer
![Page 10: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/10.jpg)
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
fram
ebuf
fer
zbuf
fer
![Page 11: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/11.jpg)
Z-Buffer
• Get fragment z-values by interpolating z-values at vertices during rasterization
• Perspective projection destroysz-values, setting them all to –d
• Need a perspective distortion that preserves at least the ordering ofz-values
-far-.1-.2-.3-.4-.3-.1-.7-.8-far-far-far
fram
ebuf
fer
zbuf
fer
![Page 12: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/12.jpg)
Normalized View Volume
x
y
z
x
y
z
W2V
Model
View
Persp
ModelCoords
WorldCoords
ViewingCoords
ClipCoords
ScreenCoords
(left,top,-near)
(right,bottom,-near)
(0,0,-far)
glFrustum(left,right,bottom,top,near,far)
(-1,1,1)
z1 -1
x
1
-1
y
-1
1
![Page 13: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/13.jpg)
Perspective Projection
screen
-z
y
zview
yview
d
yclip
clip view
view
viewclip
view /
y y
d z
yy
z d
view
viewviewview
viewview view
viewviewview
view
/1
1
/1
/1/ 0 1
1
x
z dxx
yy y
z dzz
dz dd
![Page 14: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/14.jpg)
Perspective Distortion
screen
-z
y
zview
yview
1
yclip
viewclip
view
yy
z
view
viewviewview
viewviewview
viewviewview
viewview
1
1
1 0 1
1
x
zxx
yyy
zzz
zz
![Page 15: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/15.jpg)
Distorted z-Values
viewclip
view
yy
z
view
viewviewview
viewviewview
viewviewview
viewview
1
1
1 0 1
1
x
zxx
yyy
zzz
zz
-z
- – /z
-
1/-z curve
z1 z2
- – /z2
- – /z1
if z1 > z2 then - – /z1 > - – /z2
![Page 16: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/16.jpg)
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 near1 0
x
y
z
x
y
z
(left,top,-near)
(right,bottom,-near)
(0,0,-far)
(-1,1,1)
z1 -1
x
1
-1
y
-1
1
![Page 17: Visible Surface Determination](https://reader036.vdocument.in/reader036/viewer/2022070402/568138cf550346895da0893b/html5/thumbnails/17.jpg)
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 displayingfront-to-back
-.2-.3-.4-.5-.6-.7-.8-far
fram
ebuf
fer
hierarchical zbuffer
-.3
-.5
-.7
-far
-.5
-far
-far