Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visible surface determination

Similar presentations


Presentation on theme: "Visible surface determination"— 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 n x m frame buffer) and find closest of k polygons Complexity O(nmk) Two techniques: Ray tracing Z-buffer

9 Algorithms Object space Image space Hybrid Back-face culling
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) where Ibackgnd value for backgnd intensity Isurf (x,y) is the projected intensity value for 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; }


Download ppt "Visible surface determination"

Similar presentations


Ads by Google