VTK/Depth Peeling

From KitwarePublic
Revision as of 08:37, 18 April 2007 by Vv9Sn9 (talk | contribs)
Jump to navigationJump to search


Depth peeling is a multipass technique to render translucent polygonal geometry without sorting polygons.

The algorithm peels the translucent geometry from front to back until there is no more geometry to render. The iteration loop stops either if it reaches the maximum number of iterations set by the user or if the number of pixels modified by the last peel is less than some ratio of the area of the window (this ratio is set by the user, if the ratio is set to 0.0, it means the user wants the exact result. A ratio of 0.2 will render faster than a ratio of 0.1).

Date of Implementation

It was added to VTK on November 27th 2006. Texturing was added on January 9th 2007. Improvement with volumetric dataset and polygonal translucent geometry was made on March 5th 2007. Implemented by (any question to) François Bertel.


  • Translucent geometry does not have to be sorted.


  • The algorithm is inherently slow due to rendering the geometry multiple times.
  • The implementation based on OpenGL API requires a couple of extensions, restricting its usage to recent GPU. It works fine with the current CVS version of Mesa (2006/12/01)


Required OpenGL extensions

  • GL_ARB_depth_texture
  • GL_ARB_shadow
  • GL_EXT_shadow_funcs
  • GL_ARB_vertex_shader
  • GL_ARB_fragment_shader
  • GL_ARB_shader_objects
  • GL_ARB_occlusion_query
  • GL_ARB_multitexture
  • GL_ARB_texture_rectangle
  • GL_SGIS_texture_edge_clamp or GL_EXT_texture_edge_clamp or OpenGL 1.2

OpenGL context requirement

  • at least 8 alpha bits (by default vtkRenderWindow does not ask for alpha bit planes, make sure to call vtkRenderWindow::SetAlphaBitPlanes(1))

Rational: the algorithm has two main stages: first it renders peels from front to back in the framebuffer. each peel is saved in a 2D RGBA texture by grabbing the contents of the framebuffer. So the framebuffer is required to have an alpha channel in order to save it into an RGBA texture. The second part is doing compositing from back to front into the framebuffer by drawing quads on which each peel texture is applied. The compositing stage is drawing into the framebuffer but does not require alpha channel on it (the blending function used at this stage only use the alpha channel from the textures).

Linux Nvidia driver

Make sure to install a driver newer than 9500. For older drivers, there is a bug with GL_ARB_texture_rectangle and GLSL that prevents to use GLSL for depth peeling.