0% found this document useful (0 votes)
112 views67 pages

Solid Area Scan Conversion or Visible Surface Detection

Uploaded by

shivam kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views67 pages

Solid Area Scan Conversion or Visible Surface Detection

Uploaded by

shivam kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 67

Solid Area Scan Conversion

or
Visible Surface Detection
P (viewing point)

P (viewing point)
visible-surface detection
Given a set of 3D object and viewing point
This process find which lines or parts of the object
are visible from the viewing point ,
So that it can draw only those part

Find which surfaces are visible


 visible-surface detection
Remove those surfaces that should not be visible
 hidden-surface removal.
Visible Surface Detection
algorithm
• 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
Visible surface detection algorithms are based on
following 2 concepts:
– Sorting : It facilitate the depth comparison by ordering
the object surface or lines in the scene
according to their distance from the view plane
– Coherence : This method are used to take advantage of
regularities in a scene
( It contain intervals of constant pixel intensity &
scan pattern change (a little), from one line to other)
Visible Surface Detection
Algorithms
• Depth Comparison
• Z-buffer or Depth Buffer
• Depth Sorting or Painter’s
• Area Subdivision or Warnock’s

 Back Face detection


 A – Buffer
 Scan line
 BSP tree
 OCTree
Depth Comparison(image space)
If 2 pt.s lie on same projection line then depending on the depth
comparison the pt which is closer will be visible

A. Parallel projection
Let projection plane  XY plane (orthographic proj)
z axis
2 pt.s p1(x1,y1,z1) & p2(x2,y2,z2) in p1
3D are on same projection line  p2 p3

if (x1=x2) & (y1=y2) but (z1!=z2) p4


if(z1<z2)
P1’
then p1 is visible Pro P2’
P4’/p3’
y axis
Else j e ctio
x axis
nP
p2 is visible lan
e
B. Perspective Projection
Given –> view plane – XY plane
c.o.p -- Zf

z axis

p1 p2 p3 p4 p5 pn p1

p3

Obscured by p2
Obscures p4
P1’ P2’
P4’
y axis

p4 p5 p6 pn x axis Zf
EM
B L
RO
P Given
Let 3 3D pt.s are given p1(1,2,0), p2(3,6,20), p3(2,4,6).
C.O.P is (0,0,-10)
Problem
Determine which pt obscures other
p1 p2 p3
Z-Buffer(Extension of frame buffer) (Image space)
• Frame buffer  stores the intensity value of each
pixel in image space.
• Z-buffer(depth buffer)  stores the z-coordinate
value of each pixel in image space.

When an object in 3D is projected on a view plane as


projection pt(x,y) 
it’s z-value is compared with the previously stored
z-value. If it is smaller then new pixel is written to the
frame buffer and z-buffer is updated with new z-value
S3

S2
y axis
S1

Z3

Z2

Z1
x axis

z axis Order of scanning is


S2s3s1
Two buffers are needed: depth and color.
– Initialize the buffers:
depth(x,y) = Zbackground
color(x,y) = Ibackground

–For (each position on each polygon surface)


calculate z for each (x,y)position
if (z(x,y) < depth(x,y))
{
depth(x,y) = Z
color(x,y) = Isurf
}
Painter’s algorithm
(image space & object space)
This algorithm process the polygon as if they
were being painted into the screen in order of
their distance from the viewer.

It has following basic steps 


 Surface are sorted in order of decreasing depth
 Surface are scan converted in order, starting
with surface of greatest depth.
By Painter’s
Algorithm
STEP 1 6 5
Store the polygon in array by
uniquely numbering them 4
2
3
1 2 3 4 5 6 1

STEP 2
For each polygon maintain a linked list named as front list
which will contain the polygon no. in front of it in a sequence

STEP 3
For each polygon maintain a counter named as behind
counter which will contain the no. of polygon behind to it
n 6 5
ti o
liza
i ti a 2 4
In 3
1

Polygon Array Front List Behind Counter


5 2
1
2 4 3 1 0
1 5 2
3
4 3 1
2
5
0
6
STEP 4 (loop)
Repeat step 5 & step 6 till all polygon behind counter is -1

STEP 5
Draw all polygon’s whose behind counter is 0

