CS3500 Computer Graphics Visible Surface Determination: P. J. Narayanan
CS3500 Computer Graphics Visible Surface Determination: P. J. Narayanan
CS3500
1
IIIT Campus
Rm 305
Rm 104
CVIT CDE Director
CS3500 February 14, 2005
4
Box-Frustum Intersection
Orthographic: Intersection of two boxes. Perform by
checking simultaneous X-Y-Z overlaps.
Image-Precision Algorithm
for each pixel in the image
Determine closest object in the direction of projector
Draw the pixel with appropriate colours
Object-Precision Algorithm
for each object in the world
Determine unobstructed parts of the object
Draw those parts with appropriate colours
Simplifying VSD
Extents: If two object do not overlap in and extents,
they cannot occlude each other. Bounding volumes must
overlap for possible obstruction.
Spatial Partitions: If the whole object overlaps, divide into
sub-parts and check for each.
Hierarchy: If higher levels of the hierarchy contains the
lower ones entirely, checking can be done from top down.
Coherence or local similarity in: objects, faces, edges,
scan-line, area, depth, etc.
Results in incremental computation algorithms.
CS3500 February 14, 2005
8
Back-Face Culling
Only the front side can be seen of solid, opaque objects.
If surface normals point out of the object, polygons with
normals pointing away from the viewer cannot be seen.
If , draw. Else discard. v is a vector from CoP to
with negative component in the normal vector.
End of Class 19
closer 3D point in any direction.
is larger than previously stored value.
CS3500 February 17, 2005
12
10 6 8
3
+
5
3 2
Pseudocode
for Ymax
for Xmax
if (pz ReadZ(x, y))
WriteZ()
WritePixel()
Y2
Z2
When or increments by 1
changes by a constant .
Z-buffering: Discussion
Any shape with per pixel can be handled correctly.
Time is independent of number of primitives.
Easy to implement; can do with a single scan-line Z-
buffer.
Z-buffer can be read back and saved.
Needs extra memory, but memory is cheap.
Can cause aliasing or z-fighting (shimmering).
VSD: Recap
Need to know which surface is in front and which is at the
back.
back to front.
Objects may need splitting if no unique ordering exists.
Ordering and splitting polygons: Object-precision
operation.
Overwriting farther points while scan conversion: Image-
precision operation.
CS3500 February 17, 2005
18
2. Resolve ambiguities due to overlap in .
Split polygons if necessary.
3. Scan convert from back to front.
Q
P Q
P
P
Q Q
CS3500 February 17, 2005
20
Test the following:
1. Are P and Q non-overlapping in ?
2. Are P and Q non-overlapping in ?
3. Is P entirely on the opposite side of Q’s plane from
viewpoint?
4. Is Q entirely on the same side of P as the viewpoint?
5. Are XY projections of P and Q non-overlapping?
CS3500 February 17, 2005
21
3 2
Computationally expensive.
BSP Trees
Use planes of polygons in the scene as partitioning
planes.
3
CS3500 February 17, 2005
28
4b
1
1 4a
3 2
2
5b 5a 4b 4a
5a
5b
3
4
5
1
4 3
2
5 1 2
Performance Considerations
Construction of the BSP tree is expensive.
End of Class 20
Scan-Line Algorithms
Perform visibility computations along with scan conversion.
Modify scan conversion algorithm to handle multiple
polygons for each scan line. Use a Polygon Table (PT)
in addition to the ET.
Spans are further divided into portions depending on the
polygon they belong to.
Compute which polygon is in front for each such span.
An image pixel is computed only once (except, perhaps,
background pixels).
CS3500 March 18, 2004
35
Area-Subdivision Algorithms
If the image to be formed belongs to only one polygon, no
visibility computation.
1 X
5
4 5
If VPN is (-, +, +):
If VPN is (+, +, -):
Visit the octree in the back-to-front order, given the
orientation of the camera with respect to the scene.
Ray Equation
If the CoP is and pixel point is , the
ray is given by
Negative values of line behind CoP. is at the
projection or pixel plane.
Intersection point:
Does it lie within the polygon?
Substituting, we get:
we are interested only in the relative values of .
VSD: Summary
Sorting in the right order is key to all of them.
If expensive lighting/shading is used, do not shade an
image pixel more than once.
For quick rendering, z-buffer algorithms are better.
BSP Trees can be fast if environment is static.
Ease of implementation and scope of hardware
acceleration are also important.
Z-buffering is popular due to memory being cheap.
End of Class 21