Top Banner
Hidden Surfaces Hidden Surfaces Chapter 10
72

Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

Mar 27, 2015

Download

Documents

Patrick Hurley
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

Hidden SurfacesHidden Surfaces

Chapter 10

Page 2: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

2

Department of CSE, CUET

Hidden Lines

Page 3: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

3

Department of CSE, CUET

Hidden Lines Removed

Page 4: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

4

Department of CSE, CUET

Hidden Surfaces Removed

Page 5: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

5

Department of CSE, CUET

Why?

We must determine what is visible within a scene from a chosen viewing position

For 3D worlds this is known as visible surface detection or hidden surface elimination

Page 6: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

6

Department of CSE, CUET

Hidden Surface Removal

Goal: Determine which surfaces are visible and which are not.

Z-Buffer is just one of many hidden surface removal algorithms.

Other names:Visible-surface detection

Hidden-surface elimination

Display all visible surfaces, do not display any occluded surfaces.We can categorize into

Object-space methods

Image-space methods

Page 7: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

7

Department of CSE, CUET

Topics need to be read

Back face Culling Hidden Object Removal: Painters Algorithm

Z-buffer

Scanline

subdivision

Warnock

Atherton-Weiler

BSP Tree

Page 8: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

8

Department of CSE, CUET

Two Main Approaches

Visible surface detection algorithms are broadly classified as: Object Space Methods: Compares objects and parts of objects to

each other within the scene definition to determine which

surfaces are visible

Image Space Methods: Visibility is decided point-by-point at

each pixel position on the projection plane

Image space methods are by far the more common

Page 9: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

9

Department of CSE, CUET

Two Main Approaches

Object Space Method:

For each object in the scene do

Begin

1. Determine those part of the object whose view is

unobstructed by other parts of it or

any other object with respect to the viewing specification.

2. Draw those parts in the object color.

End

Page 10: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

10

Department of CSE, CUET

Two Main Approaches

Image Space Method:

For each pixel in the image do

Begin

1. 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

Page 11: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

11

Department of CSE, CUET

Visible Surface Detection

Object space methods ex: back-face, painters algorithm

Image space methods ex: z-buffer, scan-line, subdivision

Page 12: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

12

Department of CSE, CUET

Back-Face Detection

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).

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.

Page 13: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

13

Department of CSE, CUET

Back-Face Detection

zv

xv

yv

Vview

N=(A,B,C)

(x,y,z) is behind the polygon if Ax+By+Cz<0

orA polygon is a backface if

Vview . N >0

if Vview is parallel to zv axis:if C<0 then backfaceif C=0 then polygon cannot be seen

Page 14: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

14

Department of CSE, CUET

Back-Face Culling Example

v = (-1, 0, -1)

n2 = (-3, 1, -2)

n1·v = (2, 1, 2) · (-1, 0, -1) = -2 – 2 = -4,

so n1·v < 0so n1 front facing polygon

n1 = (2, 1, 2)

n2 ·v = (-3, 1, -2) · (-1, 0, -1) = 3 + 2 = 5

so n2 · v > 0so n2 back facing polygon

Page 15: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

15

Department of CSE, CUET

Back-Face Culling

If the viewpoint is on the +z axis looking at the origin, we

only need check the sign of the z component of the object’s

normal vector

if nz < 0, it is back facing

if nz > 0 it is front facing

What if nz = 0?

the polygon is parallel to the view direction, so we don’t see it

Page 16: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

16

Department of CSE, CUET

Z-Buffering

Visible Surface Determination Algorithm:

Determine which object is visible at each pixel.

Order of polygons is not critical.

Works for dynamic scenes.

Basic idea:

Rasterize (scan-convert) each polygon, one at a time

Keep track of a z value at each pixel

Interpolate z value of vertices during rasterization.

Replace pixel with new color if z value is greater. (i.e., if object is

closer to eye)

Page 17: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

17

Department of CSE, CUET

Example

Goal is to figure out which polygon to draw based on which is in front of what. The algorithm relies on the fact that if a nearer object occupying (x,y) is found, then the depth buffer is overwritten with the rendering information from this nearer surface.

