More Visible Surface Determination Algorithms

Binary Space Partitioning

This method uses a binary tree to partition a set of polygons.
The tree can be used to display the polygons in back-to-front order, from any viewpoint.
An example of viewpoint-independent preprocessing.

Constructing the tree.  The following algorithm creates a BSP tree from a set of polygons.  (Assume that we are given a method makeTree which constructs a binary tree, given a root data item and left and right subtrees.)

BSPTree constructBSPTree(PolygonSet S)
    PolygonSet Sin,Sout;

    if S is empty, return an empty tree;
    Choose a polygon P from S;
    Let Sin and Sout be empty polygon sets;
    for each polygon Q in S - {P} {
        if Q is on the inside of the plane containing P
            insert Q in Sin;
        else if Q is on the outside of the plane containing P
            insert Q in Sout;
            split Q into two polygons Qin (on the inside of P's plane) and Qout (on the outside of P's plane);
            insert Qin in Sin;
            insert Qout in Sout;
    return makeTree(P,constructBSPTree(Sin),constructBSPTree(Sout));

Now, the tree can be traversed to produce a back-to-front ordering:

void traverse(BSPTree t,Point viewer)
    if t is not empty {
        P =;  // P is the polygon in the root node of the tree
        if(viewer is on the inside of P's plane){
            display P;
        else {
            display P;

Scan Line Algorithms

Data structures:

Edge table (ET)

Polygon table (PT).  For each polygon, it contains: Active-edge table (AET).

Area Subdivision Algorithms

Basic idea:  Repeatedly divide viewing area into regions.  Continue until each region contains the projection of only a single visible surface or none at all, or has been reduced to a single pixel.

Warnock’s Algorithm

Problem:  The algorithm needs to use image-precision operations to terminate because it can clip a polygon only againgst a rectangular area.

the Weiler-Atherton Algorithm

The algorithm in pseudocode:

Visible Surface Ray Tracing

Simple ray tracing algorithm:

for (each scan line in image) {
    for (each pixel in scan line ) {
        determine ray from eye through the center of the pixel;
        for(each object in scene) {
            determine the intersection between the ray and the object;
            if(object is intersected and is closest considered thus far)
                record intersection point and object id.
        determine the surface normal at the closest intersection point;
        apply the illumination model to the intersection point, and use the result to color the pixel;

Problem:  The number of intersections to be computed is k * M, where k is the number of objects in the scene and M is the number of pixels.  For a scene of 100 polygons displayed on a 1024x1024 viewing window, this is 100 million intersections.

Some techniques for improving efficiency:

Antialiasing can be done by casting (adaptively) several rays per pixel.