27
Hidden Lines and Hidden Lines and Surfaces Surfaces 1

Hidden lines & surfaces

Embed Size (px)

DESCRIPTION

Identify those parts of a scene that are visible from a chosen viewing position. Visible-surface detection algorithms are broadly classified according to whether they deal with object definitions directly or with their projected images. These two approaches are called object-space methods and image-space methods, respectively An object-space method compares objects and parts of objects to each other within the scene definition to determine which surfaces, as a whole, we should label as visible. In an image-space algorithm, visibility is decided point by point at each pixel position on the projection plane.

Citation preview

Page 1: Hidden lines & surfaces

Hidden Lines and Hidden Lines and SurfacesSurfaces

11

Page 2: Hidden lines & surfaces

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

Visible-surface detection algorithms are Visible-surface detection algorithms are broadly classified according to whetherbroadly classified according to whether

they deal with object definitions directly or they deal with object definitions directly or with their projected images. with their projected images.

These These two approaches are called object-two approaches are called object-space methods and image-space methods, space methods and image-space methods, respectivelyrespectively

22

Page 3: Hidden lines & surfaces

An object-space method comparesAn object-space method compares

objectsobjects and parts of objects and parts of objects to each other to each other within the scene definition to determine which within the scene definition to determine which surfaces, as a whole, we should label as surfaces, as a whole, we should label as visible.visible.

In an image-space algorithm, visibility is In an image-space algorithm, visibility is decided point by point at each pixel position decided point by point at each pixel position on the projection plane. on the projection plane.

33

Page 4: Hidden lines & surfaces

BACK-FACE DETECTIONBACK-FACE DETECTION

A point A point (x, y, (x, y, z) is "inside" a polygon surface z) is "inside" a polygon surface with plane parameters A, B, C, and D ifwith plane parameters A, B, C, and D if

Ax+ Bx + Cz + D < 0Ax+ Bx + Cz + D < 0

When an inside point is along the line of sight When an inside point is along the line of sight to the surface, the polygon must be a back face to the surface, the polygon must be a back face (we are inside that face and cannot see the (we are inside that face and cannot see the front of it from our viewing position).front of it from our viewing position).

44

Page 5: Hidden lines & surfaces

• Consider the normal vector N to a polygonConsider the normal vector N to a polygon surface, which has Cartesian components surface, which has Cartesian components (A, B, C). (A, B, C). • In general, if V is a vector in In general, if V is a vector in the viewing the viewing

direction from the eye (or "camera") position, direction from the eye (or "camera") position, then this polygon is a back face ifthen this polygon is a back face if V . N > 0V . N > 0

55

Page 6: Hidden lines & surfaces

if object descriptions have been converted to if object descriptions have been converted to projection coordinates and our viewing projection coordinates and our viewing direction is parallel to the viewing z direction is parallel to the viewing z vv axis, axis,

then V = then V = (0, 0, (0, 0, V) V) andand

V . N = VV . N = Vzz . C . C

so that we only need to consider the sign of C, so that we only need to consider the sign of C, the z component of the normal vector Nthe z component of the normal vector N

66

Page 7: Hidden lines & surfaces

we can label any polygon as a back face if its we can label any polygon as a back face if its normal vector has a z component value:normal vector has a z component value:

C < = 0C < = 0

77

Page 8: Hidden lines & surfaces

By examining parameter C for the different By examining parameter C for the different planes defining an object, we can immediately planes defining an object, we can immediately identify all the back facesidentify all the back faces

88

Page 9: Hidden lines & surfaces

DEPTH-BUFFER METHODDEPTH-BUFFER METHOD compares surface depths at each pixel position compares surface depths at each pixel position

on the projection plane. on the projection plane. This procedure is also referred to as the z-This procedure is also referred to as the z-

buffer methodbuffer method Each surface of a scene is processed Each surface of a scene is processed

separately, one point at a time across the separately, one point at a time across the surface. surface.

The method is usually applied to scenes The method is usually applied to scenes containing only polygon surfacescontaining only polygon surfaces

99

Page 10: Hidden lines & surfaces

• for each pixel position for each pixel position (x, y) on the view(x, y) on the view plane, object depths can be compared by comparing z plane, object depths can be compared by comparing z

values.values.• Figure Figure 13-4 shows 13-4 shows three surfaces at varying distancesthree surfaces at varying distancesalong the orthographic projection line from positionalong the orthographic projection line from position(x,y) in a (x,y) in a

