R2 Core Shaders

Data Structures | Functions
R2Fog.h File Reference

Types related to fog rendering. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | R2_fog_t
| The type of fog parameters. More...

## Functions
float | R2_fogAmountLinear (const R2_fog_t fog, const float z)
float | R2_fogAmountQuadratic (const R2_fog_t fog, const float z)
float | R2_fogAmountQuadraticInverse (const R2_fog_t fog, const float z)
vec3 | R2_fogLinear (const R2_fog_t fog, const vec3 surface, const float z)
vec3 | R2_fogQuadratic (const R2_fog_t fog, const vec3 surface, const float z)
vec3 | R2_fogQuadraticInverse (const R2_fog_t fog, const vec3 surface, const float z)

## Detailed Description

Types related to fog rendering.

Definition in file R2Fog.h.

## Function Documentation

## § R2_fogAmountLinear()

float R2_fogAmountLinear | ( | const R2_fog_t | fog,
|  | const float | z
| ) |  |

Calculate the linear fog amount for the given positive eye-space Z value z.

Parameters

  fog | Fog parameters
  z | The positive eye-space Z value of the surface

Definition at line 28 of file R2Fog.h.

31 {
32 return clamp((z - fog.z_near) / (fog.z_far - fog.z_near), 0.0, 1.0);
33 }
R2_fog_t::z_far
float z_far
Definition: R2Fog.h:15
R2_fog_t::z_near
float z_near
Definition: R2Fog.h:12

## § R2_fogAmountQuadratic()

float R2_fogAmountQuadratic | ( | const R2_fog_t | fog,
|  | const float | z
| ) |  |

Calculate the quadratic fog amount for the given positive eye-space Z value z.

Parameters

  fog | Fog parameters
  z | The positive eye-space Z value of the surface

Definition at line 43 of file R2Fog.h.

46 {
47 float linear = R2_fogAmountLinear(fog, z);
48 return linear * linear;
49 }
R2_fogAmountLinear
float R2_fogAmountLinear(const R2_fog_t fog, const float z)
Definition: R2Fog.h:28

## § R2_fogAmountQuadraticInverse()

float R2_fogAmountQuadraticInverse | ( | const R2_fog_t | fog,
|  | const float | z
| ) |  |

Calculate the inverse quadratic fog amount for the given positive eye-space Z value z.

Parameters

  fog | Fog parameters
  z | The positive eye-space Z value of the surface

Definition at line 59 of file R2Fog.h.

62 {
63 return sqrt(R2_fogAmountLinear(fog, z));
64 }
R2_fogAmountLinear
float R2_fogAmountLinear(const R2_fog_t fog, const float z)
Definition: R2Fog.h:28

## § R2_fogLinear()

vec3 R2_fogLinear | ( | const R2_fog_t | fog,
|  | const vec3 | surface,
|  | const float | z
| ) |  |

Calculate linear fog for the given positive eye-space Z value z.

Parameters

  fog | Fog parameters
  surface | The current surface color
  z | The positive eye-space Z value of the surface

Definition at line 75 of file R2Fog.h.

79 {
80 return mix(surface, fog.color, R2_fogAmountLinear(fog, z));
81 }
R2_fogAmountLinear
float R2_fogAmountLinear(const R2_fog_t fog, const float z)
Definition: R2Fog.h:28
R2_fog_t::color
vec3 color
The fog color.
Definition: R2Fog.h:17

## § R2_fogQuadratic()

vec3 R2_fogQuadratic | ( | const R2_fog_t | fog,
|  | const vec3 | surface,
|  | const float | z
| ) |  |

Calculate quadratic fog for the given positive eye-space Z value z.

Parameters

  fog | Fog parameters
  surface | The current surface color
  z | The positive eye-space Z value of the surface

Definition at line 92 of file R2Fog.h.

96 {
97 return mix(surface, fog.color, R2_fogAmountQuadratic(fog, z));
98 }
R2_fogAmountQuadratic
float R2_fogAmountQuadratic(const R2_fog_t fog, const float z)
Definition: R2Fog.h:43
R2_fog_t::color
vec3 color
The fog color.
Definition: R2Fog.h:17

## § R2_fogQuadraticInverse()

vec3 R2_fogQuadraticInverse | ( | const R2_fog_t | fog,
|  | const vec3 | surface,
|  | const float | z
| ) |  |

Calculate inverse quadratic fog for the given positive eye-space Z value z.

Parameters

  fog | Fog parameters
  surface | The current surface color
  z | The positive eye-space Z value of the surface

Definition at line 109 of file R2Fog.h.

113 {
114 return mix(surface, fog.color, R2_fogAmountQuadraticInverse(fog, z));
115 }
R2_fogAmountQuadraticInverse
float R2_fogAmountQuadraticInverse(const R2_fog_t fog, const float z)
Definition: R2Fog.h:59
R2_fog_t::color
vec3 color
The fog color.
Definition: R2Fog.h:17