Implementing order-independent transparency using dual depth peeling
In this recipe, we will implement dual depth peeling. The main idea behind this method is to peel two depth layers at the same time. This results in a much better performance with the same output, as dual depth peeling peels two layers at a time; one from the front and one from the back.
Getting ready
The code for this recipe is contained in the Chapter6/DualDepthPeeling
folder.
How to do it…
The steps required to implement dual depth peeling are as follows:
Create an FBO and attach six textures in all: two for storing the front buffer, two for storing the back buffer, and two for storing the depth buffer values.
glGenFramebuffers(1, &dualDepthFBOID); glGenTextures (2, texID); glGenTextures (2, backTexID); glGenTextures (2, depthTexID); for(int i=0;i<2;i++) { glBindTexture(GL_TEXTURE_RECTANGLE, depthTexID[i]); //set texture parameters glTexImage2D(GL_TEXTURE_RECTANGLE , 0, GL_FLOAT_RG32_NV, WIDTH, HEIGHT, 0, GL_RGB, GL_FLOAT...