STEP 6
After drawing
a) Step through the polygon in the front list, decrease
their behind counter by 1.
b) For drawn polygon make it’s behind counter as -1
ITERATION -- 1 6

New
Polygon Array Front List Behind Counter Behind Counter
2 1
1 5
0 -1
2 4 3 1
1 5 2 1
3
3 1 0
4
2 2
5
0 -1
6
ITERATION -- 2 6

2 4

New
Polygon Array Front List Behind Counter Behind Counter
5 1 1
1
2 4 3 1 -1 -1
1 5 1 0
3
3 0 -1
4
2 2
5
-1 -1
6
ITERATION -- 3 6

2 4
3

New
Polygon Array Front List Behind Counter Behind Counter
5 1 0
1
2 4 3 1 -1 -1
1 5 0 -1
3
3 -1 -1
4
2 1
5
-1 -1
6
ITERATION -- 4 6

2 4
3
1
New
Polygon Array Front List Behind Counter Behind Counter
5 0 -1
1
2 4 3 1 -1 -1
1 5 -1 -1
3
3 -1 -1
4
1 0
5
-1 -1
6
ITERATION -- 5 6 5

2 4
3
1
New
Polygon Array Front List Behind Counter Behind Counter
5 -1 -1
1
2 4 3 1 -1 -1
1 5 -1 -1
3
3 -1 -1
4
0 -1
5
-1 -1
6
Disadvantage
For following type of polygons this will not work
Solution
• Cyclically overlapping polygons require cutting
• Piercing polygons require clipping
Back-Face Detection
• A fast and simple object-space method for
locating back faces
• A point (x,y,z) is “inside” a polygon surface
with plane parameters A, B, C, D if :
Ax + By + Cz + D < 0
• When an inside point is along the line of sight
to the surface, the polygon must be a back
face and so cannot be seen
Back-Face Detection
• The test is simplified by considering the normal
vector N to the polygon and the viewing vector V

• This is back face if


V·N>0
Back-Face Detection
A point  x, y, z  is behind a polygon surface if Ax  By  Cz  D  0,
where A, B, C and D are the plane parameters of the polygon. Test is
simplified by considering normal of face and viewing direction.

N   A, B, C 

Vview

A polygon is back face if Vview  N  0. In a right-handed


viewing system viewing direction is along negative z axis,
Vview   0, 0, 1 . Then, a polygon is a back face if C  0.
May 2012 26
BSP Trees
• Binary space partitioning is an efficient method for
determining object visibility
– Binary Space Partition is a relatively easy way to sort
the polygons relative to the eyepoint

• Paint surfaces into the frame buffer from back to front

• Particularly useful when the view reference point


changes, but the objects are at fixed positions
BSP Tree Construction
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.
3. If the plane intersects a polygon, divide the polygon at the plane
4. Polygons are placed into a binary search three with T as the root
5. Call the procedure recursively on the left and right subtree
BSP tree building
• a root polygon is chosen (arbitrarily) which divides the
region into 2 half-spaces (2 nodes =>front and back)

• a polygon in the front half-space is chosen which divides


the half-space into another 2 half-spaces

• the subdivision is repeated until the half-space contains a


single polygon (leaf node of the tree)

• the same is done for the back space of the polygon


Building BSP-Trees
• Choose polygon (arbitrary)
• Split its cell using plane on which polygon lies
– May 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

03/12/02
BSP-Tree Example
A
C A
- +
4 3
B C

B - + - +

1
3 2 4 1

03/12/02
Building Example
• We will build a BSP tree, in 2D, for a 3 room building
5
– Ignoring doors
• Splitting edge order is shown
– “Back” side of edge is side with the number

2
3 4

6
Building Example (1)
5
1
- +

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


3b 2 4b

1
3a 4a

03/12/02
Building Example (2)
5b 5a
1
- +

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

1
3a 4a

03/12/02
Building Example (3)
5b 5a
1
- +

2
3a
-
+ + 3b 2 4b
4a, 6 4b, 5a 3b
+
5b 1
3a 4a

03/12/02
Building Example (Done)
5b 5a
1
- +

2
3a
-
+ + 3b 2 4b
4a 4b 3b
+ + +
6 5a 5b 1
3a 4a

03/12/02
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.

