1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Wind field for `viewport-lib`.
//!
//! A single global wind vector with gust modulation, driven once per frame on
//! the CPU and pushed into a deformer slot's `slot_params` on the GPU.
//! Consumers read the field from two places:
//!
//! - The standard mesh shaders apply per-vertex wind through the deformer
//! registry. [`WindPlugin::install`] registers the deformer; the GPU half
//! keeps its slot params in sync with the CPU clock.
//! - Rust code calls [`WindField::sample`] for spring bones, particles, or
//! any other CPU consumer that needs the same vector the renderer sees.
//!
//! Typical setup:
//!
//! ```ignore
//! use viewport_lib::runtime::ViewportRuntime;
//! use viewport_lib_wind::{WindAuthoring, WindPlugin, WindSwayWeights};
//!
//! let wind = WindPlugin::new(WindAuthoring::default());
//! wind.install(&mut resources, &device).expect("register wind deformer");
//!
//! let runtime = ViewportRuntime::new()
//! .with_plugin(wind.cpu_plugin())
//! .with_gpu_plugin(wind.gpu_plugin());
//!
//! // Per wind-affected mesh:
//! let mask = WindSwayWeights::height_falloff(&positions, 0.0, top_y);
//! wind.attach_sway_mask(&mut resources, &device, mesh_id, &mask);
//! ```
//!
//! The CPU sampler and the WGSL deformer body use the same formula, so a
//! vertex drawn through the deformer and a spring bone tracking the same
//! world position see the same wind to within float precision.
pub use ;
pub use WindGlobals;
pub use ;
pub use SHARED_WIND_WGSL;
pub use ;
/// Catalogue version of `viewport-lib` this crate was built against.
///
/// Bump in lockstep with `viewport_lib::plugin_api::shared_wgsl::WGSL_VERSION`
/// whenever the shared-WGSL contract changes. The compile-time assertion
/// below catches accidental drift.
pub const VIEWPORT_LIB_WGSL_VERSION: u32 = 6;
const _: = assert!;