view plane taken as the xview plane taken as the xvv y yvv plane. Surface S1, is closest at plane. Surface S1, is closest at this this position, so its surface intensity value at position, so its surface intensity value at (x, y) is saved.(x, y) is saved.

1010

Page 11: Hidden lines & surfaces

• Two buffer areas are required. A Two buffer areas are required. A depth buffer depth buffer is used to store depth values for each (x, y) is used to store depth values for each (x, y) position as surfaces are processed, and the position as surfaces are processed, and the refresh buffer refresh buffer stores the intensity values for stores the intensity values for each position. each position.

• Initially, all positions in the depth buffer are Initially, all positions in the depth buffer are set to set to 0 (minimum depth), and the refresh 0 (minimum depth), and the refresh buffer is initialized to the background buffer is initialized to the background intensity. intensity.

• Each surface listed in the polygon tables is Each surface listed in the polygon tables is then processed, one scan line at a time, then processed, one scan line at a time, calculating the depth (z value) at each (x, y) calculating the depth (z value) at each (x, y) pixel position.pixel position.

1111

Page 12: Hidden lines & surfaces

1212

Page 13: Hidden lines & surfaces

For any scan line (Fig. 13-5), adjacent horizontal For any scan line (Fig. 13-5), adjacent horizontal positions across the line differ by 1, and a vertical y positions across the line differ by 1, and a vertical y value on an adjacent scan line differs by 1. value on an adjacent scan line differs by 1. If the depth of position If the depth of position (x, y) has been determined to be (x, y) has been determined to be z, then the depth z' of the next position (x +z, then the depth z' of the next position (x +1, y) along 1, y) along the scan line is obtained from Eq. 13-4 asthe scan line is obtained from Eq. 13-4 as

1313

Page 14: Hidden lines & surfaces

1414

Page 15: Hidden lines & surfaces

• On each scan line, we start by calculating the depth On each scan line, we start by calculating the depth on a left edge of the polygon that intersects that scan on a left edge of the polygon that intersects that scan line (Fig. 13-6). line (Fig. 13-6).

• Depth values at each successive position across the Depth values at each successive position across the scan line are then calculated by Eq. 13-6.scan line are then calculated by Eq. 13-6.

• We first determine the y-coordinate extents of each We first determine the y-coordinate extents of each polygon, and process the surface from the topmost polygon, and process the surface from the topmost scan line to the bottom scan line .scan line to the bottom scan line .

• Starting at a top vertex, we can recursively Starting at a top vertex, we can recursively calculate x positions down a left edge of the calculate x positions down a left edge of the polygon aspolygon as

x' = x' = x - l/mx - l/m where m is the slope of the edgewhere m is the slope of the edge

1515

Page 16: Hidden lines & surfaces

Depth values down the edge are then obtained Depth values down the edge are then obtained recursively asrecursively as

1616

Page 17: Hidden lines & surfaces

A-BUFFER METHODA-BUFFER METHOD

A drawback of the depth-buffer method is that A drawback of the depth-buffer method is that it can only find one visible surface at each it can only find one visible surface at each pixel position.pixel position.

Depth buffer method deals only with opaque Depth buffer method deals only with opaque surfaces and cannot accumulate intensity surfaces and cannot accumulate intensity values for more than one surface, as is values for more than one surface, as is necessary if transparent surfaces are to be necessary if transparent surfaces are to be displayed displayed

1717

Page 18: Hidden lines & surfaces

• Each position in the A-buffer has two fields:Each position in the A-buffer has two fields:• depth field - stores a positive or negative real depth field - stores a positive or negative real

numbernumber• intensity field - stores surface-intensity intensity field - stores surface-intensity

information or a pointer value.information or a pointer value.

1818

Page 19: Hidden lines & surfaces

• If the depth field is positive, the number stored at that If the depth field is positive, the number stored at that position is the depth of a single surface overlapping position is the depth of a single surface overlapping the corresponding pixel area. the corresponding pixel area.

• The intensity field then stores the RGB components The intensity field then stores the RGB components of the surface color at that point and the percent of of the surface color at that point and the percent of pixel coverage, as illustrated in Fig.pixel coverage, as illustrated in Fig.

Organization of an A-buffer pixel position: (a) single-surface overlap ofOrganization of an A-buffer pixel position: (a) single-surface overlap ofthe corresponding pixel areathe corresponding pixel area

1919

Page 20: Hidden lines & surfaces

If the depth field is negative, this indicates If the depth field is negative, this indicates multiple-surface contributions to the pixel multiple-surface contributions to the pixel intensity. intensity.

