It is time to discuss transparency and alpha blending. We mentioned before that the alpha channel can carry information about the opacity of the color with which the object is being painted. However, as we saw in the cube example, it is not possible to obtain a translucent object unless alpha blending is activated. Things get a bit more complicated when we have several objects in the scene. We will see here what to do in order to have a consistent scene when we have translucent and opaque objects.
The first approach to obtain transparent objects is to use polygon stippling. This technique consists of discarding some fragments so you can see through the object. Think of it as punching little holes throughout the surface of your object.
OpenGL supports polygon stippling through the glPolygonStipple
function. This function is not available in WebGL. You could try to replicate this functionality by dropping some fragments in the fragment shader using the...