# Distance attentuation of omi and spotlights

This topic is 391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

If we apply the rendering equation to a single omni light, we obtain

$$L\!\left(p, \hat{\omega_{o}}\right) = f_{r}\!\left(p, \hat{\omega_{i}}, \hat{\omega_{o}}\right) E\!\left(p, \hat{\omega_{l}}\right).$$

$$E\!\left(p, \hat{\omega_{l}}\right) := \frac{\mathrm{d}\Phi}{\mathrm{d}A},$$

we can substitute the power/flux received at a surface $A$, positioned at $p$ and oriented by $\hat{n}$:

$$\Phi_{A} = \frac{\Phi A \left(\hat{n} \cdot \hat{\omega_{l}}\right)}{4 \pi \lVert p - p_{l} \rVert_{2}^{2} }$$

in the above equation:

$$L\!\left(p, \hat{\omega_{o}}\right) = f_{r}\!\left(p, \hat{\omega_{i}}, \hat{\omega_{o}}\right) \frac{\Phi \left(\hat{n} \cdot \hat{\omega_{l}}\right)}{4 \pi \lVert p - p_{l} \rVert_{2}^{2} } \mathcal{V}\!\left(p, p_{l}\right).$$

Here,

$$I_{l} := \frac{\Phi}{4 \pi}$$

is the mysterious "intensity" factor appearing in some code, still having units [W] (unless we really should interpret the denominator as the solid angle of the full sphere?). Though actual (radial) intensity is equal to

$$I := \frac{\mathrm{d}\Phi}{\mathrm{d}\omega}$$

and has units [W/sr].

The distance attunatuation is equal to

$$\frac{1}{\lVert p - p_{l} \rVert_{2}^{2}} = \frac{1}{r^{2}}.$$

Unfortunately, this is not very practical for light culling due to the infinite decay. So lets make the decay finite:

$$\frac{1}{r^{2}}-\frac{1}{r_{\mathrm{range}}^{2}}.$$

Is this a common PBR distance attenuation used in game engines?  The function reaches infinity at zero meter, which is actually correct. A ray tracer would do the same. (Note that omni lights do not exist in reality.) The following could remedy this:

$$\frac{1}{r^{2}+a^2}-\frac{1}{r_{\mathrm{range}}^{2}+a^2}.$$

Here, we will approximately have

$$\frac{1}{a^2}$$

at a distance of zero meter. (Note that we need to clamp at zero. I omitted this for simplicity of notation.)

My concern was actually with the following distance attenuation, I found in the Real-time Rendering book:

$$\mathrm{saturate}\!\left(\frac{r_\mathrm{end}-r}{r_{range}}\right).$$

This really compensates the absence of indirect lighting, but results in images far from (real-time) physically accurate.

Furthermore, what is normally stored for expressing the "light intensity" of omni and spotlights? For directional lights, this is radiance. For omni lights my guess is

$$\frac{\Phi}{4 \pi}$$

and for spotlights my guess is

$$\frac{\Phi}{2 \pi}$$

(assuming you do not include the angular falloff into the power)?

Edited by matt77hias

##### Share on other sites

The last few games that I've shipped use the attenuation equation that you suggest (subtracting 1/range^2), and it works okay. One issue with it is that the combination of the offset + clamping at 0 means that the resulting function isn't continuous in the first derivative, which can give you a visible seam in some cases. Brian Karis suggested an alternate attenuation function here that doesn't have this particular issue.

##### Share on other sites
6 hours ago, MJP said:

Brian Karis suggested an alternate attenuation function here that doesn't have this particular issue.

He uses the following distance falloff:

$$\frac{\mathrm{saturate}\left(1-\left(r/r_{\mathrm{range}}\right)^4\right)^2}{r^2+1}$$

What is the idea behind the power of 4 and the power of 2 in the nominator? I think that the power of 2 is for ease of use; we keep working with squared distances, but the nominator does not contain an absolute squared distance? Only some relative coefficient.

I played around with this function, but it looks very unrealistic due to the +1 in the denominator. You should expect some attenuation factor larger than 1 for distances less than 1m. But with +1 you will never have an attenuation higher than 1. So if you put a spotlight at your camera eye, it looks much too dark close to some objects.

Edited by matt77hias

1. 1
Rutin
41
2. 2
3. 3
4. 4
5. 5

• 10
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633402
• Total Posts
3011670
• ### Who's Online (See full list)

There are no registered users currently online

×