I draw multiple 3d shapes in cube volumes with raycasting in fragment shader, like described here: https://github.com/bagobor/opengl33_dev_cookbook_2013/blob/master/Chapter7/GPURaycasting/shaders/raycaster.frag
float prev_alpha = sample - (sample * vFragColor.a);
vFragColor.rgb = prev_alpha * vec3(sample) + vFragColor.rgb;
vFragColor.a += prev_alpha;
It goes from front to back of the raycast and accumulates the alpha in each step. For alpha blending i use this settings:
glAlphaFunc(GL_GREATER, 0.01);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I have an blending problem, when i draw multiple volumes. Fully transparent parts of cubes are drawn in front non-transparent parts of others. How can i fix this, discard the transparent parts of the cubes? (Rearranging the array of volumes to its xyz position dont work, because i can turn the camera)