Trang 4 Why hidden surface removal■ A correct rendering requires correct visibility calculations■ When multiple opaque polygons cover the same screen space, only the closest one is visib
Trang 3Overview
Trang 4Why hidden surface removal
■ A correct rendering requires correct visibility
calculations
screen space, only the closest one is visible (remove the other hidden surfaces)
wrong visibility correct visibility
Trang 5Why hidden surface removal
resources rendering primitives which don’t
contribute to the final image
CPU cycles
□ e.g Illumination
Trang 6Hidden surface removal
Trang 7Painter’s algorithm
Trang 8Painter’s algorithm
polygons “paint” over farther ones
first
Trang 9Painter’s algorithm: Problem
determination
□ see image at right
Trang 10Painter’s algorithm: Problem
need to segment the
triangles and make
them sortable
Trang 11Z Buffer
Trang 13□ For every pixel in the polygon interior, calculate its corresponding z value (by interpolation)
□ Compare the depth value with the closest value from a different polygon (largest z) so far
□ Paint the pixel with the color of the polygon if it is closer
Trang 14Z-Buffer example
Trang 15−1.0 −1.0 −1.0 −1.0
−1.0 −1.0 −1.0 −1.0
−1.0 −1.0 −1.0 −1.0
−1.0 −1.0 −1.0 −1.0 Step 1: Initialise the depth buffer
Trang 16Step 2: Draw the blue polygon (order does not affect the final result)
Trang 17Step 2: Draw the yellow polygon
- If the depth value is greater than corresponding value in z-buffer, that pixel is coloured and the value in z-buffer will be updated
Trang 18Step 2: Draw the red polygon
- Similarly, if the depth value is greater than corresponding value
in z-buffer, that pixel is coloured and the value in z-buffer will be updated
Trang 19□ Memory for z-buffer is now not expensive
Trang 20Disadvantages
Trang 21BSP Tree
Trang 22BSP Tree
□ Only draw those close to the viewer
□ Similar to the painter’s algorithm, but doing a detailed scene analysis
□ Suitable for a scene below
Trang 23BSP Tree algorithm
(relative to normal) and back
half-spaces
both sides
each side – split scene again
side until each node contains
only 1 polygon
3
4 1
2
5
View of scene from above
Trang 24BSP Tree algorithm
(relative to normal) and back
4 5b
back front
3
4 1
2
5 5a
5b
Trang 25BSP Tree algorithm
each side & split scene again
3
4 1
2
5 5a
5b
3
4 5b
back front
2
1 5a
front
Trang 26BSP Tree algorithm
side until each node contains
only 1 polygon
3
4 1
2
5 5a
5b
3 backfront
2
1 5a
front
5b 4
Trang 27BSP Tree displaying
priority list for an arbitrary viewpoint
□ Back-to-front: same as painter’s algorithm
□ Front-to-back: more efficient
Trang 28BSP Tree displaying
Back to front
□ If viewer is in front half-space, draw polygons behind root first, then the root polygon, then polygons in front.
□ If viewer is in back half-space, draw polygons in front of root first, then the root polygon, then polygons behind.
□ If polygon is on edge – either can be used.
□ Recursively descend the tree
■ If eye is in rear half-space for a polygon can back face cull
Trang 294 1
2
5 5a
5b
3 backfront
2
1 5a
front
5b 4
Trang 30in
Trang 32Use of BSP Tree
□ Need to produce a well balanced tree
□ Intersecting polygon splitting may also be costly
■ Cheap to check visibility once tree is set up
→Efficient when objects don’t change very often in the scene.
■ Render the static objects first (front-to-back)
with the Z-buffer on
Trang 33Architectural scenes
Trang 34Portal culling
Trang 35Portal culling
□ Nodes: Cells (or rooms)
□ Edges: Portals (or doors)
□ Potentially visible set
2 If portal to the next room is visible, render the
connected room in the portal region
A B D
A
B C
D
E F
G
Trang 36Additional techniques
Trang 37Back face culling
other direction
If negative – cull, since normal points away from viewer
■ Or if N.V > 0 we are viewing the back face so polygon is obscured
Trang 38are mapped to pixels
□ Painter’s algorithm, BSP trees, portal culling
vertices are rasterized
□ Z-buffering
▫ Z-buffer is easy to implement on hardware and is
a standard technique for hidden surface removal
▫ Need to combine it with an object-based method especially when there are too many polygons
Trang 39Any questions?
Trang 40Lecture notes provided by School of Information and
Communication Technology, Hanoi University of Science and
Technology.
Composed by Huynh Quyet Thang, Le Tan Hung, Trinh Thanh
Trung and others
Edited by Trinh Thanh Trung
Special thanks to all the people who made and released these awesome resources for free:
■ Presentation template by SlidesCarnival
■ Photographs by Death to the Stock Photo ( license )
■ Diverse device hand photos by Facebook Design Resources