38

Hiddensurfaceppt 12-09-13

Embed Size (px)

Citation preview

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 1/38

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 2/38

Problem definition of Visible-Surface 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.

Characteristics of approaches:•Require large memory size?•Require long processing time?• Applicable to which types of objects?

Considerations:•Complexity of the scene•Type of objects in the scene• Available equipment•Static or animated?

Hidden Surface Removal / Visible Surface Detection Methods

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 3/38

1. Object-space Methods

Compare objects and parts of objects to each other within the scene definition to

determine which surfaces, as a whole, we should label as visible:

For each object in the scene do

Begin

1.Determine those part of the object whose view is unobstructed by otherparts of it or any other object with respect to the viewing specification.

2.Draw those parts in the object color.

End

Compare each object with all other objects to determine the visibility of the object parts.

Display is more accurate but computationally more expensive as compared to image space

methods because step 1 is typically more complex, eg. Due to the possibility of intersection between

surfaces.

Suitable for scene with small number of objects and objects with simple relationship with each

other.

Classification of Visible-Surface Detection Algorithms:

 

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 4/38

Image-space Methods Mostly used)

Visibility is determined point by point at each pixel position on the projection plane.

For each pixel in the image do

Begin1.Determine the object closest to the viewer that is pierced by the

projector through the pixel.

2.Draw the pixel in the object colour.End

-

For each pixel, examine all n objects to determine the one closest to the viewer.

If there are p pixels in the image, complexity depends on n and p ( O(np) ).Accuarcy of the calculation is bounded by the display resolution.

A change of display resolution requires re-calculation

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 5/38

Application of Coherence in Visible Surface Detection Methods:

1. Making use of the results calculated for one part of the scene or image

for other nearby parts.2. Coherence is the result of local similarity

3. As objects have continuous spatial extent, object properties vary

smoothly within a small local region in the scene. Calculations can then

be made incremental.

Types of Coherence

1. Object Coherence

2. Face Coherence

3. Edge Coherence4. Scan Line Coherence

5. Area and Span Coherence

6. Depth Coherence

7. Frame Coherence

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 6/38

In a solid object, there are surfaces which are facing the viewer

(front faces) and there are surfaces which are opposite to the

viewer (back faces).

These back faces contribute to approximately half of the total

number of surfaces.

Since we cannot see these surfaces anyway, to save processing

time, we can remove them before the clipping process with

a simple test.

Each surface has a normal vector.

If this vector is pointing in the direction of the center of projection, it is a front face and

can be seen by the viewer.

If it is pointing away from the center of projection, it is a back face and cannot be seen

 by the viewer.

The test is very simple,.

if the z component of the normal vector is positive then it is a back face.

If the z component of the vector is negative, it is a front face.

Back-Face Detection

-Z

Z

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 7/38

This technique only caters well for nonoverlapping convex polyhedra.

For other cases where there are concave polyhedra or overlapping objects, we still

need to apply other methods to further determine where the obscured faces are partially or completely hidden by other objects (eg. Using Depth-Buffer Method or

Depth-sort Method).

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 8/38

 This approach compare surface depths at each pixelposition on the projection plane.

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

This method requires 2 buffers:image buffer (used to store the color values of each pixel position)

z-buffer (or the depth buffer). (depth values for each ( x,y)

position)

Each of these buffers has the same resolution as the imageto be captured.

As surfaces are processed, the image buffer is used tostore the color values of each pixel position and the z-buffer

is used to store the depth values for each ( x,y) position.

Z-Buffer Method

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 9/38

Z-buffer Image buffer

Obtain the depth and the

colour of the polygon atthe pixel concerned.

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 10/38

 Algorithm:

1.Initially each pixel of the z-buffer is set to the maximum depth value (the depth of the

back clipping plane).

2.The image buffer is set to the background color.

3.Surfaces are rendered one at a time.

4.For the first surface, the depth value of each pixel is calculated.

5.If this depth value is smaller than the corresponding depth value in the z-buffer (ie. it is

closer to the view point), both the depth value in the z-buffer and the color value in the

