Implementing the Shaders

With our shaders, we will implement Phong shading and the Phong reflection model. Remember that Phong shading interpolates vertex normals and creates a normal for every fragmentthe processing happens in the fragment shader. The Phong reflection model describes illumination as the addition of ambient, diffuse, and specular interaction of the object with the light sources.

To be consistent with the Material Template Library (MTL) format, we’ll follow some typical conventions to set out uniform names 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 see it in the ...

Get Real-Time 3D Graphics with WebGL 2 - Second Edition 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.