Page 18: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

18

Department of CSE, CUET

Z-buffering

Need to maintain:

Frame buffer

contains colour values for each pixel

Z-buffer

contains the current value of z for each pixel

The two buffers have the same width and height.

No object/object intersections.

No sorting of objects required.

Additional memory is required for the z-buffer.

In the early days, this was a problem.

Page 19: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

19

Department of CSE, CUET

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.

Z-Buffering: Algorithm

Page 20: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

20

Department of CSE, CUET

Z-Buffering: Algorithmallocate z-buffer;

 The z-buffer algorithm:

compare pixel depth(x,y) against buffer record d[x][y]

for (every pixel){ initialize the colour to the background};

for (each facet F){

for (each pixel (x,y) on the facet)

if (depth(x,y) < buffer[x][y]){ / / F is closest so far

set pixel(x,y) to colour of F;

d[x][y] = depth(x,y)

}

}

Page 21: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

21

Department of CSE, CUET

Z-Buffering: Example

-1

-2 -3

-3 -4 -5

-4 -5 -6 -7

-1

-3 -2

-5 -4 -3

-7 -6 -5 -4

Scan convert the following two polygons.The number inside the pixel represents its z-value.

(0,0) (3,0)

(0,3)

(0,0) (3,0)

(3,3)

Does order matter?

Page 22: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

22

Department of CSE, CUET

-1

-3 -2

-5-4 -3

-7-6-5 -4

Z-Buffering: Example

= +

-1

-2 -3

-3 -4

-4 -5

-1

-2 -3

-3 -4 -5

-4 -5 -6 -7

-1

-3 -2

-5 -4 -3

-7 -6 -5 -4

-1

-2 -3

-3 -4 -5

-4 -5 -6 -7

-1

-3 -2

-5 -4 -3

-7 -6 -5 -4

+

+

=

= =+

-1

-3 -2

-5 -4 -3

-7 -6 -5 -4

-1

-3 -2

-5-4 -3

-7-6-5 -4

-1

-2 -3

-3 -4

-4 -5

-1

-2 -3

-3 -4 -5

-4 -5 -6 -7

Page 23: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

23

Department of CSE, CUET

Z-Buffering: Example

Page 24: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

24

Department of CSE, CUET

Z-Buffering: Computing Z

How do you compute the z value at a given pixel?Interpolate between vertices

z1

z2

z3

y1

y2

y3

ys

za zb

zs31

1131

21

