O'Reilly logo

WebGL Beginner's Guide by Brandon Jones, Diego Cantor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use of color in lights

Colors are light properties. In Chapter 3, Lights, we saw that the number of light properties depend on the lighting reflection model selected for the scene. For instance, using a Lambertian reflection model we would only need to model one shader uniform: the light diffuse property/color. In contrast, if the Phong reflection model were selected, each light source would need to have three properties: the ambient, diffuse, and specular colors.

Note

The light position is usually also modeled as a uniform when the shader needs to know where the light source is. Therefore, a Phong model with a positional light would have four uniforms: ambient, diffuse, specular, and position.

For the case of directional lights, the fourth uniform ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required