The intensity field then stores a pointer to a The intensity field then stores a pointer to a linked Iist of surface data, as in Fig.linked Iist of surface data, as in Fig.

Organization of an A-buffer pixel position for multiple Organization of an A-buffer pixel position for multiple surface overlapsurface overlap

2020

Page 21: Hidden lines & surfaces

Data for each surface in the linked list includesData for each surface in the linked list includesRGB intensity componentsRGB intensity components• opacity parameter (percent of transparency)opacity parameter (percent of transparency)• depthdepth• percent of area coveragepercent of area coverage• surface identifiersurface identifier• other surface-rendering parametersother surface-rendering parameters• pointer to next surfacepointer to next surface

2121

Page 22: Hidden lines & surfaces

SCAN-LINE METHODSCAN-LINE METHOD

• we now deal with multiple surfaceswe now deal with multiple surfaces• As each scan line is processed, all polygon As each scan line is processed, all polygon

surfaces intersecting that line are examined to surfaces intersecting that line are examined to determine which are visible.determine which are visible.

• Across each scan line, depth calculations are Across each scan line, depth calculations are made for each overlapping surface to made for each overlapping surface to determine which is nearest to the view plane. determine which is nearest to the view plane.

• When the visible surface has been determined, When the visible surface has been determined, the intensity value for that position is entered the intensity value for that position is entered into the refresh buffer.into the refresh buffer.

2222

Page 23: Hidden lines & surfaces

The edge table contains coordinate endpoints The edge table contains coordinate endpoints for each line in-the scene, the inverse slope of for each line in-the scene, the inverse slope of each line, and pointers into the polygon table each line, and pointers into the polygon table to identify the surfaces bounded by each lineto identify the surfaces bounded by each line

The polygon table contains coefficients of the The polygon table contains coefficients of the plane equation for each surface, intensity plane equation for each surface, intensity information for the surfaces, and possibly information for the surfaces, and possibly pointers into the edge tablepointers into the edge table

2323

Page 24: Hidden lines & surfaces

• we can set up an active list of edges from we can set up an active list of edges from information in the edge table. This active list will information in the edge table. This active list will contain only edges that cross the current scan contain only edges that cross the current scan line, sorted in order of increasing line, sorted in order of increasing x. x.

• In In addition, we define a flag for each surface that addition, we define a flag for each surface that is set on or off to indicate whether a position is set on or off to indicate whether a position along a scan line is inside or outside of the along a scan line is inside or outside of the surface. surface.

• Scan lines are processed from left to right. At the Scan lines are processed from left to right. At the leftmost boundary of a surface, the surface flag is leftmost boundary of a surface, the surface flag is turned on; and at the rightmost boundary, it is turned on; and at the rightmost boundary, it is turned off.turned off.

2424

Page 25: Hidden lines & surfaces

Scan lines crossing the projection of two surfaces, Scan lines crossing the projection of two surfaces, S1 and S2 S1 and S2 in the in the view plane. Dashed lines indicate the boundaries of view plane. Dashed lines indicate the boundaries of hidden surfaces.hidden surfaces.

2525

Page 26: Hidden lines & surfaces

• For scan lines 2 and 3 in Fig. 13-10, the active For scan lines 2 and 3 in Fig. 13-10, the active edge list contains edges edge list contains edges AD, AD, EH, EH, BC, and FG. BC, and FG.

• Along scan line 2 from edge AD to edge EH, Along scan line 2 from edge AD to edge EH, only the flag for only the flag for surface S1 is on. But between surface S1 is on. But between edges EH and edges EH and BC, the flags for both surfaces are BC, the flags for both surfaces are on.on.

• In this interval, depth calculations must be made In this interval, depth calculations must be made using the plane coefficients for the two surfaces.using the plane coefficients for the two surfaces.

• For this example, the depth of surface For this example, the depth of surface SI is SI is assumed to be less assumed to be less than that of S2, so intensities than that of S2, so intensities for surface S1 are loaded into the refresh buffer for surface S1 are loaded into the refresh buffer until boundary BC is encountered. Then the flag until boundary BC is encountered. Then the flag for surface for surface SI goes off, and intensities SI goes off, and intensities for surface for surface S2 are stored until edge FG is passed.S2 are stored until edge FG is passed. 2626

Page 27: Hidden lines & surfaces

Thank You

Thank You

(Follow me to get update on engineering , technology

(Follow me to get update on engineering , technology

and science)

and science)

2727