1121

)(

)(

yy

yyzzzz

yy

yyzzzz

sb

sa

ab

sbbabs xx

xxzzzz

)(

Page 25: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

25

Department of CSE, CUET

Z-Buffer Advantages

Simple to implement in hardware.

Memory for z-buffer is now not expensive

Diversity of primitives – not just polygons.

Unlimited scene complexity

Don’t need to calculate object-object intersections.

– Buffer may be saved with image for re-processing

Amenable to scan-line algorithms

Can easily resolve visibility cycles

Page 26: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

26

Department of CSE, CUET

Z-Buffer Disadvantages Extra memory and bandwidth Waste time drawing hidden objects Z-precision errors May have to use point sampling Requires a lot of memory – Finite depth precision can cause problems – Spends time while rendering polygons that are not visible – Requires re-calculations when changing the scale Does not do transparency easily Aliasing occurs! Since not all depth questions can be resolved Anti-aliasing solutions non-trivial Shadows are not easy

Higher order illumination is hard in general

Page 27: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

27

Department of CSE, CUET

Scan-Line Method

An image space method for identifying visible surfaces

Computes and compares depth values along the various

scan-lines for a scene.

Page 28: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

28

Department of CSE, CUET

Scan-Line Method (cont…)

Two important tables are maintained: The edge table The surface facet table

The edge table contains: Coordinate end points of reach line in the scene The inverse slope of each line Pointers into the surface facet table to connect edges to surfaces

The surface facet tables contains:The plane coefficients

Surface material properties

Other surface data

Maybe pointers into the edge table

Page 29: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

29

Department of CSE, CUET

Scan-Line Method (cont…)

•To facilitate the search for surfaces crossing a given

scan-line an active list of edges is formed for each

scan-line as it is processed.

•The active list stores only those edges that cross the

scan-line in order of increasing x.

•Also a flag is set for each surface to indicate whether a

position along a scan-line is either inside or outside the

surface.

Page 30: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

30

Department of CSE, CUET

Scan-Line Method (cont…)

•Pixel positions across each scan-line are processed from

left to right

•At the left intersection with a surface the surface flag is

turned on

•At the right intersection point the flag is turned off

•We only need to perform depth calculations when more

than one surface has its flag turned on at a certain scan-line

position

Page 31: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

31

Department of CSE, CUET

Scan Line Method Example

Page 32: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

32

Department of CSE, CUET

Scan-Line Method Limitations

The scan-line method runs into trouble when surfaces cut through each other or otherwise cyclically overlap

Such surfaces need to be divided

Page 33: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

33

Department of CSE, CUET

Scan-Line Method

For each scan-line, examine all polygon surface projections intersecting that scan line to determine which are visible. Then enter the surface color of that position in the frame buffer.

Edge table:coordinate endpoints of each lineinverse slope of each linepointers to surface table

Surface table:plane coefficients (A,B,C)surface material propertiespointers to edge table

yv

xv

Image space method

Page 34: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

34

Department of CSE, CUET

Scan-Line Method

Algorithm:

1. Form an active edge list that contains only the edges that cross the current scan line, sorted in order of increasing x.

2. Define a flag for each surface to indicate whether a position along a scan line is inside or outside the surface.

3. Process pixel positions across each scan line from left to right. Locate visible positions of surfaces along the scan line.

yv

xv

1

23

Page 35: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

35

Department of CSE, CUET

An area-subdivision techniqueIdea:

Divide an area into four equal sub-areasAt each stage, the projection of each polygon will do one of four things:

1. Completely surround a particular area

2. Intersect the area

3. Be completely contained in the area

4. Be disjoint to the area

Warnock’s Algorithm

Page 36: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

36

Department of CSE, CUET

Warnock’s Algorithm

Disjoint polygons do not influence an area.

Parts of an intersecting polygon that lie outside the area do not

influence that area

At each step, we determine the areas we can color and color

them, then subdivide the areas that are ambiguous.

Page 37: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

37

Department of CSE, CUET

Warnock’s Algorithm

At each stage of the algorithm, examine the areas:

1. If no polygons lie within an area, the area is filled with the

background color

2. If only one polygon is in part of the area, the area is first filled

with the background color and then the polygon is scan

converted within the area.

3. If one polygon surrounds the area and it is in front of any

other polygons, the entire area is filled with the color of the

surrounding polygon.

4. Otherwise, subdivide the area and repeat the above 4 tests.

Page 38: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

38

Department of CSE, CUET

Warnock’s Algorithm

Initial scene

Page 39: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

39

Department of CSE, CUET

Warnock’s Algorithm

First subdivision

Page 40: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

40

Department of CSE, CUET

Warnock’s Algorithm

Second subdivision

Page 41: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

41

Department of CSE, CUET

Warnock’s Algorithm

Third subdivision

Page 42: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

42

Department of CSE, CUET

Warnock’s Algorithm

Fourth subdivision

Page 43: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

43

Department of CSE, CUET

Warnock’s Algorithm

Subdivision continues until:All areas meet one of the four criteria

An area is pixel sizein this case, the polygon with the closest point at that pixel determines the pixel color

Page 44: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

44

Department of CSE, CUET

Page 45: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

45

Department of CSE, CUET

0

0 0 0

00

0

1

M

1

1

1

1

M M

M

Page 46: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

46

Department of CSE, CUET

1 1 0 0

1 M M 1

1 M M M

0 1 1 1

Page 47: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

47

Department of CSE, CUET

1

11

0

M M M M

M M M M

M M M M M

M M M

Page 48: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

48

Department of CSE, CUET

Page 49: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

49

Department of CSE, CUET10/29/02

Warnock’s Algorithm

Regions labeled with case used to classify them:1) One polygon in front2) Empty3) One polygon inside,

