![Page 1: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/1.jpg)
Hidden Surface Removal
April 30, 2007
![Page 2: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/2.jpg)
Hidden Surface Removal
• Object-space algorithms:– Back-face culling (removal)– Depth sorting and Painter’s algorithm
• Image-space algorithm:– Z Buffer!– Fast, but requires more memory.
![Page 3: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/3.jpg)
Back-Face Culling
• For convex objects, we can’t see the back faces.
• But, how do we determine the back faces?
![Page 4: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/4.jpg)
![Page 5: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/5.jpg)
![Page 6: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/6.jpg)
![Page 7: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/7.jpg)
Painter’s Algorithm
• Draw from back to front.
• No solution for:– Cyclic ordering– Intersecting surfaces
![Page 8: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/8.jpg)
Z Buffer
• At each pixel, store the Z of the front-most surface.
• If the new Z is larger, it’s occluded.
• If the new Z is smaller, then:– Draw the new surface– Update the Z
![Page 9: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/9.jpg)
Other Algorithms
• Scan-line algorithm: See Section 7.11 of Ed Angel’s book (4th Ed).
• For more advanced research in this area, see:– Chen and Wang, SIGGRAPH 1996.– Snyder and Lengyel, SIGGRAPH 1998.
![Page 10: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/10.jpg)
from the previous lecture…
![Page 11: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/11.jpg)
Projection Matrix
1
0100
*200
02
0
002
'
'
'
z
y
x
nearfar
nearfar
nearfar
nearfarbottomtop
bottomtop
bottomtop
farleftright
leftright
leftright
far
w
wz
wy
wx
![Page 12: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/12.jpg)
Range of Z
• If Z = near, what is Z’?-1
• If Z = far, what is Z’?1
• Does Z’ change linearly with Z?– No!– Z’ = wZ’ / w = (a*Z+b) / Z = a + b/Z
![Page 13: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/13.jpg)
Z Resolution
• Since screen Z’ is expressed in the form of a+b/Z, most of the Z resolution is used up by the Z’s closer to the near plane.
• So, what does this mean?
• You shouldn’t set zNear to be very close to the eye position.
![Page 14: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/14.jpg)
-1.1-0.9-0.7-0.5-0.3-0.10.10.30.50.70.91.1
0 200 400 600 800 1000-1.1-0.9-0.7-0.5-0.3-0.10.10.30.50.70.91.1
0 200 400 600 800 1000
Near=10Far=1000
Near=100Far=1000
Notice the change in the range of Z after transformation (in NDC space) for the original Z (in eye space) between 200 and 400 (marked by the Red boxes).
![Page 15: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/15.jpg)
Why Not Linear?
• To make it linear, we will have to make WZ’ = a*Z2 + bZ (so that Z’ = WZ’/W = a*Z + b)
• But that’s impossible with the perspective matrix…
![Page 16: Hidden Surface Removal April 30, 2007. Hidden Surface Removal Object-space algorithms: –Back-face culling (removal) –Depth sorting and Painter’s algorithm](https://reader034.vdocument.in/reader034/viewer/2022051401/56649d4e5503460f94a2e8c1/html5/thumbnails/16.jpg)
Linear Z Buffer or W Buffer
• Wait! Why is linear Z impossible under perspective projection? Can’t we simply ignore the divide-by-w step for Z?
• Yes, but we no longer have the nice math of the homogeneous coordinates
?'
'
'
,
1
'
'
'
'
'
'
w
z
wy
wx
z
y
x
w
wz
wy
wx
Division by w