15
Visible-Surface Visible-Surface Detection Methods Detection Methods Presented By: Dinesh Kumar Kamal MCA Student

Visible-Surface Detection Methods

Embed Size (px)

Citation preview

Page 1: Visible-Surface Detection Methods

Visible-Surface Detection Visible-Surface Detection Methods Methods

Presented By:

Dinesh Kumar Kamal

MCA Student

Page 2: Visible-Surface Detection Methods

Problem Definition of Visible-Surface Problem Definition of Visible-Surface Detection Methods:Detection Methods:

To identify those parts of a scene that are visible from a chosen viewing position.

Surfaces which are obscured by other opaque surfaces along the line of sight (projection) are invisible to the viewer.

Page 3: Visible-Surface Detection Methods

Problem outlineProblem outlineGiven 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 surfaces, which will not ultimately be seen by the viewer, or which might confuse the viewer.

Page 4: Visible-Surface Detection Methods

For Example:For 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?

Page 5: Visible-Surface Detection Methods

? ?

Page 6: Visible-Surface Detection Methods

ApproachesApproachesThere are 2 fundamental approaches to

the problem.

Object space

Image space

Page 7: Visible-Surface Detection Methods

Object spaceObject spaceObject 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 color

Involves comparing the polygons in object a to other polygons in a and to polygons in every other object in the scene.

Page 8: Visible-Surface Detection Methods

Image spaceImage 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

Page 9: Visible-Surface Detection Methods

AlgorithmsAlgorithmsObject space

Back-face culling

Image spacez-buffer algorithm

HybridDepth-sort

Page 10: Visible-Surface Detection Methods

Z-buffer algorithmZ-buffer algorithmThis approach compares surface depths at

each pixel position on the projection plane.

Object depth is usually measured from the view plane along the z axis of a viewing system.

Page 11: Visible-Surface Detection Methods

RequirementsRequirements

Page 12: Visible-Surface Detection Methods

Initially each pixel of the z-buffer is set to the maximum depth value (the depth of the back clipping plane).

depth(x,y)=Zmax

The image buffer is set to the background color.

refresh(x,y)= Is ; Is = background intensity

For each position on each polygon surface:• Calculate the depth(z) for each (x,y) position on the polygon.

• If z < depth(x,y), then

depth(x,y) = z , refresh(x,y) = Is

AlgorithmAlgorithm

Page 13: Visible-Surface Detection Methods

; Is is the projected intensity value for the surface at pixel position (x,y).

After all the surfaces have been processed, the depth buffer contains depth values for the visible surfaces and the refresh buffer contains the corresponding intensity values for those surfaces.

Calculation of z:

Equation of surface:

Ax+By+Cz+D=0 -------(1)

from =n(1);

z = (-Ax-By-D)/C

Page 14: Visible-Surface Detection Methods

For any scan line in fig.

adjacent horizontal

positions across the line

differ by 1,and a vertical

y value on an adjacent

scan line differ by 1. z’ for (x+1,y) =

[-A(x+1) – By -D] /C

z’=z - A/C

and z’ for (x,y-1)= [-Ax - B(y-1) - D] / C

z’= z + B/C

Page 15: Visible-Surface Detection Methods

Now z’ for (x+1,y-1) is calculated by putting x’or x+1=x-1/m ; where m is slope of the edge.

z’(x+1,y-1)= [-A(x-1/m) - B(y-1) - D] / C

= (-Ax + A/m – By + B – D) / C

= (-Ax – By – D) / C + (A/m + B) / C

z’ = z + (A/m + B) / C

So, to implement algorithm, three constants are required for each surface:

-A/C , [A/m + B] / C , B/C