surrounding or intersecting

Small regions not labeledNote it’s a rendering algorithm and a HSR algorithm at the same time

Assuming you can draw squares

2 2 2

2222

2

2

3

3

3

3 33

3

3

3

3

3

333

3

3

1

1 1 11

Page 50: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

50

Department of CSE, CUET

Weiler -Atherton Algorithm

Object space

Like Warnock

Output – polygons of arbitrary accuracy

Page 51: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

51

Department of CSE, CUET

Weiler -Atherton Algorithm

Subdivide along polygon boundaries (unlike Warnock’s rectangular boundaries in image space);Algorithm:

1. Sort the polygons based on their minimum z distance2. Choose the first polygon P in the sorted list 3. Clip all polygons left against P, create two lists:

– Inside list: polygon fragments inside P (including P)– Outside list: polygon fragments outside P

4. All polygon fragments on the inside list that are behind P are discarded. If there are polygons on the inside list that are in front of P, go back to step 3), use the ’offending’ polygons as P

5. Display P and go back to step (2)

Page 52: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

52

Department of CSE, CUET

WA_display(polys : ListOfPolygons)

sort_by_minZ(polys);while (polys <> NULL) do

WA_subdiv(polys->first, polys)end;

WA_subdiv(first: Polygon; polys: ListOfPolygons)

inP, outP : ListOfPolygons := NULL;

for each P in polys do Clip(P, first->ancestor, inP, outP);

for each P in inP do if P is behind (min z)first then discard P;

for each P in inP doif P is not part of first then WA_subdiv(P, inP);

for each P in inP do display_a_poly(P);

polys := outP;

end;

Weiler -Atherton Algorithm

Page 53: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

53

Department of CSE, CUET53

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

Page 54: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

54

Department of CSE, CUET

BSP-Trees (Object Precision)

Construct a binary space partition treeTree gives a rendering order

A list-priority algorithm

Tree splits 3D world with planesThe world is broken into convex cells

Each cell is the intersection of all the half-spaces of splitting planes on tree path to the cell

Also used to model the shape of objects, and in other visibility algorithmsBSP visibility in games does not necessarily refer to this algorithm

Page 55: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

55

Department of CSE, CUET

BSP-Tree Example

AC

B

2

4

1

3A

B C

3 2 4 1

-

- -

+

++

Page 56: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

56

Department of CSE, CUET

Building BSP-Trees

Choose polygon (arbitrary)

Split its cell using plane on which polygon liesMay have to chop polygons in two (Clipping!)

Continue until each cell contains only one polygon fragment

Splitting planes could be chosen in other ways, but there is no efficient optimal algorithm for building BSP trees

Optimal means minimum number of polygon fragments in a balanced tree

Page 57: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

57

Department of CSE, CUET

Building Example

We will build a BSP tree, in 2D, for a 3 room building

Ignoring doors

Splitting edge order is shown“Back” side of edge is side with the number

1

23 4

5

6

Page 58: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

58

Department of CSE, CUET

Building Example (1)

1

23b 4b

5

6

1

3a, 4a, 6 2, 3b, 4b, 5

- +

4a3a

Page 59: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

59

Department of CSE, CUET

Building Example (2)

1

23b 4b

5a

6

1

3a, 4a, 6

- +

4a3a

3b, 5b

2

4b, 5a

- +

5b

Page 60: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

60

Department of CSE, CUET

Building Example (3)

1

23b 4b

5a

6

1- +

4a3a

2

4b, 5a

-+

5b

4a, 6

3a+

5b

3b

+

Page 61: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

61

Department of CSE, CUET

Building Example (Done)

1

23b 4b

5a

6

1- +

4a3a

2-

+

5b

3a+

3b

+

4a

6

+

5b

4b

5a

+

Page 62: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

62

Department of CSE, CUET

BSP-Tree Rendering

Observation: Things on the opposite side of a splitting plane from the viewpoint cannot obscure things on the same side as the viewpoint

Rendering algorithm is recursive descent of the BSP Tree

At each node (for back to front rendering):Recurse down the side of the sub-tree that does not contain the viewpoint

Test viewpoint against the split plane to decide which tree

Draw the polygon in the splitting planePaint over whatever has already been drawn

Recurse down the side of the tree containing the viewpoint

Page 63: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

63

Department of CSE, CUET

BSP-Tree Rendering Example

AC

B

2

4

1

3A

B C

3 2 4 1

-

- -

+

++

1st

View

2nd3rd 4th

Page 64: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

64

Department of CSE, CUET

BSP-Tree Rendering (2)

Advantages:One tree works for any viewing pointFilter anti-aliasing and transparency work

Have back to front ordering for compositing

Can also render front to back, and avoid drawing back polygons that cannot contribute to the view

User two trees – an extra one that subdivides the window

Disadvantages:Can be many small pieces of polygonOver-rendering

Page 65: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

65

Department of CSE, CUET

BSP (Binary Space Partitioning) Tree.

•One of class of “list-priority” algorithms – returns ordered list of polygon fragments for specified view point (static pre-processing stage).

•Choose polygon arbitrarily

•Divide scene into front (relative to normal) and back half-spaces.

•Split any polygon lying on both sides.

•Choose a polygon from each side – split scene again.

•Recursively divide each side until each node contains only 1 polygon.

3

41

2

5

View of scene from above

Page 66: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

66

Department of CSE, CUET

19/10/2007

BSP Tree.

•Choose polygon arbitrarily

•Divide scene into front (relative to normal) and back half-spaces.

•Split any polygon lying on both sides.

•Choose a polygon from each side – split scene again.

•Recursively divide each side until each node contains only 1 polygon. 3

341

2

5

5a5b

12

5a

45b

backfront

Page 67: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

67

Department of CSE, CUET

•Choose polygon arbitrarily

•Divide scene into front (relative to normal) and back half-spaces.

•Split any polygon lying on both sides.

•Choose a polygon from each side – split scene again.

•Recursively divide each side until each node contains only 1 polygon. 3

341

2

5

5a5b

45b

backfront

2

15a

front

BSP Tree.

Page 68: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

68

Department of CSE, CUET

•Choose polygon arbitrarily

•Divide scene into front (relative to normal) and back half-spaces.

•Split any polygon lying on both sides.

•Choose a polygon from each side – split scene again.

•Recursively divide each side until each node contains only 1 polygon.

3

3

41

2

5

5a

5b

backfront

2

15a

front

5b

4

BSP Tree.

Page 69: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

69

Department of CSE, CUET

19/10/2007

Displaying a BSP tree.

Once we have the regions – need priority list

BSP tree can be traversed to yield a correct priority list for an arbitrary viewpoint.

Start at root polygon.If viewer is in front half-space, draw polygons behind root first, then the root polygon, then polygons in front.

If polygon is on edge – either can be used.

Recursively descend the tree.

If eye is in rear half-space for a polygon – then can back face cull.

Page 70: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

70

Department of CSE, CUET

19/10/2007

BSP Tree.

A lot of computation required at start.Try to split polygons along good dividing planeIntersecting polygon splitting may be costly

Cheap to check visibility once tree is set up.Can be used to generate correct visibility for arbitrary views.

Efficient when objects don’t change very often in the scene.

Page 71: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

71

Department of CSE, CUET

19/10/2007

BSP performance measure

Tree construction and traversal (object-space ordering algorithm – good for relatively few static primitives, precise)Overdraw: maximum

• Front-to-back traversal is more efficient• Record which region has been filled in already• Terminate when all regions of the screen is filled in

• S. Chen and D. Gordon. “Front-to-Back Display of BSP Trees.” IEEE Computer Graphics & Algorithms, pp 79–85. September 1991.

Page 72: Hidden Surfaces Chapter 10. 2 Department of CSE, CUET Hidden Lines.

72

Department of CSE, CUET

Coherence

• Most methods for visible surface determination take advantage of coherence

features in the surface:

– Object coherence

– Face coherence

– Edge coherence

– Scan-line coherence

– Depth coherence

– Frame coherence