Easy3D 2.5.3
DualDepthPeeling Class Reference

Transparency effect using dual depth peeling. More...

#include <easy3d/renderer/dual_depth_peeling.h>

Inheritance diagram for DualDepthPeeling:
Transparency

Public Member Functions

 DualDepthPeeling (Camera *cam)
 Constructor. More...
 
void set_max_peels (int n)
 Sets the maximum number of peeling layers. More...
 
int max_peels () const
 Returns the maximum number of peeling layers.
 
void draw (const std::vector< TrianglesDrawable * > &surfaces) override
 Renders the scene (a set of surfaces) with transparency effect. More...
 
virtual void draw (const std::vector< TrianglesDrawable * > &surfaces)=0
 Renders the scene (a set of surfaces) with transparency effect. More...
 

Detailed Description

Transparency effect using dual depth peeling.

DualDepthPeeling implements the dual depth peeling algorithm described in [Order independent transparency with dual depth peeling] (http://developer.download.nvidia.com/SDK/10.5/opengl/src/dual_depth_peeling/doc/DualDepthPeeling.pdf) by L. Bavoil, K. Myers. February 2008.

Depth peeling is traditionally used to perform order independent transparency (OIT) with N geometry passes for N transparency layers. Dual depth peeling enables peeling N transparency layers in N/2+1 passes, by peeling from the front and the back simultaneously using a min-max depth buffer. It performs peeling and blends on the fly. The pass occurs in several stages:

  1. Copy the current (opaque geometry) depth buffer into a texture.
  2. Initialize the min-max depth buffer from the opaque depth texture and the translucent geometry.
  3. Peel the nearest and farthest fragments: 3a. Blend fragments that match the nearest depth of the min-max depth buffer into the front buffer. 3b. Write the far depth fragments into a temporary buffer. 3c. Extract the next set of min/max depth values for the next peel. 3d. Blend the temporary far fragment texture (3b) into an accumulation texture. 3e. Go back to 3a and repeat until the maximum number of peels is met, or the desired occlusion ratio is satisfied.
  4. If the occlusion ratio != 0 (i.e. we hit the maximum number of peels before finishing), alpha blend the remaining fragments in-between the near and far accumulation textures.
  5. Blend all accumulation buffers over the opaque color buffer to produce the final image.

Related articals or methods:

About antialiasing: Dual depth peeling won't work with a multisample FBO, so for better rendering quality, it is possible to add a "Fast Approximate Anti-Aliasing" (FXAA) step for post antialiasing.

Optimization tips: rendering with multi-effects (e.g., shadowing, SSAO) can benefit from sharing the same geometry pass.

Examples
Tutorial_504_Transparency.

Constructor & Destructor Documentation

◆ DualDepthPeeling()

DualDepthPeeling ( Camera cam)
explicit

Constructor.

Parameters
camThe camera used in the view

Member Function Documentation

◆ draw()

void draw ( const std::vector< TrianglesDrawable * > &  surfaces)
overridevirtual

Renders the scene (a set of surfaces) with transparency effect.

Implements Transparency.

◆ set_max_peels()

void set_max_peels ( int  n)
inline

Sets the maximum number of peeling layers.

It has to be a positive value. Default value is 4. A special value of 0 means no maximum limit.


The documentation for this class was generated from the following files: