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§
- Atmosphere
Params - Full atmosphere parameter set for physical sky rendering.
- Cloud
Layer - A single cloud layer definition.
- MieScattering
- Mie scattering parameters for Earth’s atmosphere.
- Ocean
Wave - A single Gerstner wave component.
- Preetham
- Simplified Preetham sky model.
- Rayleigh
Scattering - Rayleigh scattering parameters for Earth’s atmosphere.
- SkyModel
- Physical sky colour model using single-scattering path integrals.
- Transmittance
Lut - Precomputed transmittance lookup table.
- Volumetric
Fog - 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
posand timetime. - 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
startto the atmosphere boundary, and also toward the sun for shadow computation. - pcf_
kernel - Generate a Poisson-disc PCF kernel of
sizetaps. - 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
posusing layered FBM noise. - water_
color - Simple deep-water colour model.
- water_
fresnel - Fresnel reflectance for water (IOR = 1.333) using Schlick approximation.