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({
.color = 0x444444,
.near = 2.0f,
.far = 6.0f
});
// Adds exponential fog to scene
my_scene->fog = Fog::CreateExponential({
.color = 0x444444,
.density = 0.3f
});Construction
Constructors
Fog()
Constructs a fog object.
Fog::Fog(Type type, const Color& color);| Parameter | Description |
|---|---|
| type | Fog::Type specifying the attenuation model. |
| color | Fog color used for fully fogged fragments. |
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 Fog Fog::CreateExponential(const ExponentialParameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters. |
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 Fog Fog::CreateLinear(const LinearParameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters. |
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. |
Fog::ExponentialParameters struct
Fog::LinearParameters struct
Properties
density float
Density factor for exponential fog (used when type is Exponential).
float density {0.00025f};far float
End distance for linear fog (used when type is Linear).
float far {1000.0f};near float
Start distance for linear fog (used when type is Linear).
float near {1.0f};