Specular Light on a Ball
Lighted Texture Looks Like Plastic. Swipe to Move the Ball.
View the specular light on the ball. Lighting helps define the texture of the surface covering the ball. The ball's surface looks like plastic. Light location, light color, and ambient color are declared with constants in the fragment shader.
As the ball spins and moves, both a model matrix and a normal matrix are uploaded. The model matrix represents rotation and translation data for the ball. The normal matrix equals the model matrix inverted and transposed. The vertex shader uses the normal attributes and normal matrix to compute lighting per frame.
Seven Thunder Software created a sphere in 3DS Max then exported as a Collada DAE file with normals. The Windows 3D Translator app was used to convert from DAE format to a set of WebGL arrays.