Blending



Creating a material that has transparency can be perilous. The results depend heavily on the order in which polygons are drawn because once a polygon is drawn, it sets the z-buffer even if the polygon is completely transparent as shown in the images below.



No Transparency.
 

Depth turned off to show rendering order.
 

Middle layer partially transparent.

Middle layer completely transparent.

Note, one can use the discard() function in the fragment shader to completely remove a pixel (i.e. make transparent) without setting the z-buffer as shown below: