bevy_elements 0.7.0

Living environments for Bevy: sun, moon and stars, climate-driven weather, GPU wind, volumetric clouds, rain, snow and fog, lightning, terrain with hydraulic and thermal erosion, flooding, snow cover, wetness and dust — simulated in compute shaders.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// bevy_elements::climate::snow — the one definition of how precipitation splits into rain and
// snow, shared by the kernels that add rain to the water layer (hydrology) and snow to the cover
// layer (M4 snow). Both evaluate it at the temperature of the cell, so the two shares add up to
// the precipitation in every cell and nothing is counted twice.
//
//     import bevy_elements::climate::snow::snow_fraction_at;
//
// Mirrors `Weather::snow_fraction` (`climate/weather.rs`).

/// Fraction of precipitation that falls as snow at air temperature `t_c` (°C): 1 at −1 °C and
/// below, 0 at 2 °C and above, linear between, times `possible` (`Weather::snow_possible`: 0
/// outside the climate's snow season).
fn snow_fraction_at(t_c: f32, possible: f32) -> f32 {
    return clamp((2.0 - t_c) / 3.0, 0.0, 1.0) * possible;
}