image buffer are replaced by the depth value and the color value of this surface

calculated at the pixel position.

6.Repeat step 4 and 5 for the remaining surfaces.

7.After all the surfaces have been processed, each pixel of the image buffer represents

the color of a visible surface at that pixel.

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 11/38

 

Advantages:

Simple and does not require additional data structures.The z-value of a polygon can be calculated incrementally.

No pre-sorting of polygons is needed.

No object-object comparison is required.

Can be applied to non-polygonal objects.

Hardware implementations of the algorithm are available in some graphics

workstation. 

Disadvantages:

This method requires an additional buffer (if compared with the Depth-Sort

Method) and the overheads involved in updating the buffer. So this method is lessattractive in the cases where only a few objects in the scene are to be rendered.

For large images, the algorithm could be applied to, eg ., the 4 quadrants of the image

separately, so as to reduce the requirement of a large additional buffer

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 12/38

Generally to compute z : If the equation of the plane is Ax + By + Cz + d = 0,

then

 Ax By D z 

( 1)/

 A x By D z z A C 

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 13/38

1/3/2015

A-Buffer Method

• accumulation buffer – buffer accumulates multiple pieces of

information for each pixel in addition to depth for transparency oranti-aliasing (high-end movies, etc.). A-buffer element stores:

 – Depth Field : real-number

 – Surface Data Field (SDF): stores surface data or pointer

• When Depth >= 0:

-real-number is depth of surface at pixel-SDF is surface color and pixel coverage percentage

depth ≥ 0RGB & Other

Info Pixel

44%48%

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 14/38

1/3/2015

•When Depth < 0: 

-SDF is pointer to linked list of elements that store:

-RGB intensity

-opacity

-depth

-pixel coverage percentage

-surface ID

-other surface rendering parameters

Depth < 0RGB & Other

Info

RGB & Other

Info

Surface 1 Surface 2

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 15/38

15

Painter’s Algorithm 

Object-space algorithmDraw surfaces from back (farthest away) to front (closest): – Sort surfaces/polygons by their depth (z value)

 – Draw objects in order (farthest to closest)

 – Closer objects paint over the top of farther away objects

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 16/38

16

1

6

4

2 3

5

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 17/38

17

Triangle Behind Counter List of triangles infront of it

1 2 5

2 0 4,3,1

3 2 1, 5

4 1 3

5 2

6 0

Depth Order Table

St 1

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 18/38

18

Triangle Front List Behind

Counter

Output New Behind

Counter

1 5 2 1

2 4,3,1 0 -1

3 1, 5 2 1

4 3 1 0

5 2 2

6 0 -1

Triangle Front List Behind

Counter

Output New Behind

Counter

1 5 1 1

2 4,3,1 -1 -1

3 1, 5 1 0

4 3 0 -1

5 2 2

6 -1 -1

Step:1

Step:2

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 19/38

19

Step:3

Triangle Front List Behind Counter Output New behind

counter

1 5 1 6,2,4,3 0

2 4, 3, 1 -1 -1

3 1, 5 0 -1

4 3 -1 -1

5 2 1

6 -1 -1

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 20/38

2020

Step:4

Triangle Front List Behind Counter Output New behind

counter

1 5 0 -1

2 4, 3, 1 -1 -1

3 1, 5 -1 -1

4 3 -1 -1

5 1 0

6 -1 6,2,4,3,1 -1

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 21/38

2121

Step:5

Triangle Front List Behind Counter Output New behind

counter

1 5 -1 -1

2 4, 3, 1 -1 -1

3 1, 5 -1 -1

4 3 -1 -1

5 0 -1

6 -1 -1

6,2,4,3, 1, 5

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 22/38

 

Advantages

1. Well suited for a set of triangles which do not intersect or penetrate

each other or any cyclic overlapping.

Disadvantages

1.

Subdividing any complex surface creates a large number of polygons,

which require polygonization process and calculating depth order using

this algorithm.

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 23/38

1/3/2015

Scan-Line Method

Image Space Method

 An extension of the scan line algorithm.

 As each scan line is processed, all polygon surfaces intersecting

