Fog
Fog is a scene-level effect that blends fragment color toward a fog color based on distance from the camera. It can be used to suggest large scale, hide distant detail, and soften transitions into the background.
// Adds linear fog to scene
my_scene->fog = Fog::CreateLinear(0x444444, 2.0f, 6.0f);
// Adds exponential fog to scene
my_scene->fog = Fog::CreateExponential(0x444444, 0.3f);Construction
Constructors
Fog()
Constructs a fog object.
Fog::Fog(Type type, const Color& color);| Parameter | Description |
|---|---|
| type | |
| color |
Factories preferred
Creates an exponential fog object.
Exponential fog increases with distance using a density parameter, typically with a factor like or a related variant, which produces a smooth atmospheric falloff.
static std::unique_ptr<Fog> Fog::CreateExponential(const Color& color, float density);| Parameter | Description |
|---|---|
| color | |
| density |
Creates a linear fog object.
Linear fog increases its effect given a distance range along the view direction, typically using a factor similar to .
static std::unique_ptr<Fog> Fog::CreateLinear(const Color& color, float near, float far);| Parameter | Description |
|---|---|
| color | |
| near | |
| far |
Types
Fog::Type enum
Fog attenuation models.
Selects how fog intensity increases with distance. Linear fog uses a depth range, while exponential fog uses a density-based curve that grows smoothly with distance.
| Value | Description |
|---|---|
| Linear | Depth-based fog using a near and far distance range. |
| Exponential | Density-based fog using a continuous falloff curve. |
Properties
density float
Density factor for exponential fog (used when type is Exponential).
float density {};far float
End distance for linear fog (used when type is Linear).
float far {};near float
Start distance for linear fog (used when type is Linear).
float near {};