The Java applet below shows a sphere illuminated by a single light source. Initially the light source is directly behind you, the viewer. You can change the location of the light source by clicking on the control on the right side of the applet.

The applet below is similar to the applet above except this applet has three light sources -- red, green, and blue -- and three controls.

The mathematics of lighting and shading is multivariable calculus and three dimensional linear algebra.