May 2012 1
Back-Face Detection
( )A point , , is behind a polygon surface if 0,
where , , and are the plane parameters of the polygon. Test is
simplified by considering normal of face and viewing direction.
x y z Ax By Cz D
A B C D
+ + + <
( ), ,A B C=N
viewV
( )
view
view
A polygon is back face if 0. In a right-handed
viewing system viewing direction is along negative axis,
0,0, 1 . Then, a polygon is a back face if 0.
z
C
× >
= − ≤
V N
V
May 2012 2
Depth-Buffer Methods
Three surfaces overlapping pixel position (x,y) on the view plane.
The visible surface, S1, has the smallest depth value.
vx
vy
vz
3S
2S
1S
( ),x y
view plane
May 2012 3
( )
( )
Initialize each pixel ( , ) of depth buffer and frame buffer (color):
, 1. // Z is normalized to [0,1.0]
//
0;
, background color; initialize
for ea
to backgroun
h
d
c p
x y
depthBuf x y
frameBuf x y
=
=
Z - Buffer Algorithm
( )
( ) ( )
( )
olygon {
for each pixel , polygon {
if
// traverse all polygons
// rasterization
//( , , ) {
get (compute) , ;
check closer pixel
// compute color of pixel
x y
z x y depthBuf x y
color x y
d
∈
>
( ) ( ) ( ) ( ), , ; , , ;
}}}
epthBuf x y z x y frameBuf x y color x y= =
May 2012 4
Efficient Depth Calculation
Given the depth value in a vertex of a polygon, the depth of any
other point in the plane containing the polygon can be
calculated efficiently (additions only).
( )
( ) ( )
Depth is calculated from plane equatuion .
At rasterization along scan-line changes by 1. Therefore,
1 1 , and the ratio
is constant for the entire polygon.
z Ax By D C
x
z x A x By D C z A C A C
= − − −
±
+ = − + − − = − −  
May 2012 5
A-Buffer Method
It is named so since z-buffer is used for depth semantics and in
some sense a-buffer has the nature of the other end of alphabet. It
is an extension using antialiasing, area-averaging visibility
detection method, supporting transparency.
background opaque
surface
foreground
transparent surface
08/04/15©Zachary Wartell
Scan-Line Method
• Unlike z-buffer or A-buffer, scan-line method has depth info only for
a single scan-line.
• In order to require one scan-line of depth values, we must group
and process all polygons intersecting a given scan-line at the same
time before process the next scan-line
• Build table of edges of all polygons in scene. Maintain active-edge-
table as we visit each scan-line in scene. AET now contains edges
for all polygons at that scanline. Must maintain flag for each
surface to determine whether pixel on scan-line is inside that
surface.
scan-line
08/04/15©Zachary Wartell
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 depth
In this example we color from S1
– (B,C) to (F,G) only inside S2, so color from S2
B
A
D
C
G
F
E
H
S1 S2
Scan Line 1
Scan Line 2
Scan Line 3
08/04/15©Zachary Wartell
Scan-Line Method Generalization
• This basic approach fails when surfaces cut-
through each other or overlap. To generalize
we must divide surfaces to eliminate overlaps
08/04/15©Zachary Wartell
Depth-Sorting Method
• Painter’s Algorithm
• Approach:
– sorted surfaces by increasing depth
• may require surface splitting
– scan-convert surfaces in sorted order (back to
front)
• Use a sequence of sorting steps and tests of
increasing computational complexity to
handle all possible cases of polygon depth
orderings
08/04/15©Zachary Wartell
• Sort surfaces by each surface’s smallest z into
list:
(S1,S2,… Si… SN)
• For all Si ,i∈[2, N]
• If farthest surface SF has no z overlap render it.
(easy case)
• If there is z overlap with SF, we can still avoid
reordering if one of four conditions holds. So
we test these conditions…
Depth Sorting Details
z
SF=S1
Si
zmin2
zmax2
zmin1
zmax1
z
SF=S1
Si
zmin2
zmax2
zmin1
zmax1
farther from
PRP !
08/04/15©Zachary Wartell
Depth Sorting: Reorder Avoidance Tests
• We can avoid reorder if:
1) Bounding rectangles in xy don’t overlap
2) Sf is completely behind overlapping surface
relative to view position
3) Overlapping surface is completely in front of
Sf relative to view position
4) Boundary edges of projections of two
surfaces on projection plane don’t overlap
z
Sf
S2
xmin1 xmax1 xmin2 xmax2
1)
Sf
S2
2) 3)
z z
Sf
S2
08/04/15©Zachary Wartell
BSP-trees
Binary Space Partition is a relatively easy way to sort the polygons relative to the eyepoint
To Build a BSP Tree
1. Choose a polygon, T, and compute the equation of the plane it defines.
2. Test all the vertices of all the other polygons to determine if they are in front of, behind, or in
the same plane as T. If the plane intersects a polygon, divide the polygon at the plane.
3. Polygons are placed into a binary search tree with T as the root.
4. Call the procedure recursively on the left and right subtree.
Larry F. Hodges, Drew Kessler
08/04/15©Zachary Wartell
Traversing BSP-Tree
• Traverse the BSP tree such that the
branch descended first is the side that is
away from the eyepoint. This can be
determined by substituting the eye point
into the plane equation for the polygon at
the root.
• When there is no first branch to descend,
or that branch has been completed then
render the polygon at this node.
• After the current node's polygon has been
rendered, descend the branch that is
closer to the eyepoint.Larry F. Hodges, Drew Kessler
08/04/15©Zachary Wartell
Area-Subdivision Method
• Recursively subdivide viewplane into quadrants until:
– rectangle contains part of 1 projected surface
– rectangle contains part of no surface
– rectangle is size of pixel
08/04/15©Zachary Wartell
Area-Subdivision Method
• We need tests that can quickly determine tell if current area is part
of one surface or if further subdivision is needed.
• Four cases for relation between surface and rectangular area:
surrounding
surface
overlapping
surface
inside
surface
outside
surface
08/04/15©Zachary Wartell
Area-Subdivision: Stopping Conditions
• Recursive subdivision can stop when either:
1) a rectangle has all surfaces outside
2) a rectangle has exactly one inside, overlapping, or
surrounding surface
3) a rectangle has one surrounding surface and the
surface occludes all other surfaces in the area
• For efficiency:
– compare rectangle to projected surface bounding
rectangle first. Only perform exact interaction
test if necessary. If single bounding rect.
intersects rectangle, test for exact intersection
and color the framebuffer for the intersection of
08/04/15©Zachary Wartell
Octrees
• Octree:
– partitions 3-space by a regular, recursive subdivision of 3-space into
axis-aligned boxes
– 3D objects are stored in the octree node that contains them.
Recursively subdivide until each octree node is either empty, a
homogeneous volume, or contains single object that’s “easy” to
compute visibility (example can use back-face culling alone).
3 2
0 1
4 5
6
7
0 1 2 3 4 5 6 7
Any of these octants could then be
recursively subdivide
08/04/15©Zachary Wartell
Ray-Casting Method
• based geometric optics method that trace rays of light
• “backwards” light path tracing
• compare to depth buffer (surfaces to pixels versus pixel to surfaces)
• special case of ray-tracing
COP
pixel
view plane

