INFOGR – Computer Graphics
- J. Bikker - April-July 2015 - Lecture 7: “Visibility”
Welcome! INFOGR Lecture 7 Visibility 2 Perpendicular Vectors - - PowerPoint PPT Presentation
INFOGR Computer Graphics J. Bikker - April-July 2015 - Lecture 7: Visibility Welcome! INFOGR Lecture 7 Visibility 2 Perpendicular Vectors perpendicular to : ,
Perpendicular Vectors perpendicular to 𝑦 𝑧 : −𝑧 𝑦 , 𝑧 −𝑦 Calculating a vector perpendicular to 𝑦 𝑧 𝑨 : −𝑧 𝑦 𝑨
*additional rules apply
Verify: 𝑦 𝑧 𝑨 ∙ −𝑧 𝑦 = 𝑦 ∗ −𝑧 + 𝑧 ∗ 𝑦 + 𝑨 ∗ 0 = 0 .
−𝑧 𝑦 INFOGR – Lecture 7 – “Visibility” 2
Rendering – Functional overview
translating / rotating meshes
calculating 2D screen positions
determining affected pixels
calculate color per affected pixel Transform Project Rasterize Shade meshes vertices vertices fragment positions pixels
Animation, culling, tessellation, ... Postprocessing
INFOGR – Lecture 7 – “Visibility” 4
determining affected pixels Questions:
affected pixel? How do we efficiently determine visibility of a pixel? Transform Project Rasterize Shade meshes vertices vertices fragment positions pixels
Animation, culling, tessellation, ... Postprocessing
INFOGR – Lecture 7 – “Visibility” 5
Too far away to draw Part of the tree is off-screen Torso closer than ground City obscured by tree Tree requires little detail Tree between ground & sun
Old-skool depth sorting: Painter’s Algorithm
Advantage:
Problems:
INFOGR – Lecture 7 – “Visibility” 7
Overdraw: Inefficiency caused by drawing multiple times to the same pixel. INFOGR – Lecture 7 – “Visibility” 8
Correct order: BSP root INFOGR – Lecture 7 – “Visibility” 9
Correct order: BSP root
full empty
INFOGR – Lecture 7 – “Visibility” 10
Correct order: BSP root
full empty
INFOGR – Lecture 7 – “Visibility” 11
Correct order: BSP root
full empty
INFOGR – Lecture 7 – “Visibility” 12
Correct order: BSP root
full empty
INFOGR – Lecture 7 – “Visibility” 13
Correct order: BSP root
full empty
INFOGR – Lecture 7 – “Visibility” 14
Correct order: BSP root
full empty
Sorting by BSP traversal: Recursively
INFOGR – Lecture 7 – “Visibility” 15
Draw order using a BSP:
But:
INFOGR – Lecture 7 – “Visibility” 16
Z-buffer A z-buffer stores, per screen pixel, a depth value. The depth of each fragment is checked against this value:
The z-buffer requires:
possibly a write.
INFOGR – Lecture 7 – “Visibility” 17
Z-buffer What is the best representation for depth in a z-buffer?
𝑔𝑜 𝑨 ) (more accurate nearby);
INFOGR – Lecture 7 – “Visibility” 19
Z-buffer optimization In the ideal case, the nearest fragment for a pixel is drawn first:
The ideal case can be approached by using Painter’s to ‘pre-sort’.
INFOGR – Lecture 7 – “Visibility” 20
‘Z-fighting’: Occurs when two polygons have almost identical z-values. Floating point inaccuracies during interpolation will cause unpleasant patterns in the image.
INFOGR – Lecture 7 – “Visibility” 21
Stuff that is too far to draw Part of the tree is off-screen Torso closer than ground City obscured by tree Tree requires little detail Tree between ground & sun
Clipping Many triangles are partially off-screen. This is handled by clipping them. Sutherland-Hodgeman clipping: Clip triangle against 1 plane at a time; Emit n-gon (0, 3 or 4 vertices).
INFOGR – Lecture 7 – “Visibility” 24
Sutherland-Hodgeman Input: list of vertices Algorithm: Per edge with vertices v0 and v1:
where C is the intersection point of the edge and the plane. Output: list of vertices, defining a convex n-gon.
1 2 in
Vertex 0 Vertex 1 Vertex 1 Intersection 1 Vertex 2 Intersection 2 Vertex 0 INFOGR – Lecture 7 – “Visibility” 25
Sutherland-Hodgeman Calculating the intersections with plane 𝑏𝑦 + 𝑐𝑧 + 𝑑𝑨 + 𝑒 = 0: 𝑒𝑗𝑡𝑢𝑤 = 𝑤 ∙ 𝑏 𝑐 𝑑 + 𝑒 𝑔 = |𝑒𝑗𝑡𝑢𝑤0| |𝑒𝑗𝑡𝑢𝑤0| + |𝑒𝑗𝑡𝑢𝑤1| 𝐽 = 𝑤0 + 𝑔(𝑤1 − 𝑤0)
v0 v1
I
After clipping, the input n-gon may have at most 1 extra vertex. We may have to triangulate it: 0,1,2,3,4 0, 1, 2 + 0, 2, 3 + 0, 3, 4. INFOGR – Lecture 7 – “Visibility” 26
Guard bands To reduce the number of polygons that need clipping, some hardware uses guard bands : an invisible band of pixels outside the screen.
discarded, even if they touch the guard band;
in the guard band are drawn without clipping;
partially outside the guard band are clipped.
INFOGR – Lecture 7 – “Visibility” 27
Sutherland-Hodgeman Clipping can be done against arbitrary planes.
INFOGR – Lecture 7 – “Visibility” 28
Stuff that is too far to draw Part of the tree is off-screen Torso closer than ground City obscured by tree Tree requires little detail Tree between ground & sun
Only rendering what’s visible: “Performance should be determined by visible geometry, not overall world size.”
geometry outside frustum
geometry
more detailed than strictly necessary INFOGR – Lecture 7 – “Visibility” 33
Culling Observation: 50% of the faces of a cube are not visible. On average, this is true for all meshes. Culling ‘backfaces’: Triangle: 𝑏𝑦 + 𝑐𝑧 + 𝑑𝑨 + 𝑒 = 0 Camera: 𝑦, 𝑧, 𝑨 Visible: fill in camera position in plane equation. 𝑏𝑦 + 𝑐𝑧 + 𝑑𝑨 + 𝑒 > 0: visible. Cost
1 dot dot pr product pe per r tri triangle. INFOGR – Lecture 7 – “Visibility” 34
Culling Observation: If the bounding sphere of a mesh is outside the view frustum, the mesh is not visible. But also: If the bounding sphere of a mesh intersects the view frustum, the mesh may be not visible. View frustum culling is typically a conservative test: we sacrifice accuracy for efficiency. Cost
1 dot dot pr product pe per r mes esh. INFOGR – Lecture 7 – “Visibility” 35
Culling Observation: If the bounding sphere over a group of bounding spheres is outside the view frustum, a group of meshes is invisible. We can store a bounding volume hierarchy in the scene graph:
they represent;
child nodes. Cost
1 dot dot pr product pe per r sce cene gr grap aph subtree. INFOGR – Lecture 7 – “Visibility” 36
INFOGR – Lecture 7 – “Visibility” 37 Culling Observation: If a grid cell is outside the view frustum, the contents of that grid cell are not visible. Cost
0 for
grid cel cells.
Indoor visibility: Portals Observation: if a window is invisible, the room it links to is invisible. INFOGR – Lecture 7 – “Visibility” 38
Visibility determination Coarse:
Finer:
Finest:
INFOGR – Lecture 7 – “Visibility” 50
Time for your examination. Where: EDUC-GAMMA When: Thursday, May 21st, 2015, at 13.30 Duration: Two hours, three for dyslexia Contents:
What to study:
Need extra time? Entitled to it? Notify me! INFOGR – Lecture 7 – “Visibility” 52
INFOGR – Lecture 7 – “Visibility”