04/24/2020
Traversing BSP-Tree Algorithm
Procedure DisplayBSP (tree: BSP_tree)
Begin
If tree is not empty then
If viewer is in front of the root then
Begin
DisplayBSP(tree.back_child)
displayPolygon(tree.root)
DisplayBSP(tree.front_child)
End
Else
Begin
DisplayBSP(tree.front_child)
displayPolygon(tree.root)
DisplayBSP(tree.back_child)
End
End
Traversing BSP Trees
EYE 1
A
F2
+Z B C
D
E1 F1 D
F1 C
E2 F2
E2
A

E1
B

+X -X

EYE 2
Splitting Triangles
If all our polygons are triangles then we
always divide a triangle into more
triangles when it is intersected by the
plane.

• It is possible for the number of triangles to increase


exponentially but in practice it is found that the increase
may be as small as two fold.

• A heuristic to help minimize the number of fractures is to


enter the triangles into the tree in order from largest to
smallest.

04/24/2020 ©Zachary Wartell


Larry F. Hodges, Drew Kessler
Discussion:

• Back face removal is achieved by not displaying a polygon if the


viewer is located in its back half-space

• It is an object space algorithm (sorting and intersection calculations


are done in object space precision)

• If the view point changes, the BSP needs only minor re-rrangement.

• A new BSP tree is built if the scene changes

• The algorithm displays polygon back to front (cf. Depth-sort)


Area Subdivision or Warnock’s Algo

This method is essentially an image-space method,


but object-space operations can be used to
accomplish depth ordering of surface.

It takes advantage of area coherence in a scene by


locating those view areas that represent part of a
single surface.
Area Subdivision or Warnock’s Algo

This method can be applied by successively dividing


the total viewing area into smaller and smaller
rectangles until each area is the projection of part
of a single visible surface or no surface at all.

This process can be continued until the


subdivisions are easily analyzed as belonging to a
single surface or until they are reduced to the size
of a single pixel.
Quad Tree Starting with full screen
as the initial area, the
1 3 algo. divides it to 4
2 4 smaller area at each
stage depending on the
visibility test
1.1 1.3
1.2 1.4 3
2 4

1.3
1.2 1.4
Classification of polygons(p) w.r.t the given area(A)
1. Surrounding Polygon
P A

2. Intersecting Polygon A P

3. Contained Polygon AP

4. Disjoint Polygon A P

PVPL – Potentially visible polygon list


Category 1,2,3
Algorithm

STEP 1
Initialize the area to be the whole scene
STEP 2
Create PVPL w.r.t the current area

STEP 3
Sort PVPL in terms of Zmin

STEP 4
Place the polygon in their appropriate category
STEP 5 (Perform the Visibility Test)
a. If all polygons are disjoint to the area, then set the
color of area as background color

P A P
P

b. If there is one polygon in PVPL & that is


contained, then color that polygon & color the
remaining area as back ground color
A
P
c. If there is one surrounding polygon is present,
then color the area as polygon color

P A

d. Let PVPL contains n no. of polygon where there is


one surrounding polygon which is closest from the
view pt, then color the area as surrounding polygon
color
e. If the area is a pixel & PVPL contains set of points, then
compute Z(x,y) of all pixel & set the color to the color
of minimum Z(x,y) point.
STEP 6
If none of the case has occurred, sub-divide the screen
Area into 4 sub area
For each area go to step 2
Octree
• Extension of area-subdivision method
• Projecting octree nodes onto the viewplane
– Front-to-back order  Depth-first traversal
• The nodes for the front suboctants of octant 0 are
visited before the nodes for the four back suboctants
• The pixel in the framebuffer is assigned that color if no
values have previously been stored 6
– Only the front colors are loaded 4 5

0 1

7 3 2
52
Displaying An Octree
• Map the octree onto a quadtree of visible
areas
– Traversing octree nodes from front to back in a
recursive procedure
– The quadtree representation for the 6

visible surfaces is loaded into the 4


5

framebuffer
1
0

7 2
3
53
Octants in Space
Octrees
• Visible-surface identification is accomplished
by searching octree nodes in a front-to-back
order
Octree Methods
In these methods, octree nodes are projected onto
the viewing surface in a front-to-back order.

Any surfaces toward the rear of the front octants


