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

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 see ...

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