1 / 17

Visibility (hidden surface removal)

Visibility (hidden surface removal). A correct rendering requires correct visibility calculations Correct visibility – when multiple opaque polygons cover the same screen space, only the front most one is visible (remove the hidden surfaces). Correct visibility. wrong visibility.

kgray
Download Presentation

Visibility (hidden surface removal)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visibility (hidden surface removal) • A correct rendering requires correct visibility calculations • Correct visibility – when multiple opaque polygons cover the same screen space, only the front most one is visible (remove the hidden surfaces) Correct visibility wrong visibility

  2. Visibility (hidden surface removal) • Goal: determine which objects are visible to the eye • Determine what colors to use to paint the pixels • Active research subject - lots of algorithms have been proposedin the past (and is still a hot topic)

  3. Visibility • Where is visiblity performed in the graphics pipeline? v1, m1 modeling and viewing per vertex lighting projection v3, m3 v2, m2 viewport mapping interpolate vertex colors Rasterization texturing Shading visibility clipping Display

  4. OpenGL - Image Space Approach • Determine which of the n objects is visible to each pixel on the image plane for (each pixel in the image) { determine the object closest to the pixel draw the pixel using the object’s color }

  5. Image Space Approach – Z-buffer • Method used in most of graphics hardware (and thus OpenGL): Z-buffer algorithm • Basic idea: • rasterize every input polygon • For every pixel in the polygon interior, calculate its corresponding Z value (by interpolation) • Choose the color of the polygon whose z value is the closest to the eye to paint the pixel.

  6. Z (depth) buffer algorithm • How to choose the polygon that has the closet Z for a given pixel? • Initialize (clear) every pixel in the z buffer to a very large negative value (remember object in front of eye always negative Z values) • Then run the following loop:

  7. Z (depth) Buffer Algorithm For each polygon { for each pixel (x,y) inside the polygon projection area { if (Z_polygon_pixel(x,y) > depth_buffer(x,y) ) { depth_buffer(x,y) = Z_polygon_pixel(x,y); color_buffer(x,y) = polygon color at (x,y) } } }

  8. Z buffer example Z = -.5 Z = -.3 eye Final image Top View

  9. Z buffer example (2) Step 1: Initialize the depth buffer -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999 -999

  10. Z = -.5 -999 -999 -999 -999 Z = -.3 -999 -999 -999 -999 -.5 -.5 -999 -999 -.5 -.5 -999 -999 eye Z buffer example (3) Step 2: Draw the blue polygon (assuming the OpenGL program draws blue polyon first – the order does not affect the final result any way).

  11. Z = -.5 -999 -999 -999 -999 Z = -.3 -999 -.3 -.3 -999 -.5 -.3 -.3 -999 -.5 -.5 -999 -999 eye Z buffer example (4) Step 3: Draw the yellow polygon

  12. OpenGL functions • glEnable(GL_DEPTH_TEST) • glDepthFunc(GLenum fun): • GL_NEVER; GL_ALWAYS; GL_LESS; GL_LEQUAL; GL_EQUAL; GL_GEQUAL; GL_GREATER; GL_NOTEQUAL; • Default: GL_LESS • Need to remember to initialize the depth buffer in GLUT • glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH); • glDepthMask(GLboolean flag) • Whether to write to the depth buffer or not • GL_TRUE or GL_FALSE • Default is GL_TRUE once gl depth test is enabled

  13. Other Approaches • Not implemented by most of the graphics hardware • Back face culling (supported by OpenGL) • View frustum culling • Ray tracing • Painter’s algorithm • And many more …

  14. N V Back Face Culling • Back face culling – remove the back faces of a closed opaque object) • How to detect back faces?

  15. View-Frustum Culling • Remove objects that are outside the viewing frustum Done by application

  16. Ray Tracing • Ray tracing is another example of image space method • Ray tracing: Cast a ray from eye through each pixel to the world. Calculate ray-object intersection. Topic of 681

  17. Painter’s Algorithm • A depth sorting method • Surfaces are sorted in the order of decreasing depth • Surfaces are drawn in the sorted order, and overwrite the pixels in the frame buffer • Two problems: • It can be nontrivial to sort the surfaces • It can be no solution for the sorting order

More Related