Adolescence, n.: The stage between puberty and adultery. Concept 7.1 : Position And Attenuation ====================================== Idea: ===== As mentioned before we can choose whether to have a light source that's directional or positional. The effect of an infinite location is that the rays of light can be considered parallel by the time they reach an object. An example would be our sun. For the positional source its exact position within the scene determines the effect it has on a scene, and specifically, the direction from which the light rays come. An example would be a desk lamp. Light Position Vector ==================== Typically we supply four values to specify the position of a light source, as shown above. These values (x, y, z, w) supply the position for the GL_POSITION parameter. If the last value, w is zero the light source is a directional one, i.e. infinitely located, and the (x,y,z) values in that case describe its direction. If the w value is nonzero, the light is positional, and the (x,y,z) values specify the location of the light. Attenuation Factor ================== For real-world lights, the intensity of light decreases as distance from the light increases. Since a directional light is infinitely far away, it doesn't make sense to attenuate its intensity over distance, so attenuation is disabled for a directional light. However we might want to attenuate the light from a positional light source. OpenGL attenuates a light source by multiplying the contribution of that source by an attenuation factor. The attenuation factor is defined as : 1 ------------------------- Kc + Kl*d + Kq*d*d where d = distance between the light's position and the vertex Kc = GL_CONSTANT_ATTENUATION Kl = GL_LINEAR_ATTENUATION Kq = GL_QUADRATIC_ATTENUATION By default Kc is 1.0, and both Kl and Kq are zero but we can give these parameters different values by calls to glLightfv() as the following example shows: glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 2.0); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 1.0); glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.5); Note : The ambient, diffuse, and specular contributions are all attenuated. Only the emission and global ambient values are not attenuated.