visible surface determination
play

Visible Surface Determination CS418 Computer Graphics John C. Hart - PowerPoint PPT Presentation

Visible Surface Determination CS418 Computer Graphics John C. Hart Painters Algorithm Display polygons in back-to-front order Sort polygons by z-value -z Which vertex? O ( n log n ) Problems Quadtree Algorithm Sort


  1. Visible Surface Determination CS418 Computer Graphics John C. Hart

  2. Painter’s Algorithm • Display polygons in back-to-front order • Sort polygons by z-value -z – Which vertex? – O ( n log n ) • Problems…

  3. Quadtree Algorithm • Sort polygons • Subdivide screen until each region contains one or zero edges • Invented by John Warnock in 1969

  4. Quadtree Algorithm • Sort polygons • Subdivide screen until each region contains one or zero edges • Invented by John Warnock in 1969

  5. Quadtree Algorithm • Sort polygons • Subdivide screen until each region contains one or zero edges • Invented by John Warnock in 1969

  6. Quadtree Algorithm • Sort polygons • Subdivide screen until each region contains one or zero edges • Invented by John Warnock in 1969

  7. Quadtree Algorithm • Sort polygons • Subdivide screen until each region contains one or zero edges • Invented by John Warnock in 1969

  8. Z-Buffer -far -far -far -far Key Observation: Each pixel displays -far -far color of only one triangle, ignores -far everything behind it -far -far • Don’t need to sort triangles, just find -far -far for each pixel the closest triangle -far framebuffer zbuffer • Z-buffer: one fixed or floating point value per pixel • Algorithm: For each rasterized fragment ( x , y ) If z > zbuffer( x , y ) then framebuffer( x , y ) = fragment color zbuffer( x , y ) = z

  9. Z-Buffer -far -.1 -.2 -.3 Key Observation: Each pixel displays -.4 -.5 color of only one triangle, ignores -.6 everything behind it -.7 -.8 • Don’t need to sort triangles, just find -far -far for each pixel the closest triangle -far framebuffer zbuffer • Z-buffer: one fixed or floating point value per pixel • Algorithm: For each rasterized fragment ( x , y ) If z > zbuffer( x , y ) then framebuffer( x , y ) = fragment color zbuffer( x , y ) = z

  10. Z-Buffer -far -.1 -.2 -.3 Key Observation: Each pixel displays -.4 -.3 color of only one triangle, ignores -.1 everything behind it -.7 -.8 • Don’t need to sort triangles, just find -far -far for each pixel the closest triangle -far framebuffer zbuffer • Z-buffer: one fixed or floating point value per pixel • Algorithm: For each rasterized fragment ( x , y ) If z > zbuffer( x , y ) then framebuffer( x , y ) = fragment color zbuffer( x , y ) = z

  11. Z-Buffer -far -.1 -.2 -.3 • Get fragment z-values by interpolating -.4 -.3 z-values at vertices during rasterization -.1 -.7 -.8 • Perspective projection destroys -far -far z-values, setting them all to – d -far framebuffer zbuffer • Need a perspective distortion that preserves at least the ordering of z-values

  12. Normalized View Volume glFrustum(left,right,bottom,top,near,far) y y (-1,1,1) 1 z z (0,0,-far) y x x -1 x -1 1 z 1 -1                 Screen Clip Viewing World Model W2V Persp View Model         Coords Coords Coords Coords Coords                

  13. Perspective Projection screen y y view y clip -z z view d   x view          y z / d 1 x x y clip     view view view view         d z 1 y y y        view view view   view         z / d y 1 z z     view view view view y       clip      z view / d       d 1/ d 0 1 z / d view     1

  14. Perspective Distortion screen y y view y clip -z z view 1   x view    z   view       1 x x view view         y view y 1 y y           view view  view    y z clip  view            z z z view view view                       1 0 1 z view z   view     1

  15. Distorted z-Values z 1 z 2 - z if z 1 > z 2 then -  –  / z 1 > -  –  / z 2 1/- z curve -  –  / z 1 -  –  / z 2 -  -  –  / z   x view    z   view       1 x x view view         y view y 1 y y           view view  view    y z clip  view            z z z view view view                       1 0 1 z view z   view     1

  16. Normalized Perspective Distortion y y (-1,1,1) 1 z z (0,0,-far) y x x -1 x -1 1 z 1 -1      2 near right left     right left right left        2 near top bottom     top bottom top bottom        far near 2 far near      far near far near      1 0

  17. Hierarchical Z-Buffer -.2 -.3 -.3 • Invented by Ned Green in 1994 -.5 -.4 -.5 -.5 • Creates a MIP-map of the z-buffer -far -.6 -.7 -.7 – z-value equal to farthest z-value of -far -.8 -far -far its four children framebuffer hierarchical zbuffer • Before rasterizing a triangle… – Check z-value of its nearest vertex against z-value of the smallest quadtree cell containing the triangle – If z-test fails, then the entire triangle is hidden and need not be rasterized • Works best when displaying front-to-back

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend