Dr' Scott Schaefer - PowerPoint PPT Presentation

1 / 68
About This Presentation
Title:

Dr' Scott Schaefer

Description:

Backface Culling. 11 /62. Backface Culling. counter clock-wise orientation, draw polygon ... Backface Culling. Is this all we have to do? No! ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 69
Provided by: symo5
Category:

less

Transcript and Presenter's Notes

Title: Dr' Scott Schaefer


1
Hidden Surfaces
  • Dr. Scott Schaefer

2
Hidden Surfaces
3
Hidden Surfaces
4
Hidden Surfaces
5
Backface Culling
6
Backface Culling
view direction
7
Backface Culling
view direction
8
Backface Culling
, draw polygon
view direction
9
Backface Culling
, cull polygon
view direction
10
Backface Culling
11
Backface Culling
counter clock-wise orientation, draw polygon
12
Backface Culling
clock-wise orientation, cull polygon
13
Backface Culling
  • Advantages
  • Improves rendering speed by removing roughly half
    of polygons from scan conversion
  • Disadvantages
  • Assumes closed surface with consistently oriented
    polygons
  • NOT a true hidden surface algorithm!!!

14
Backface Culling
  • Is this all we have to do?

15
Backface Culling
  • Is this all we have to do? No!
  • Can still have 2 (or more) front faces that map
    to the same screen pixel

16
Backface Culling
  • Is this all we have to do? No!
  • Can still have 2 (or more) front faces that map
    to the same screen pixel
  • Which actually gets drawn?

17
Painters Algorithm
  • Sort polygons according to distance from viewer
  • Draw from back to front
  • How do we sort polygons?

18
Painters Example
Sort by depth Green rect Red circle Blue tri
19
Painters Algorithm
20
Painters Algorithm
  • Sometimes there is NO ordering that produces
    correct results!!!

21
Painters Algorithm
  • Sort all objects zmin and zmax

22
Painters Algorithm
  • Sort all objects zmin and zmax
  • If an object is uninterrupted (its zmin and zmax
    are adjacent in the sorted list), it is fine

23
Painters Algorithm
  • Sort all objects zmin and zmax
  • If an object is uninterrupted (its zmin and zmax
    are adjacent in the sorted list), it is fine
  • If 2 objects DO overlap
  • 3.1 Check if they overlap in x
  • - If not, they are fine
  • 3.2 Check if they overlap in y
  • - If not, they are fine
  • - If yes, need to split one

24
Painters Algorithm
  • The splitting step is the tough one
  • - Need to find a plane to split one polygon by
    so that each new polygon is entirely in front of
    or entirely behind the other
  • - Polygons may actually intersect, so then need
    to split each polygon by the other

25
Painters Algorithm
  • The splitting step is the tough one
  • - Need to find a plane to split one polygon by
    so that each new polygon is entirely in front of
    or entirely behind the other
  • - Polygons may actually intersect, so then need
    to split each polygon by the other
  • After splitting, you can resort the list and
    should be fine

26
Painters Algorithm-Summary
  • Advantages
  • Simple algorithm for ordering polygons
  • Disadvantages
  • Sorting criteria difficult to produce
  • Redraws same pixel many times
  • Sorting can also be expensive

27
Depth (Z) Buffer
  • Simple modification to scan-conversion
  • Maintain a separate buffer storing the closest
    z value for each pixel
  • Only draw pixel if depth value is closer than
    stored z value
  • Update buffer with closest depth value

28
Depth (Z) Buffer
  • Advantages
  • Simple to implement
  • Allows for a streaming approach to polygon
    drawing
  • Disadvantages
  • Requires extra storage space
  • Still lots of overdraw

29
Binary Space Partitioning Trees
  • BSP tree organize all of space (hence partition)
    into a binary tree
  • - Preprocess overlay a binary tree on objects in
    the scene
  • - Runtime correctly traversing this tree
    enumerates objects from back to front
  • - Idea divide space recursively into half-spaces
    by choosing splitting planes
  • Splitting planes can be arbitrarily oriented

30
BSP Trees Objects
9
8
7
6
5
4
1
2
3
31
BSP Trees Objects
9
-
8
7

6
5
4
1
2
3
32
BSP Trees Objects
Put front objects in the left branch
-

9
-
8
7

6
9
8
5
6
1
4
2
3
7
5
4
1
2
3
33
BSP Trees Objects
Put front objects in the left branch
-

9
8
7
6
-

-

5
4
9
8
5
6
1
4
2
3
7
1
2
3
34
BSP Trees Objects
Put front objects in the left branch
-

9
8
7
6
-

-

5
4
1
-
-
-



1
2
3
3
8
9
5
6
2
4
7
35
BSP Trees Objects
Put front objects in the left branch
-

9
8
7
6
-

-

5
4
1
-
-
-



1
2
3
3
8
5
6
6
2
-
-


2
4
7
9
36
BSP Trees Objects
Put front objects in the left branch
-

9
8
7
6
-

-

5
4
1
-
-
-



1
2
3
3
8
5
6
6
2
-
-


2
4
7
9
When to stop the recursion?
37
Object Splitting
  • No bunnies were harmed in my example
  • But what if a splitting plane passes through an
    object?
  • - Split the object give half to each node
  • - Worst case can create up to O(n3) objects!

38
BSP Trees Objects
Correctly traversing this tree enumerates objects
from back to front
-

9
8
7
6
-

-

5
4
1
-
-
-



1
2
3
3
8
5
6
6
2
-
-


2
4
7
9
Traversal order?
39
BSP Trees Objects
Correctly traversing this tree enumerates objects
from back to front
-

9
8
7
6
-

-

5
4
1
-
-
-



1
2
3
3
8
5
6
6
2
-
-


2
4
7
9
Traversal order 8-gt9-gt7-gt6-gt5-gt3-gt4-gt2-gt1
40
Building a BSP Tree
  • Choose a splitting polygon
  • Sort all other polygons as
  • Front
  • Behind
  • Crossing
  • On
  • Add front polygons to front child, behind to
    back child
  • Split crossing polygons with infinite plane
  • Add on polygons to root
  • Recur

41
Building a BSP Tree
6
7
3
5
1
2
4
42
Building a BSP Tree
6
7
3
5
1
2
4
1
b
2,3,4,5,6,7
43
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2,6, 5-2
2,4,5-1,7-1
44
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-1
7-2,6, 5-2
b
f
4, 5-1
2
45
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-1
7-2,6, 5-2
b
f
4
2
b
5-1
46
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-1
7-2,6, 5-2
b
f
4
2
b
5-1
47
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-1
7-2,6, 5-2
b
f
4
2
b
5-1
48
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6, 5-2
2
b
5-1
49
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
2
b
b
5-2
5-1
50
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
2
b
b
5-1
5-2
51
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
2
b
b
5-1
5-2
52
Rendering with a BSP Tree
  • If eye is in front of plane
  • Draw back polygons
  • Draw on polygons
  • Draw front polygons
  • If eye is behind plane
  • Draw front polygons
  • Draw on polygons
  • Draw back polygons
  • Else eye is on plane
  • Draw front polygons
  • Draw back polygons

53
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
Traversal order
2
b
b
5-1
5-2
54
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
Traversal order 6-gt(5-2)-gt(7-2)-gt3-gt(5-1)-gt4-gt(7-
1)-gt2-gt1
2
b
b
5-1
5-2
55
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
Traversal order
2
b
b
5-1
5-2
56
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
Traversal order 1-gt2-gt(7-1)-gt4-gt(5-1)-gt3-gt(7-2)-gt
(5-2)-gt6
2
b
b
5-1
5-2
57
Building a BSP Tree
6
7-2
5-2
3
7-1
5-1
1
2
4
1
b
3
f
b
7-2
7-1
b
b
f
4
6
Traversal order?
2
b
b
5-1
5-2
58
Rendering with a BSP Tree
59
Rendering with a BSP Tree
  • Advantages
  • No depth comparisons needed
  • Polygons split and ordered automatically
  • Disadvantages
  • Computationally intense preprocess stage
    restricts algorithm to static scenes
  • Splitting increases polygon count
  • Redraws same pixel many times
  • Choosing splitting plane not an exact science

60
Improved BSP Rendering
  • Take advantage of view direction to cull away
    polygons behind viewer

61
Improved BSP Rendering
  • Take advantage of view direction to cull away
    polygons behind viewer

View frustum
62
Improved BSP Rendering
  • Take advantage of view direction to cull away
    polygons behind viewer

63
(No Transcript)
64
Scan Line Algorithm
  • Assume for each line of screen, we have
    scan-lines for all polygons intersecting that
    line
  • For each polygon, keep track of extents of scan
    line
  • Whenever the x-extents of two scan lines overlap,
    determine ordering of two polygons

65
Scan Line Algorithm
66
Scan Line Algorithm
67
Scan Line Algorithm
68
Scan Line Algorithm
  • Advantages
  • Takes advantage of coherence resulting in fast
    algorithm
  • Does not require as much storage as depth buffer
  • Disadvantages
  • More complex algorithm
  • Requires all polygons sent to GPU before drawing
Write a Comment
User Comments (0)
About PowerShow.com