Curve Based Exponential Fog | ebp Curve Based Exponential Fog | ebp
Post

Curve Based Exponential Fog

a flexible and believable exponential fog in Unreal Engine 4 based on Direct3D 9's Exponential Fog Equation

Curve Based Exponential Fog

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:

Exponential Fog Equation Exponential Fog Equation

Then, blend the fog factor with:

Fog Factor Fog Factor

After that, use a curve to control the color based on the distance between the camera:

Curve Curve

Execution

First, implement basic exponential fog:

Basic Exponential Fog Basic Exponential Fog

Then, the original color is simply the scene color:

Original Color Original Color

Here, a height based mask was calculated (use one minus because we want the bottom part to be opaque):

Height Mask Height Mask

Finally, blend them together:

Final Result Final Result

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}
}
This post is licensed under CC BY 4.0 by the author.