Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Distance attentuation of omi and spotlights

$
0
0
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).$$ Since irradiance is defined as $$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)?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>