Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visible-surface Detection Computer Graphics Seminar MUM - 2005.

Similar presentations


Presentation on theme: "Visible-surface Detection Computer Graphics Seminar MUM - 2005."— Presentation transcript:

1 Visible-surface Detection Computer Graphics Seminar MUM - 2005

2 Agenda Back-face detection Z-buffer Depth-sorting BSP Trees

3 Back-face detection Visible faces have normal vectors pointing towards the observer N V

4 Back-face detection If the viewing direction is parallel to the Z axis and. If the normal components are A, B, C, then face is visible if N V X Y Z

5 Depth-buffer (Z-Buffer) At each pixel, only the surface that is closest to the observer is drawn. X Y Z S1S1 S2S2

6 Depth-buffer (Z-Buffer) Algorithm: Two buffers are needed: depth and color. –Initialize the buffers: depth(x,y)=0, color(x,y)=I background –For each position on each polygon surface calculate z for each (x, y) position if z > depth(x,y){ depth(x,y)=z color(x,y) = I surf }

7 Depth-buffer (Z-Buffer) To speed computations: The z position is: And for the next x position it is: Therefore:

8 Depth-sorting method Also called painter’s algorithm: Sort surfaces according to their distance from the viewer (take the smallest z value at each surface) Render more distant surface before nearer ones Start with the most distance surface and compare with all others. If there are no conflicts, render it. But… conflicts may arise

9 Depth-sorting method Conflict: –The smallest z in S is less than the smaller z in S´, but S´ has to be rendered first (why?) –In this particular case, S and S’ need to be reordered X Z S S´

10 There is NO conflict when…: (S can actually be rendered before S’) when: 1. Projections on the Z axis do not overlap: X Z S S´

11 There is NO conflict when…: 2. The bounding boxes of S and S´ in the XY plane do not overlap. X Z S S´

12 There is NO conflict when…: 3. Surface S is completely behind surface S´, relative to the viewing position X Z S S´

13 There is NO conflict when…: 4. Surface S´ is completely in front of surface S, relative to the viewing position X Z S S´

14 If there is conflict: S and S´ are inverted in the sorted list Repeat the tests for S’ and all other surfaces in the list If a surface is reordered to a farther depth position, it is marked, in order to avoid an infinite loop

15 BSP Trees BSP: Binary Space Partitioning Useful when the view reference point moves, but the objects are at fixed positions The space is divided by several planes Relationships among objects are maintained in a binary tree It may be necessary to split a polygon (A) A B C D P1 P2 ACBD P1 P2 frontback front back front back front back

16 BSP trees Objects are rendered in the order back to front, relative to the view point. Example 1: –View point in front of P1 and P2: D, B, C, A. –View point in front of P1 and behind P2: B, D, A, C.


Download ppt "Visible-surface Detection Computer Graphics Seminar MUM - 2005."

Similar presentations


Ads by Google