IPhone OpenGL ES: Applying Depth Test on Textures with Transparent Pixels for 2D Game
I currently have mixing and depth testing for a 2D game. When I paint my textures, the "top" texture removes some of the bottom textures if they overlap. It is clear that transparent texture pixels are taken into account in depth analysis and will eliminate all the colors of the drawn bottom textures if they overlap. Also, alpha blends are not displayed correctly. Are there any features that can show OpenGL not to include transparent pixels in deep checks?
source to share
No, It is Immpossible. This applies to all hardware depth measurements.
GL (full or ES- and D3D) have the same model - they draw in the order you specify the polygons. If you draw polygon A in front of polygon B, and logical polygon A must be in front on polygon B, polygon B will not be colored (subject to depth test).
The solution is to draw the polygons in order from the farthest to the closest current view. Fortunately, in a 2D game, this should just be simple (for example, you probably won't have to do it very often).
In 3D games, BSPs are the primary solution to this problem.
source to share
glEnable( GL_ALPHA_TEST );
glAlphaFunc( GL_EQUAL, 1.0f );
This will discard all pixels with the alpha of everything except fully opaque. These pixels will then not be displayed in the Z-buffer. This, however, affects various Z-Buffer pipeline optimizations, so it can lead to serious slowdowns. Use it if you really are too.
source to share