Posts

Showing posts with the label Lighting

2.4: Adding in Ambient and Specular Components

Image
Now that we have a light that produces shadows, let's add the ambient component back in.  Ambient in the Phong model, is essentially an even level of light that is cast on all points of the model's surface.  We'll add an additional uniform to achieve pass in this value. glUniform1f ( glGetUniformLocation ( programID , "lightAmbient" ), 0.25 ) Then we'll add this value to the light color and multiply it by the intensity to get the effect of the ambient/diffuse light on a fragment.  Within the fragment shader, add the lightAmbient uniform and add this value to the lightColor uniform.  Note that lightAmbient and lightColor are not added together before being multiplied by the intensity.  If they were, this would negate the effect of the ambient light component which gives some level of light to every  fragment of the surface. "uniform float lightAmbient;                           ...