[vtkusers] opacity < 1 and rendering order

johnny carroll norris jnorris at csar.uiuc.edu
Fri Feb 16 11:45:17 EST 2001

Once upon a time, Charl P. Botha wrote:
> In graphics/examplesTcl/texturedCube.tcl, add the following line to the
> cubeActor configuration clause (i.e. at line 31):
> [cubeActor GetProperty] SetOpacity 0.95
> If you run this script, and take the cube through a half rotation (so that
> your camera goes through 180 degrees), you should note strange artefacts
> (the furthest polygons get rendered in front of the nearest polygons).
> AFAIK, this is typically what happens when you mess with transparency and
> don't render your polygons in the correct order (back to front).  Is there
> any way to get VTK to do this for me?

Check out vtkDepthSortPolyData in the contrib directory.  This filter will
sort polgons back-to-front (or front-to-back, if you want) using a given
vector or vtkCamera.  This can slow down rotation noticably if you've got a
large number of polygons (at least on my Sun).  Also note that this filter
doesn't handle long, thin polygons very well.  Intersecting polygons also
cause problems.

Since I have to deal with long thin polygons fairly often, I modified this
filter to sort the polygons using their cell centers (vtkDepthSortPolyData
just uses the first point in the point list).  First I pass the poly data
through a filter that computes the cell centers and stores them as field
data.  Then my modified sorting filter uses the points stored in the field
data to sort the polygons.  I get better results, and sorting is just as
fast as with the original filter, since cell centers are only computed
once (unless the data changes, of course).  My filter doesn't like
intersecting polygons, either, BTW.

If anyone is interested in these two filters, I'd be happy to send them to

John Norris
Research Programmer
Center for Simulation of Advanced Rockets

More information about the vtkusers mailing list