# max range of point light

How do I calculate the maximum range (or radius) of a distance attenuated OpenGL point light given the three attenuation values? I want to use this to determine which lights affect which objects.

If I recall correctly, the three values are coefficients of a quadratic equation, i.e. There is a simple algebraic solution (formula) to this equation, google to find exact details.

K_qd^2 + K_ld + K_c = 0 (eq. 1)

d here is the distance from light position to vertex (or fragment I suppose if per pixel lighting!).

Red Book:

a = 1/(eq. 1)

where a is the attenuation factor. The attenuation factor is multiplied with the light source ambient, diffuse and specular contributions. So when a = 0 the light source is not really contributing at all.

Solving for a = 0 would mean that eq. 1 would have to diverge to infinity, and computers don’t play nice with infinity. Instead we can set a minimum threshold for attenuation. We can call it T_a. We set it to a small value and since contributions are multiplied by that small value we say that those contributions are not important.

Substituting a for Ta we are solving for a small value rather than zero:

(eq. 1) = 1/T_a

The right-hand side is now a proper value (instead of infinity) so we move it to the left-hand side to make the right-hand side zero, and combine it with our other constant, K_c:

K_qd^2 + K_ld + (K_c - 1/Ta) = 0

Now just solve for d using the simple formula that you will find in any standard text book. This should yeild d. You will get two values for d, choose the positive one. (if my intuition is correct the should be one positive and one negative one in all cases)