1 / 14

Visible surface determination

Visible surface determination. Problem outline.

sbahe
Télécharger la présentation

Visible surface determination

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. Visible surface determination

  2. Problem outline • Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are visible, so that we do not needlessly calculate and draw surfces, which will not ultimately be seen by the viewer, or which might confuse the viewer.

  3. Simple example… With all lines drawn, it is not easy to determine the front and back of the box. Is this the front face of the cube or the rear?

  4. ? ? Simple example…

  5. Approaches • There are 2 fundamental approaches to the problem. • Object space • Image space

  6. Object space • Object space algorithms do their work on the objects themselves before they are converted to pixels in the frame buffer. The resolution of the display device is irrelevant here as this calculation is done at the mathematical level of the objects • Pseudo code… • for each object a in the scene • determine which parts of object a are visible • draw these parts in the appropriate colour • Involves comparing the polygons in object a to other polygons in a and to polygons in every other object in the scene.

  7. Image space • Image space algorithms do their work as the objects are being converted to pixels in the frame buffer. The resolution of the display device is important here as this is done on a pixel by pixel basis. • Pseudo code… • for each pixel in the frame buffer • determine which polygon is closest to the viewer at that pixel location • color the pixel with the color of that polygon at that location

  8. Image Space Approach • Look at each projector (nm for an nxm frame buffer) and find closest of k polygons • Complexity O(nmk) • Two techniques: • Ray tracing • Z-buffer

  9. Algorithms • Object space • Back-face culling • Image space • z-buffer algorithm • Hybrid • Depth-sort

  10. z-Buffer Algorithm • Use a buffer called the Z (or depth) buffer to store the depth of the closest object at each pixel found so far • As we render each polygon, compare the depth of each pixel to depth in Z buffer • If less, place shade of pixel in color buffer and update Z buffer

  11. Z-buffer algorithm • The z-buffer or depth-buffer is one of the simplest visible-surface algorithms. • Z-buffering is an image-space algorithm, an involves the use of a (surprisingly) z-buffer, to store the depth, or z-value of each pixel. • All of the elements of the z-buffer are initially set to be 'very far away.' Whenever a pixel colour is to be changed the depth of this new colour is compared to the current depth in the z-buffer. If this colour is 'closer' than the previous colour the pixel is given the new colour, and the z-buffer entry for that pixel is updated as well. Otherwise the pixel retains the old colour, and the z-buffer retains its old value.

  12. Two buffer areas required: • depth buffer – used to store depth values for each(x,y) position • Refresh buffer - stores the intensity values for each position Algo: • Initialize depth buffer & refresh buffer for positions (x,y), Depth(x,y)=0, refresh(x,y)=Ibackgnd 2. For each position on surface , compare depth values to previously stored values in the depth buffer to determine visibility. • Calculate the depth z for each(x,y) position on the surface. • If z >depth(x,y),then set depth(x,y)= z refresh(x,y)=Isurf(x,y) whereIbackgndvalue for backgnd intensity Isurf(x,y) is the projected intensity value for surface @ pixel position (x,y).

  13. Depth value for surface position (x,y) are calculated from the equation : Z= - Ax–By-D C

  14. Z-buffer algorithm • Pseudo code… for each polygon for each pixel p in the polygon's projection { pz = polygon's normalized z-value at (x, y); //z ranges from -1 to 0 if (pz > zBuffer[x, y]) // closer to the camera { zBuffer[x, y] = pz; framebuffer[x, y] = colour of pixel p; } }

More Related