Hello,
I am trying to create a selective blending. The intention is to render some textured planes (containing semi-translucent alpha values). If there is nothing between the planes and the background no blending should take place to ensure a correct color value of the result. The result is read from the buffer and saved to an image.
Currently I am using this code:
//clear depthbuffer and render only planes being further in the background
glClearDepth( 0.0 );
glClear( GL_DEPTH_BUFFER_BIT );
glDepthFunc( GL_GREATER );
//disable blending and render only color of the planes
glDisable( GL_BLEND );
glColorMask( true, true, true, false );
//–> RENDER CONTENT
//reset depthbuffer
glClearDepth( 1.0 );
glClear( GL_DEPTH_BUFFER_BIT );
glDepthFunc( GL_LESS );
//reset to standard blending
glEnable( GL_BLEND );
glColorMask( true, true, true, true );
//–> RENDER CONTENT
Actually this retrieves a correct result, but forces me to render the planes/content twice. Has someone a better solution or does someone knows an extension to achieve the result in one step?