rural marketing ppt

  • 1.
    May 2012 1 Back-FaceDetection ( )A point , , is behind a polygon surface if 0, where , , and are the plane parameters of the polygon. Test is simplified by considering normal of face and viewing direction. x y z Ax By Cz D A B C D + + + < ( ), ,A B C=N viewV ( ) view view A polygon is back face if 0. In a right-handed viewing system viewing direction is along negative axis, 0,0, 1 . Then, a polygon is a back face if 0. z C × > = − ≤ V N V
  • 2.
    May 2012 2 Depth-BufferMethods Three surfaces overlapping pixel position (x,y) on the view plane. The visible surface, S1, has the smallest depth value. vx vy vz 3S 2S 1S ( ),x y view plane
  • 3.
    May 2012 3 () ( ) Initialize each pixel ( , ) of depth buffer and frame buffer (color): , 1. // Z is normalized to [0,1.0] // 0; , background color; initialize for ea to backgroun h d c p x y depthBuf x y frameBuf x y = = Z - Buffer Algorithm ( ) ( ) ( ) ( ) olygon { for each pixel , polygon { if // traverse all polygons // rasterization //( , , ) { get (compute) , ; check closer pixel // compute color of pixel x y z x y depthBuf x y color x y d ∈ > ( ) ( ) ( ) ( ), , ; , , ; }}} epthBuf x y z x y frameBuf x y color x y= =
  • 4.
    May 2012 4 EfficientDepth Calculation Given the depth value in a vertex of a polygon, the depth of any other point in the plane containing the polygon can be calculated efficiently (additions only). ( ) ( ) ( ) Depth is calculated from plane equatuion . At rasterization along scan-line changes by 1. Therefore, 1 1 , and the ratio is constant for the entire polygon. z Ax By D C x z x A x By D C z A C A C = − − − ± + = − + − − = − −  
  • 5.
    May 2012 5 A-BufferMethod It is named so since z-buffer is used for depth semantics and in some sense a-buffer has the nature of the other end of alphabet. It is an extension using antialiasing, area-averaging visibility detection method, supporting transparency. background opaque surface foreground transparent surface
  • 6.
    08/04/15©Zachary Wartell Scan-Line Method •Unlike z-buffer or A-buffer, scan-line method has depth info only for a single scan-line. • In order to require one scan-line of depth values, we must group and process all polygons intersecting a given scan-line at the same time before process the next scan-line • Build table of edges of all polygons in scene. Maintain active-edge- table as we visit each scan-line in scene. AET now contains edges for all polygons at that scanline. Must maintain flag for each surface to determine whether pixel on scan-line is inside that surface. scan-line
  • 7.
    08/04/15©Zachary Wartell Scan-Line MethodBasic 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 depth In this example we color from S1 – (B,C) to (F,G) only inside S2, so color from S2 B A D C G F E H S1 S2 Scan Line 1 Scan Line 2 Scan Line 3
  • 8.
    08/04/15©Zachary Wartell Scan-Line MethodGeneralization • This basic approach fails when surfaces cut- through each other or overlap. To generalize we must divide surfaces to eliminate overlaps
  • 9.
    08/04/15©Zachary Wartell Depth-Sorting Method •Painter’s Algorithm • Approach: – sorted surfaces by increasing depth • may require surface splitting – scan-convert surfaces in sorted order (back to front) • Use a sequence of sorting steps and tests of increasing computational complexity to handle all possible cases of polygon depth orderings
  • 10.
    08/04/15©Zachary Wartell • Sortsurfaces by each surface’s smallest z into list: (S1,S2,… Si… SN) • For all Si ,i∈[2, N] • If farthest surface SF has no z overlap render it. (easy case) • If there is z overlap with SF, we can still avoid reordering if one of four conditions holds. So we test these conditions… Depth Sorting Details z SF=S1 Si zmin2 zmax2 zmin1 zmax1 z SF=S1 Si zmin2 zmax2 zmin1 zmax1 farther from PRP !
  • 11.
    08/04/15©Zachary Wartell Depth Sorting:Reorder Avoidance Tests • We can avoid reorder if: 1) Bounding rectangles in xy don’t overlap 2) Sf is completely behind overlapping surface relative to view position 3) Overlapping surface is completely in front of Sf relative to view position 4) Boundary edges of projections of two surfaces on projection plane don’t overlap z Sf S2 xmin1 xmax1 xmin2 xmax2 1) Sf S2 2) 3) z z Sf S2
  • 12.
    08/04/15©Zachary Wartell BSP-trees Binary SpacePartition is a relatively easy way to sort the polygons relative to the eyepoint To Build a BSP Tree 1. Choose a polygon, T, and compute the equation of the plane it defines. 2. Test all the vertices of all the other polygons to determine if they are in front of, behind, or in the same plane as T. If the plane intersects a polygon, divide the polygon at the plane. 3. Polygons are placed into a binary search tree with T as the root. 4. Call the procedure recursively on the left and right subtree. Larry F. Hodges, Drew Kessler
  • 13.
    08/04/15©Zachary Wartell Traversing BSP-Tree •Traverse the BSP tree such that the branch descended first is the side that is away from the eyepoint. This can be determined by substituting the eye point into the plane equation for the polygon at the root. • When there is no first branch to descend, or that branch has been completed then render the polygon at this node. • After the current node's polygon has been rendered, descend the branch that is closer to the eyepoint.Larry F. Hodges, Drew Kessler
  • 14.
    08/04/15©Zachary Wartell Area-Subdivision Method •Recursively subdivide viewplane into quadrants until: – rectangle contains part of 1 projected surface – rectangle contains part of no surface – rectangle is size of pixel
  • 15.
    08/04/15©Zachary Wartell Area-Subdivision Method •We need tests that can quickly determine tell if current area is part of one surface or if further subdivision is needed. • Four cases for relation between surface and rectangular area: surrounding surface overlapping surface inside surface outside surface
  • 16.
    08/04/15©Zachary Wartell Area-Subdivision: StoppingConditions • Recursive subdivision can stop when either: 1) a rectangle has all surfaces outside 2) a rectangle has exactly one inside, overlapping, or surrounding surface 3) a rectangle has one surrounding surface and the surface occludes all other surfaces in the area • For efficiency: – compare rectangle to projected surface bounding rectangle first. Only perform exact interaction test if necessary. If single bounding rect. intersects rectangle, test for exact intersection and color the framebuffer for the intersection of
  • 17.
    08/04/15©Zachary Wartell Octrees • Octree: –partitions 3-space by a regular, recursive subdivision of 3-space into axis-aligned boxes – 3D objects are stored in the octree node that contains them. Recursively subdivide until each octree node is either empty, a homogeneous volume, or contains single object that’s “easy” to compute visibility (example can use back-face culling alone). 3 2 0 1 4 5 6 7 0 1 2 3 4 5 6 7 Any of these octants could then be recursively subdivide
  • 18.
    08/04/15©Zachary Wartell Ray-Casting Method •based geometric optics method that trace rays of light • “backwards” light path tracing • compare to depth buffer (surfaces to pixels versus pixel to surfaces) • special case of ray-tracing COP pixel view plane