To modify the Phong reflection model to use flat shading, take the following steps:
- Use the same vertex shader as in the Phong example provided earlier. Change the output variable LightIntensity as follows:
flat out vec3 LightIntensity;
- Change the corresponding variable in the fragment shader to use the flat qualifier:
flat in vec3 LightIntensity;
- Compile and link both shaders within the OpenGL application, and install the shader program prior to rendering.