Exhibit #4: Fragment Phong Lighting
What we did here
The code is (nearly) identical to the code from Exhibit 3. The difference is that the shading code has been moved to the fragment shader.
- Instead of the
surfaceColor
varying, we now have the eye space position and normal instead.
- The uniforms that specify shading parameters have been moved to the fragment shader.
- The interpolated eye space normal is not used directly. Instead it is first normalized.
Normalizing the normal is important! Try removing the normalization. What happens?