Visibility is determining what is in the view volume. Visibility is needed for many algorithms: propagation (light, radio, sound), bullet tracing, visual rendering, heat transfer, etc.

We are concerned with visibility for visual rendering: we want the closest objects to occlude far objects. We also want object outside the view volume to be hidden.

We have been using visibility when rendering our scenes thus far: we have used OpenGL to draw the closest objects to our camera viewpoint. We will consider a few algorithms:

Painter's algorithm

In the painter's algorithm, sort the objects by distance, paint the farthest and remove from the list, continue till all objects are painted. This algorithm cannot handle objects that overlap!


This algorithm uses clipping, or cutting object shapes against other shapes. This results in new shapes, split by the clipping shape.


Raster images are images on grids. This means that they have samples for each grid point (pixels). So, we only need visibility results at pixels.

Z-buffering solves visibility only for discrete samples.

Z-buffering is simple and doesn't need the objects to be sorted. It also allows the depth values to be saved for later. However, it can have depth precision issues and cannot handle transparency very well.

Some OpenGL Z-buffer commands:

Turn on Z-buffer checks: glEnable(GL_DEPTH_TEST)

Clear the depth buffer: glClear(GL_DEPTH_BUFFER_BIT)

Depth precision is set when creating the OpenGL context