Skip to main content

Module atmosphere

Module atmosphere 

Source
Expand description

Atmospheric and environmental rendering mathematics.

Covers Rayleigh/Mie scattering, physical sky models, volumetric fog, procedural clouds, Gerstner ocean waves, and shadow-mapping helpers.

All math is CPU-side, using glam::{Vec2, Vec3, Vec4, Mat4}.

Structs§

AtmosphereParams
Full atmosphere parameter set for physical sky rendering.
CloudLayer
A single cloud layer definition.
MieScattering
Mie scattering parameters for Earth’s atmosphere.
OceanWave
A single Gerstner wave component.
Preetham
Simplified Preetham sky model.
RayleighScattering
Rayleigh scattering parameters for Earth’s atmosphere.
SkyModel
Physical sky colour model using single-scattering path integrals.
TransmittanceLut
Precomputed transmittance lookup table.
VolumetricFog
Homogeneous volumetric fog parameters.

Functions§

bias_matrix
Bias matrix to map NDC [-1,1] to UV [0,1] and depth [0,1].
cascade_shadow_splits
Compute cascade split distances for Cascaded Shadow Maps (CSM).
cornette_shanks_phase
Cornette-Shanks phase function — more accurate than HG for large g.
exponential_height_fog
Exponential height-fog density at world position pos.
fog_inscattering
In-scattering colour accumulated along a ray through volumetric fog toward a single directional light.
fog_transmittance
Beer-Lambert transmittance through homogeneous fog of distance.
gerstner_wave
Compute Gerstner wave displacement at horizontal position pos and time time.
light_space_matrix
Compute a light-space view matrix and ortho projection for a directional light, tightly fitted to a scene AABB.
mie_phase
Henyey-Greenstein phase function for Mie scattering.
ocean_normal
Compute the analytic surface normal of a Gerstner wave field.
optical_depth
Compute the optical depth (column density) from start to the atmosphere boundary, and also toward the sun for shadow computation.
pcf_kernel
Generate a Poisson-disc PCF kernel of size taps.
pcss_blocker_search_uv
Compute the PCSS blocker-search UV radius.
rayleigh_phase
Rayleigh phase function.
raymarch_cloud
Raymarche through cloud layers and return Vec4(rgb_color, alpha).
sample_cloud_density
Evaluate procedural cloud density at pos using layered FBM noise.
water_color
Simple deep-water colour model.
water_fresnel
Fresnel reflectance for water (IOR = 1.333) using Schlick approximation.