Full Notes Vis Surf Det
Full Notes Vis Surf Det
DETECTION
The problem of Visibility – Occlusion.
Problem Definition:
Given a set of 3
3-D
D surfaces to be
projected onto a 2-D screen, obtain the
nearest surface corresponding to any point
on the screen.
• Back-face Detection
• Depth (Z) buffer method
• Scan-line method
• Depth-sorting
ept so t g method
et od
• Area-subdivision method
• Octree methods
• A-buffer method
• BSP Trees
• Ray casting method
Visible
Vi ibl surface
f techniques
h i are 3D
versions of sorting algorithms
– basically
b i ll compare depth.
d th
Back face Culling
g or removal
A Polygon (in 3D) is a back face if:
V N > 0.
V.N 0
Let V = (0,
(0 00, Vz) and N = Ai + Bj + Ck.
Ck
Then V
V.N
N = Vz.C;
C;
V
How to g
get normal vector (
(N)
) for a
3D surface, polygon ?
R Q
R=PXQ φ
P
-R
Brighter Darker
Side side
Take
T k the
th order
d off vertices
ti to
t be
b
counter-clockwise for the brighter side.
i=1,2,…,n.
c = (X i −X j )(Yi + Y j )
i =1
Compute: If i = n,
n j=1
n
a = (Yi −Y j )(Z i + Z j )
i =1
n
b = (Z i −Z j )(X i + X j ) where j = i + 1
i =1
n
c = (X i −X j )(Yi + Y j )
i =1
If i = n, j = 1
T k the
Take th expression
i off “c”:
“ ”
Can you relate that to one property of
the 2
2-DD polygon
pol gon in X-Y
X Y plane?
a, b and c also describe the projection
surface of the polygon on the Y-Z, Z-X and
X-Y planes (or along the X, Y and Z axis)
respectively.
i l
c = (X1 −X2)(Y1 +Y2) + (X2 −X3)(Y2 +Y3) + (X3 −X1)(Y3 +Y1)
= X1(Y2 −Y3)+X2(Y3 −Y1)+X3(Y1 −Y2)
If A is the total area of the polygon
polygon, the
projected areas are:
•P
Partially
ti ll hidden
hidd faces
f cannott be
b determined
d t i d
by this method
COP
Each (
(X,Y,Z)
, , )ppoint on a p
polygon
yg
surface, corresponds to the orthographic
projection point (X, Y) on the view plane.
(ii)
( ) Refresh Buffer: To store the intensity
y
value at each position (X, Y).
Depth-buffer
Depth buffer
or
Z-buffer
ff method
COP
Steps for Processing:
(a) Initialize depth(X,Y) = Z max
∀(X,
(X Y)
IB = background refresh(X,Y) = I B
intensity
(i)
( ) Calculate depth
p Z for each p
position
(X, Y) on the polygon.
depth (X, Y) = Z;
X X+1
A
Z X +1 = Z X − ;
C
A
+B
ZY + 1 = ZY + m ;
C
F
For a vertical
ti l edge:
d Z’ = Z + B/C;
B/C
So to implement the algorithm,
algorithm three
constants are required for each surface:
A
( + B))
A m B
− , ,
C C C
Wh t iis th
What the special
i l condition,
diti C = 0?
Using the above three constants, we can
keep calculating the successive depth values
along
g and for successive scanlines. Similar
approaches can be used for curved surfaces:
Z = f(X,
( Y).)
Z Buffer Algo:
Z-Buffer
for all (x,y)
depth(x y) = -∞ /* Watch this change */
depth(x,y)
refresh(x,y) = IB
4 4
4 4
Z-Buffer
Z Buffer
values
9 8 9 8
8 7 4 7 8 7 4
4 4 7 6 5 4
Z-values
Z l off th
the 4 4 9 8 7 6 5
coordinates: 4 4 8 7 7 6 5
9 8
7 8 7 4
7 6 5 4
Z-Buffer
values
IMAGES (after pseudo
pseudo-texture
texture rendering)
V
V
SCAN-LINE
SCAN LINE Algorithms (for VSD)
Extension of 2-D Scanline (polyfill) algorithm.
Plane Shading
ID IN/OUT
Coeffs.
Coe s Info.
Take Adjacent (not successive) pairs of intersections to fill;
FILL (within pair) if POLY_FLAG is set to IN.
B E
L1
L2
L3
D
C
L4
F
L5
L3
ABC IN; ABC IN; ABC OUT;
DEF OUT DEF IN. DEF IN.
L1
L2
L3
D
C
L4
F
L5
AET Contents
Scan Line Entries
L5 AB CA
L4 AB CA FD EF
L3, L2 AB DE BC EF
L1 AB BC DE EF
Three non-intersecting
non intersecting polygons
pol gons
J B I
E
D C
F
A
G H
ZMax1
S1
ZMin1
ZMax2
S2
ZMin2
X
Z
Since,, ZMin1 > ZMax2 no overlapp occurs.
S1 is first scan converted, and then S2.
This g
goes on, as long g as no overlap occurs.
ZMax1 S1
ZMin1
ZMax2 S2
ZMin2 V
X
Z
If depth overlap occurs, additional
comparisons are necessary to reorder the
surfaces.
The following set of tests are used to
ensure that no re-orderingg of surfaces is
necessary:
Four(4) Tests in Painter’s algorithm
4.The
4 The projections of the ttwo
ossurfaces
rfaces onto
the view plane do not overlap.
T
Tests must be
b performed
f d iin order,
d as specified.
ifi d
S2
If we have X
S1
overlap, check
f
for th
the rest.
t
Z X1 X2 X3 X4 X
TEST #2:
Surface S is completely behind the
overlapping surface relative to the viewing
position.
S1
S2
Z X
S2
S1
Z X
Four(4) Tests in Painter’s algorithm
- revisited
1.The boundary rectangles in the X-Y plane
for the two surfaces do not overlap.
overlap
2.Surface
2 Surface S is completely behind the
overlapping surface relative to the viewing
position.
position
3.The
3 The overlapping surface is completely in
front of S relative to the viewing position.
Painter’s Algorithm
Case Study - I
S2
S1
X
Z
Initial
I iti l order:
d
S1 -> S2
S1 -> S2
S2, X
Z
Test 1 passed.
S1 S2
S2 S1
0.5 0.5 0
0.5 0.5
0 0 0
X Fig. B X
Fig A
Fig.
• Works in image-space
image space
• Divide-and-conquer
q strategy.
gy
WARNOCK’s
WARNOCK s
Algorithm
Possible relationships of the area of interest
(rectangular,
g AOI) and the projection
j of the
polygon:
1.Surrounding
1 Surrounding polygons are completely
overlapping the area of interest.
4. Disjoint
j polygons
p yg area completely
p y outside
the area.
Four cases of Polygon
yg p position w.r.t rectangular
g AOI.
Intersecting
S
Surrounding
di
Contained
Disjoint
Treat interior part of the intersection
and contained as equivalent. Disjoint is
irrelevant The decisions about division of an
irrelevant.
area is based on:
2.Only
y one intersectinggppart or interior
(contained): Fill the area with background
color and then scan-convert the polygon.
Z
Z
Intersection with:
Contained Polygon Surrounding
Polygon
Intersecting Polygon
Four cases of Polygon
yg p position w.r.t rectangular
g AOI.
Intersecting
S
Surrounding
di
Contained
Disjoint
Case Studies – examples of
(iii) (iv)
( )
BSP (Binary Space Partition) trees
P1
P2 C
A
D
P1
B BP F B
FP
FP
BP P2F P2B
F B F B
BSP (Binary Space
A C B D
Partition) trees
Salient feat
features:
es
• In the tree
tree, the objects are represented as
terminal nodes with front objects as left
branches and back objects as right
branches.
• BSP tree’s root is a polygon selected from
those to be displayed.
• The
h algorithm
l i h terminates
i when
h each
h node
d
contains only a single polygon.
5a 5
2
3 5b
1 3
4
1 4
2 5b
5a
5
5a 5 4
2
3
5b
1 3 1
4
2
5
2
3
1 3
2 4 4
5a 1 5b
5a
5
2
V
5b 3
1 3
4 2 5b
1 5a 4
Also see:
Other applications:
potential visibility sets;
• Robot navigation
KD trees, R+-trees;
• Collision Detecion
Bounding Volume Hierarchy (BVH)
• GIS
and
Shadow Volume BSP Tree (SVBSP) • Image Registration
Display
p y list of a BSP tree
• BSP tree may be traversed in a “modified in-
order tree
tree” walk to yield a correctly priority-
ordered polygon list for an arbitrary
viewpoint.
viewpoint
• If the viewer is in the root polygon’s front
half space
space, the algorithm must first display:
1.All polygons in the root’s rear half-
space.
space
2.Then the root.
3.And finally all polygons in the front
half-space.
• Use back face culling
• Each of the root’s children is recursively
processed.
processed
Disadvantages
g
COP
Figure for illustrating
VSD - Ray
R Tracing
T i
For Ray-tracing:
• Shoot ray from eye point through pixel (x,y)
into scene
• Li
Line off Si
Sight
ht off each
h pixel
i l iis iintersected
t t d
with all surfaces
• Need
d off an efficient
ffi i ray-surface
f iintersection
i
technique
• Can be parallelized
Surface – RAY = 0;
Eqns. for
LINE: x = x0 +tΔx ; y = y0 +tΔy ; z = z0 +tΔz ;
SPHERE: (x − a) + ( y −b) + (z −c) = r
2 2 2 2
Substitution
gives us:
( x0 + tΔx) − 2a( x0 + tΔx) + a
2 2
Collecting terms
gives us:
(Δx + Δy + Δz )t +
2 2 2 2
Cases:
• No real roots - Surface and ray do
not intersect
• Two
T reall roots
t - From b
F both
th
intersections, get
th one with
the ith the
th
smallest value of t.
What is the shade, at that point of
i t
intersection?
ti ?
• Gaussian
G i
• Ellipsoid
• Directional sinusoid
• Torus
Eqns. for
LINE : x = x0 + tΔx ; y = y0 + tΔy ; z = z0 + tΔz ;
PLANE : A + By
Ax B + Cz
C +D=0
Substitution gives us:
( Ax0 + By0 + Cz0 + D)
t =−
( AΔx + BΔy + CΔz)
• Denominator should not be zero;
• Global Illumination
• Radiosity
R di it
• The
Th Metropolis
M t li light
li ht transport
t t (MLT) - SIGGRAPH 1997
• Bi-directional
Bi directional Ray Tracing
Rendering with global illumination: Light is reflected by
surfaces, and colored light transfers from one surface to
another Color from the red wall and green wall (latter not
another.
visible) reflects onto other surfaces in the scene. Also
notable is the caustic projected onto the red wall from
li ht passing
light i through
th h the
th glass
l sphere.
h
Comparison
p of VSD (
(HSR)
) techniques
q
Algorithms/
Memory Speed
Methods
Two Depth
Z B ff
Z-Buffer
arrays complexity
Apriori
One
Painter’s sorting helps
array
y
speed-up
d
Object ( p
O(#pixels,
Ray casting data #surfaces or
base objects)
Scanline, Area
- Slowest
sub-division
sub division
Algorithms Issues in
Remarks
/Methods Implementation
Scan conversion,,
Z B ff
Z-Buffer C
Commonly
l used
d
Hardware
Splitting and
sorting the
Painter’s Scan conversion
major
bottleneck
Excellent
Spatial data
Ray
y casting
g structures helpp for CSG,
speedup h d
shadows,
transparency
Cannot be
Scanline, Area
Hard generalized for non-
sub-division
sub division
polygonal models.
VSD - “Visible Surface Detection”
i also
is l called:
ll d
Problem:
Take any VSD algorithm and
g
convert to an HLE algorithm
End of lectures on
VISIBLE SURFACE
DETECTION