<p>After some research i think i have final answer.</p>

<p>General fog equation looks something like this:
<span class="math-container">$$ L(t)=L_p\color{red}{T(t)} + \int_0^t\color{blue}{T(x)}\color{green}{\sigma(x)L(x)}dx $$</span>
Transmittance defined as:
<span class="math-container">$$T(x)=e^{-\int_0^x\sigma(x) dx}$$</span>
With const <span class="math-container">$\sigma$</span> become
<span class="math-container">$$T(x)=e^{-\sigma x}$$</span></p>

<p>So color that will be visible is:</p>

<p>Visible percent <span class="math-container">$\color{red}{T(t)}$</span> of pixel color <span class="math-container">$L_p$</span>, plus scattering probability <span class="math-container">$\color{green}{\sigma(x)L(x)}$</span> multiplied by visible percent <span class="math-container">$\color{blue}{T(x)}$</span> at distance <span class="math-container">$x$</span> integrated on ray.
<a href="https://i.sstatic.net/dgnqR.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dgnqR.jpg" alt="enter image description here"></a></p>

<p>With two or more fogs we get multiple scatterings so equations become:
<span class="math-container">$$T(x)=e^{-\int_0^x\sum_0^n\sigma_i(x)dx} = e^{-x\sum_0^n\sigma_i}$$</span>
<span class="math-container">$$L(t)=L_p\color{red}{T(t)} + \int_0^t\color{blue}{T(x)}\sum_0^n\color{green}{\sigma_i(x)L_i(x)}dx=L_p\color{red}{T(t)} + \sum_0^n\color{green}{\sigma_iL_i}\int_0^t\color{blue}{T(x)}dx$$</span></p>

<p>All assuming that <span class="math-container">$\sigma_i$</span> and fog color <span class="math-container">$L(x)$</span> are constant across ray.</p>

<p>The final equation for two fogs, after resolving <span class="math-container">$\int_0^t\color{blue}{T(x)}dx$</span> will become.
<span class="math-container">$$L(x)=L_p\color{red}{T(t)} + (\color{green}{\sigma_0L_0 + \sigma_1L_1})\color{blue}{\frac{1-T(t)}{\sigma_0+\sigma_1}}$$</span></p>

<p>It's the same equation as in <a href="https://graphics.pixar.com/library/DeepCompositing/paper.pdf" rel="nofollow noreferrer">Deep Compositing</a>. After combining it with Lie group/algebra it is possible to integrate only parts of fogs.</p>

<p>Of course this integration isn't 100% correct if you have more complicated fog with not constant density etc.</p>

CC BY-SA 4.0
2019-07-13T10:12:35.283Z
2019-07-13T10:12:35.283Z
Derag
<p>When calculating fog along the ray we have two main part- transmittance and scattering.</p>

<p>What happens when we have two different fogs? With different extinction and color?
Both extinction and color constant along the ray.</p>

<p>Transmittance seems easy to merge, probably something like this:
<span class="math-container">$$T = e^{(\sigma_a+\sigma_b)d}$$</span>
Where <em>d</em> is ray length.</p>

<p>What about color?</p>

<p>General in-scattering equation looks like this:
<span class="math-container">$$S=\sigma *Fog_{color}\int_0^dT(x,\omega x)dx$$</span></p>

<p>What will happen with this equation when there are two fogs?</p>

<p>Will it become:
<span class="math-container">$$Fog_{color}=lerp(Fog_a,Fog_b,\sigma_b/(\sigma_a+\sigma_b))$$</span>
<span class="math-container">$$\sigma_t=\sigma_a+\sigma_b$$</span>
<span class="math-container">$$S=\sigma_t*Fog_{color}*\int_0^de^{-\sigma_tx}dx$$</span>
Or
<span class="math-container">$$S=\sum_0^n\sigma_i*Fog_i\int_0^dT_i(x,\omega x)dx$$</span>
Where <em>n</em> is fogs count.</p>

<p>Or something else? </p>

<volumetric><fog><integral>
Adding two fogs
Derag
# Adding two fogs

(Asked by: username_0 on 2019-07-05)

When calculating fog along the ray we have two main part- transmittance and scattering.

What happens when we have two different fogs? With different extinction and color?
Both extinction and color constant along the ray.

Transmittance seems easy to merge, probably something like this:
$$T = e^{(\sigma\_a+\sigma\_b)d}$$
Where *d* is ray length.

What about color?

General in-scattering equation looks like this:
$$S=\sigma \*Fog\_{color}\int\_0^dT(x,\omega x)dx$$

What will happen with this equation when there are two fogs?

Will it become:
$$Fog\_{color}=lerp(Fog\_a,Fog\_b,\sigma\_b/(\sigma\_a+\sigma\_b))$$
$$\sigma\_t=\sigma\_a+\sigma\_b$$
$$S=\sigma\_t\*Fog\_{color}\*\int\_0^de^{-\sigma\_tx}dx$$
Or
$$S=\sum\_0^n\sigma\_i\*Fog\_i\int\_0^dT\_i(x,\omega x)dx$$
Where *n* is fogs count.

Or something else?

**Tags:** volumetric, fog, integral


---

## 1 answers

### Answer by username_0 on 2019-07-13. Score: 1 | Accepted answer

After some research i think i have final answer.

General fog equation looks something like this:
$$ L(t)=L\_p\color{red}{T(t)} + \int\_0^t\color{blue}{T(x)}\color{green}{\sigma(x)L(x)}dx $$
Transmittance defined as:
$$T(x)=e^{-\int\_0^x\sigma(x) dx}$$
With const $\sigma$ become
$$T(x)=e^{-\sigma x}$$

So color that will be visible is:

Visible percent $\color{red}{T(t)}$ of pixel color $L\_p$, plus scattering probability $\color{green}{\sigma(x)L(x)}$ multiplied by visible percent $\color{blue}{T(x)}$ at distance $x$ integrated on ray.
[![enter image description here](https://i.sstatic.net/dgnqR.jpg)](https://i.sstatic.net/dgnqR.jpg)

With two or more fogs we get multiple scatterings so equations become:
$$T(x)=e^{-\int\_0^x\sum\_0^n\sigma\_i(x)dx} = e^{-x\sum\_0^n\sigma\_i}$$
$$L(t)=L\_p\color{red}{T(t)} + \int\_0^t\color{blue}{T(x)}\sum\_0^n\color{green}{\sigma\_i(x)L\_i(x)}dx=L\_p\color{red}{T(t)} + \sum\_0^n\color{green}{\sigma\_iL\_i}\int\_0^t\color{blue}{T(x)}dx$$

All assuming that $\sigma\_i$ and fog color $L(x)$ are constant across ray.

The final equation for two fogs, after resolving $\int\_0^t\color{blue}{T(x)}dx$ will become.
$$L(x)=L\_p\color{red}{T(t)} + (\color{green}{\sigma\_0L\_0 + \sigma\_1L\_1})\color{blue}{\frac{1-T(t)}{\sigma\_0+\sigma\_1}}$$

It's the same equation as in [Deep Compositing](https://graphics.pixar.com/library/DeepCompositing/paper.pdf). After combining it with Lie group/algebra it is possible to integrate only parts of fogs.

Of course this integration isn't 100% correct if you have more complicated fog with not constant density etc.


---

