- Home /
Question by
Aubrey-Falconer · Dec 08, 2009 at 05:20 PM ·
camerashaderfogvisual-effects
In what units is fog density expressed?
What formula correlates the camera's view distance to a particular fog density?
Comment
Answer by Matthew A · Mar 26, 2013 at 02:42 PM
I imagine these are the same as the old fixed function OpenGL pipeline, which I believe are as follows:
Linear: f = inverse_lerp(fog_start_distance, fog_end_distance, distance) Exp: f = exp(-fog_density * distance) Exp2: f = exp(-(fog_density * distance) ^ 2)
f = clamp(f, 0.0, 1.0)
C = f Cr + (1.0 - f) Cf
where: f is fog factor C is resulting fragment color Cr is original fragment color Cf is fog color
Your answer
![](https://koobas.hobune.stream/wayback/20220613180839im_/https://answers.unity.com/themes/thub/images/avi.jpg)