(0,1,2,3) or in the back octants (4,5,6,7) may be
hidden by the front surfaces.

With the numbering method (0,1,2,3,4,5,6,7), nodes


representing octants 0,1,2,3 for the entire region are
visited before the nodes representing octants 4,5,6,7.

Similarly the nodes for the front four sub-octants of


octant 0 are visited before the nodes for the four back
sub-octants.
When a colour is encountered in an octree node, the
corresponding pixel in the frame buffer is painted only if no
previous color has been loaded into the same pixel position.

In most cases, both a front and a back octant must be


considered in determining the correct color values for a
quadrant.

But If the front octant is homogeneously filled with some color,


we do not process the back octant.

If the front is empty, it is necessary only to process the rear


octant.

If the front octant has heterogeneous regions, it has to be


subdivided and the sub-octants are handled recursively.
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).
4 5

0 1 2 3 4 5 6 7
0 1
6
7
3 2

04/24/2020
Any of these octants could then be
recursively subdivide
Geometric forms & models
Modeling of object or picture means describing
them to the computer so as to produce visual
display that simulate the real thing

For describing we need a set of


primitives /geometric forms

Simple Complex
• Points • Curved Segment
• Lines • Curved Surface
• Poly lines • Quadratic Surface
• Polygon
• Polyhedron

Highly realistic representation use color, shading & texture


Point Pt p in 2D p(x,y) and in 3D p(x,y,z)
Line In 2D it specified by end pt (x1,y1) to (x2,y2)
In 3D it specified by end pt (x1,y1,z1) to (x2,y2,z2)
Poly Line Chain of connected line segments from pt p0 to pn
Polygons A closed poly lines where initial pt & final pt
coincide. It specified by vertex & edge information
Planner polygon – When all vertex lie on same
plane
Polyhedron A closed polygonal net in which each polygon
(face) is planner.
It is solid object
Wireframe Model
Representation of polygonal net/ polygonal mesh

Here representation of any 3D object can be done by


vertex, edge and polygon information
In 3 ways we can represent
 Explicit vertex list
 Polygon Listing
 Explicit edge Listing
D C
Problem E H
Representation of this object A B
1. Explicit vertex list F G
Here the information of the object will be stored in the
order in which they will be encountered by travelling
around the complete model
Let the travelling sequence is ---
A -> B -> C -> D ->A -> F -> E -> D -> C
->H ->E -> F -> G -> H->G ->B
D C
H
E
A B
G
F
Disadvantage
 In efficient for a complete polygonal net where shared
vertices are repeated several time.
( More space complexity)
 For displaying the polygonal net from this type of
stored information shared edges are drawn several times
(More time complexity)

Advantage

 It is useful for single polygon.


1. Polygon listing
Here each vertex is stored exactly once in vertex list
V= (v0 ..vn)
Here each polygon is stored exactly once in polygon list
by pointing or indexing to the vertex list
The vertex list is --- V={A,B,C,D,E,F,G,H}
The polygon list is -- P= {p1,p2,p3,p4,p5,p6}
P1 ={A,B,C,D}  {V(0),V(1),V(2),V(4)}
P2 = {C,D,E,H} 
P3 = {A,B,E,F} 
D C P4 = {A,B,G,F} 
E H P3 = {A,B,E,F} 
B P6 ={E,F,G,H}  {V(4),V(5),V(6),V(7)}
A
G
F
Disadvantage
 Shared edges are drawn several times in displaying
through this method
(time complexity)
Advantage
 More efficient than explicit vertex list
1. Edge listing
Here each vertex is stored exactly once in vertex list
V= (p0 ..pn)
Each edge is stored exactly once in edge list by pointing to
the 2 vertex of vertex list for defining every edge.
Each polygon is stored exactly once in polygon list
by pointing or indexing to the edge list
Drawing will be done by considering the edge list
D C
E H

A B
G
F
Disadvantage
 none
Advantage
 Used to represent more general wireframe model

Advantage (of wire frame model)


 Wire frame model are used in engineering application
 As they are composed of straight lines
 Easy to construct
 Easy to clip & manipulate

Disadvantage (of wire frame model)


 For achieving the realistic model which are highly
curved object , here huge no of polygons are needed

You might also like