![Page 1: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/1.jpg)
Computer Graphics
Hidden Surface Removal
![Page 2: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/2.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Rendering Pipeline
modelling ofgeometry
transformation intoworld coordinates
placement ofcameras andlight sources
projection
transformation into
camera coordinates
![Page 3: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/3.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Rendering Pipeline
modelling ofgeometry
transformation intoworld coordinates
placement ofcameras andlight sources
backfaceculling
projection
hidden surfaceremovale (hsr)
transformation into
camera coordinates
![Page 4: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/4.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Rendering Pipeline
modelling ofgeometry
transformation intoworld coordinates
placement ofcameras andlight sources
backfaceculling
projection
hidden surfaceremovale (hsr)
rasterization
transformation into
camera coordinates
![Page 5: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/5.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Hidden Surface Removal
![Page 6: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/6.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Hidden Surface Removal: Motivation
• goals:
– model parts independently processed
– at the same time: show front parts only
– avoid unnecessary processing
![Page 7: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/7.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Hidden Surface Removal: Motivation
• goals:
– model parts independently processed
– at the same time: show front parts only
– avoid unnecessary processing
![Page 8: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/8.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Hidden Surface Removal: Motivation
• goals:
– model parts independently processed
– at the same time: show front parts only
– avoid unnecessary processing
![Page 9: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/9.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Back Face Culling
• back faces (usually) not visible
• remove these: reduction of computation
• removal early in the pipeline
• reduction of polygon count by approx.
½ of the total polygon number
• computation: compare dot product of
surface normal with view direction with 0n
v n • v > 0
![Page 10: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/10.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Back Face Culling
• back faces (usually) not visible
• remove these: reduction of computation
• removal early in the pipeline
• reduction of polygon count by approx.
½ of the total polygon number
• computation: compare dot product of
surface normal with view direction with 0n
v n • v < 0
![Page 11: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/11.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Back Face Culling
• back face culling as HSR technique?
– (usually) not sufficient due to partial overlaps
of several objects in the scene
– would work reliably only if no overlaps occur
– e.g., if only one convex object is shown
![Page 12: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/12.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Back Face Culling
• back face culling as HSR technique?
– (usually) not sufficient due to partial overlaps
of several objects in the scene
– would work reliably only if no overlaps occur
– e.g., if only one convex object is shown
• order of depicted objects (overlapping)
with only back face culling still depends on
rendering sequence
idea for real HSR technique
![Page 13: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/13.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
HSR: Painter’s Algorithm
• new approach to hidden surface removal
(borrowed from van Gogh & co):
draw scene from back to front
• sort scene’s triangles from back to front
• start rendering triangles from the back
• problems:
– cyclic overlaps
– performance:
sorting is O(n log n)
![Page 14: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/14.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering
• idea:
– use advantages of Painter’s algorithm
(rendering from back to front)
– avoid its disadvantages (e.g., need to sort
& problems with cyclic triangles)
• realization by
– trading speed for memory usage
(memory is cheap [now anyway], time is not)
– trading speed for accuracy
(only compute what we really need/want)
![Page 15: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/15.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering
• introduce new pixel buffer: z-buffer
(in addition to the frame buffer for image)
• z-buffer stores z-values of pixels
![Page 16: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/16.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering
• treat each primitive (triangle) individually:
scene objects triangles pixels
• use z-buffer data to determine if a new
triangle is (partially) hidden or not
• at each time, the part of scene that has
been processed thus far is correctly
displayed
![Page 17: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/17.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Algorithm
• initialize z-buffer and frame buffer
• for each triangle
– project all vertices of the triangle
– interpolate z-values for each pixel (scan line)
– before shading a pixel, testif its z-value is closer to camera (i.e. higher)than the current z-buffer value
– if so: update z-buffer value and shade pixel
– otherwise: discard pixel and continue
• after scene processing z-buffer contains depth map of scene
![Page 18: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/18.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
![Page 19: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/19.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
![Page 20: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/20.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
![Page 21: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/21.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
![Page 22: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/22.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
![Page 23: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/23.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
![Page 24: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/24.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering: Example (shown by object)
In reality the z-buffering treats the model triangle by triangle, not object by object!
![Page 25: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/25.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
z-Buffering
• advantages
– can be implemented in hardware
– can process infinitely many primitives
– does not need sorting of primitives
(only need to know distance to camera)
– can handle cyclic and penetrating triangles
• disadvantages
– needs memory to keep all z-values
(image size @ 8bit or 16bit)
– cannot handle transparency properly
![Page 26: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/26.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Other HSR Algorithms
• hierarchical z-buffer
• Appel’s algorithm (for lines)
• Warnock's algorithm
• Octrees
• Binary Space Partitioning (BSP-trees)
• A-buffer (with anti-alising)
• etc.
![Page 27: Computer Graphics · Computer Graphics Tobias Isenberg HSR & Anti-Aliasing z-Buffering: Algorithm •initialize z-buffer and frame buffer •for each triangle –project all vertices](https://reader030.vdocuments.site/reader030/viewer/2022041106/5f0830b77e708231d420c98a/html5/thumbnails/27.jpg)
HSR & Anti-AliasingTobias IsenbergComputer Graphics
Hidden Surface Removal – Summary
• needed to reduce rendering effort
• backface culling
– remove all triangles that point away
– not sufficient as HSR
• z-buffering
– use of additional z-buffer
– pixel-based technique
– no polygon sorting needed
– only pixel accuracy