Implementing the shaders

The shaders in this chapter will implement Phong shading and the Phong reflection model. Remember that Phong shading interpolates vertex normals and creates a normal for every fragment. After that, the Phong reflection model describes the light that an object reflects as the addition of the ambient, diffuse, and specular interaction of the object with the light sources present in the scene.

To keep consistency with the Material Template Library (MTL) format, we will use the following convention for the uniforms that refer to material properties:

Material

Uniform

Description

uKa

Ambient property

uKd

Diffuse property

uKs

Specular property

uNi

Optical density. We will not use this feature but you will ...

Get WebGL Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.