I’ve been thinking about the way renderers currently handle transparency and complex blending. Usually, the app is forced to do the following:
- Draw opaque objects
- Sort transparent objects based on depth(requires an extra camera transform)
- Draw transparent objects
All of this is done completely on the CPU. The most intensive part is getting the depth of each triangle for sorting.
OK, so why not put sorting into the hardware? This can be done without major changes to OpenGL by extending display lists. Example:
//Let’s draw some transparent objects.
//First, set the sorting func:
glSortFuncEXT(GL_FARTHEST_TO_NEAREST_EXT);
//Now, put all the primitives we want to sort and draw into a list:
glNewList(,GL_COMPILE_AND_SORT_EXT);
… //put blending changes, texture changes, material changes, and all other drawing stuff
glEndList();
//Then, just use glCallList( ); normally whenever you need to render.
//At this point, the video card(or driver) would transform everything to camera space and sort based on the sorting function.
Of course, there could be lots of different sorting functions…
Anyway, has this been considered before? I think this would be an amazingly useful feature.
-Shard
[This message has been edited by Shard (edited 07-16-2002).]