that line are examined to determine which are visible.

 Across each scan line, depth calculations are made for each

overlapping surface to determine which is nearest to the view plane.

When the visible surface has been determined, the intensity value

for that position is entered into the refresh buffer.

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 24/38

B

 A

C

F

E

H

S1 S2

Scan Line 1

Scan Line 2

Scan Line 3

D G

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 25/38

1/3/2015

Scan-Line Method Basic Example

• Scan Line 1: – (A,B) to (B,C) only inside S1, so color from S1

 – (E,H) to (F,G) only inside S2, so color from S2

• Scan Line 2: – (A,D) to (E,H) only inside S1, so color from S1

 – (E,H) to (B,C) inside S1 and S2 , so compute & test depthIn this example we color from S1

 – (B,C) to (F,G) only inside S2, so color from S2

BE

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 26/38

26

BSP Tree Algorithm

1. Select a polygon and make it the root

2. Partition space into two half-spaces determined by the

normal of the root polygon

3. If a polygon is intersected by the plane, split thepolygon into two polygons, one in each half space

4. Select one polygon in the root’s front and one in the

root’s back and assign them as children of the root 

5. Recursively subdivide space depending on each of thechildren generated from step 4.

6. Stop when a sub-space contains a single polygon

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 27/38

27

• Initial Scene:

1

23

4

5

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 28/38

28

• Select polygon 3 as the root

1

23

4

5

1

2

4a

4b

5

3

4a

4b

front  back

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 29/38

29

• Select polygons 2 and 4b as the next nodes

1

23

4

5 1b

4a

34a

4b 4b2

1a 5

1b

1a

front  back

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 30/38

30

• Select polygon 1b as the next node

1

23

4

5

4a

4b

1b

1a

3

4b2

1a 51b

4a

front  back

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 31/38

31

• Once the tree is built, we can scan convert

• The viewpoint will be in one of the subspaces

• To scan convert properly:

 –Recursively scan convert all polygons in the root’ssubspace that doesn’t contain the viewpoint 

 –Then scan convert the root

 –Then recursively scan convert the subspace that

contains the viewpoint

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 32/38

32

BSP Tree example

• Suppose the viewpoint is as shown:

• Since the eye is in front of 3, scan convert the polygons inback of 3 first

3

4b2

1a 51b

4a

front  back1

23

4

5

4a

4b

1b

1a

eye

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 33/38

33

BSP Tree example

• The eye is behind 4b, so scan convert the polygons in front

of 4b first (there are none)

• Then scan convert 4b, then scan convert the polygons inback of 4b (5)

1

23

4

5

4a

4b

1b

1a

3

4b2

1a 51b

4a

front  back

eye

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 34/38

34

• Next scan convert 3

• Then scan convert the polygons in front of 3

3

4b2

1a 51b

4a

front  back

1

23

4

5

4a

4b

1b

1a

eye

BSP Tree example

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 35/38

35

• The eyepoint is behind 2, so scan convert the

polygons in front of 2 first

3

4b2

1a 51b

4a

front  back

1

23

4

5

4a

4b

1b

1a

eye

BSP Tree example

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 36/38

36

• The eyepoint is behind 1b, so scan convert the polygons in

front of 1b first (none)

• Then scan convert 1b, then the polygons behind 1b (4a)

3

4b2

1a 51b

4a

front  back

1

23

4

5

4a

4b

1b

1a

eye

BSP Tree example

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 37/38

37

• Then scan convert 2

• Then scan convert the polygons behind 2 (1a)

3

4b2

1a 51b

4a

front  back

1

23

4

5

4a

4b

1b

1a

eye

BSP Tree example

8/10/2019 Hiddensurfaceppt 12-09-13

http://slidepdf.com/reader/full/hiddensurfaceppt-12-09-13 38/38

38

• So, the final ordering is:

 –4b, 5, 3, 1b, 4a, 2, 1a

3

4b2

1a 51b

4a

front  back1

2

3

4

5

4a

4b

1b

1a

eye

BSP Tree example