# Light intensity of a point light at position ?

I want to replace a point light with a directional light while keeping the intensity on an object the same. To know the intensity of my replacement directional light, I want to know the intensity at a position generated by a point light.

in another word, I need a formula that takes in intensity and distance and returns an intensity at the distance. Assume there is only one point light and one object.

This is actually fairly simple in theory - all you need to do is find the light’s attenuation factor at that distance and multiply it by the light’s intensity. In real life, light follows the inverse-square law, therefore a physically-based function that returns a point light’s intensity based on distance to the light source would be;

``````float LightIntensity (Light light, float distance)
{
return light.intensity / (distance * distance);
}
``````

However, you might notice that we don’t take the light’s range into account. This is because in reality lights don’t have a configurable ‘range’, just intensity. Whilst there are ways to incorporate range into this algorithm, it isn’t relevant to the built-in pipeline because unfortunately, attenuation in Unity doesn’t really follow convention and instead it uses a linear falloff. So, if you are looking at doing this purely based off lights in the built-in render pipeline, a function to find the intensity of a light at a distance (with range) would be;

``````float LightIntensity (Light light, float distance)
{
return light.intensity * (1f - Mathf.Clamp01 (distance / light.range));
}
``````

This may still not be 100% accurate to how Unity handles attenuation internally, because the engine uses lookup textures rather than actually calculating attenuation directly. This means there is really no way to tell exactly what equation they use - our best guess is some form of linear function.