Curve Based Exponential Fog
a flexible and believable exponential fog in Unreal Engine 4 based on Direct3D 9's Exponential Fog Equation
TL;DR — Building a flexible exponential fog material in Unreal Engine 4 from Direct3D 9’s exponential fog equation: compute the fog factor, drive fog color by camera distance through a curve, add a height-based mask so lower regions stay opaque, and blend the result over the scene color.
Final Result
Goal and Scope
The goal of this project is to create a flexible and believable exponential fog in Unreal Engine 4 based on Direct3D 9’s Exponential Fog Equation
Reference
Direct3D 9’s Exponential Fog Equation
Core Logic
First, implement the equation of exponential fog as a barebone:
Then, blend the fog factor with:
After that, use a curve to control the color based on the distance between the camera:
Execution
First, implement basic exponential fog:
Then, the original color is simply the scene color:
Here, a height based mask was calculated (use one minus because we want the bottom part to be opaque):
Finally, blend them together:
Full Graph
Cite this post
Jayden Zhang. “Curve Based Exponential Fog.” Jayden Zhang’s Blog, December 10, 2019. https://www.jaydengames.com/posts/curve-based-exp-fog/
BibTeX
@misc{curve-based-exp-fog2019,
author = {Jayden Zhang},
title = {Curve Based Exponential Fog},
year = {2019},
url = {https://www.jaydengames.com/posts/curve-based-exp-fog/},
note = {Jayden Zhang’s Blog}
}






