Alpha mask of overlapping objects in OpenGL

Viewed 674

What is the best way of getting alpha mask of overlapping objects in OpenGL? In the first picture below I have three grids overlapping with ellipsoid, depth test is enabled. My goal is to get result similar to the second image, where the white represents the alpha. Below are the depth testing flags that I am using.

glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LEQUAL);

Main image

Alpha Mask

2 Answers
Related