# Light Attenuation

Question:

```What are 3 different attenuation values.  All I seemed to see mentioned on various sites was Attenuation0, but TV has 2 more.
What are those used for?```

There is only one Attenuation (Loss of Light). Attenuation0, Attenuation1 and Attenuation2
are just Attenuation equation coefficients.

A = 1 / ( Attenuation0 + Attenuation1 * D + Attenuation2 * D2 )

where D is distance between the light source and the vertex
and A is the resulting Attenuation.

And No, these coefficients have nothing to do with x y and z.

i.e. Attenuation = 1 / ( 1 + 0 * D + 0 * D2 ) = 1
This creates a “directional” light with a “range” (even though it is really not a directional light
as Attenuation is not applicable to directional lights).
There is really no good description for these three coefficients. They are simply the members of
quadratic equation (a*x2+b*x+c) describing the Attenuation curve.

It’s going to get somewhat mathematical from this point on.
Feel free to stop reading at any time

If you use ModelView, you’ll notice that it uses
Attenuation0=0
Attenuation1=1
Attenuation2=0

Plug them int the above equation and you get

A = 1 / ( 0 + 1 * D + 0 * D2 ) = 1 / D

You can plot this equation (Attenuation against Distance)

If you analyze this graph you can see that at Distance=0.0 the curve never
intersects the Attenuation axis. This simply means that you
will have infinite/maximum light. As you increase the distance the light intensity
decreases. At Distance=2 your light intensity is about 0.5 as opposed to infinity
at Distance=0.0. The curve also gives you nice and smooth transition
from “a lot of light” to “some light”.

Try this:
Attenuation0=0
Attenuation1=0
Attenuation2=1

A = 1 / ( 0 + 0 * D + 1 * D2 ) = 1 / D2

Using these values (red curve) )you can see that the light intensity starts decreasing
later than in previous example (blue curve).
Light intensity decreases a lot more at Distance=2 than before.

Now combine the previous two examples
Attenuation0=0
Attenuation1=1
Attenuation2=1

A = 1 / ( 0 + 1 * D + 1 * D2 ) = 1 / (D2 + D)

With this combination light starts decreasing sooner and it also goes lower than
in previous examples ( at Distance=2 for example ).

New example:
Attenuation0=1
Attenuation1=0
Attenuation2=0

A = 1 / ( 1 + 0 * D + 0 * D2 ) = 1

This one is obvious. At any distance light has the same intensity.
Keep in mind that once the distance is larger than the range, everything
goes black (this one is applicable to all the examples).

Final example
Attenuation0=1
Attenuation1=1
Attenuation2=1

A = 1 / ( 1 + 1 * D + 1 * D2 ) = 1 / ( D2 + D +1 )

As you can see Attenuation0 pretty much caps the maximum light intensity to 1.

This was a pure theory, in reality, it all boils down to trial and error.
There is really no math equation that can replace you imagination.
Hopefully this explanation makes trial and error less painful.

Ok, thatâ€™s it

Vuli