<<< Translating normal vectors into the world space | Index | The smooth type qualifier >>> |
The light position is also given in the world space. To use a light source that rotates with the model (e.g. rotating desk with a desk lamp on it), use the following modification for the previous vertex shader:
// UPDATE! -- rotate the light source vec3 rotating_light = normalize( mRotations*vLight ).xyz;
And then in your fragment shader:
float cos_incidence = dot( normal_in_cam_space, rotating_light );
The angle between the surface normal and the light source vector is called the angle of incidence of the light.
<<< Translating normal vectors into the world space | Index | The smooth type qualifier >>> |