In this chapter, we will go a little bit deeper in the use of colors in WebGL. We will start by examining how colors are structured and handled in both WebGL and ESSL. Then we will discuss the use of colors in objects, lights and in the scene. After this we will see how WebGL knows how perform object occlusion when one object is in front of another. This is possible thanks to depth testing. In contrast, alpha blending will allows us to combine the colors of objects when one is occluding the other. We will use alpha blending to create translucent objects.
This chapter talks about:
Using colors in objects
Assigning colors to light sources
Working with several light sources in the ESSL program
The depth test and the z-buffer
Blending functions and equations
Creating transparent objects with face culling