Expand description
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::installregisters the deformer; the GPU half keeps its slot params in sync with the CPU clock. - Rust code calls
WindField::samplefor spring bones, particles, or any other CPU consumer that needs the same vector the renderer sees.
Typical setup:
ⓘ
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.
Structs§
- Wind
Authoring - Authoring knobs for a
WindField. These describe what the field looks like at rest; the field itself owns the time clock that ticks forward. - Wind
Field - The CPU-side wind field. Holds the authoring values plus a running clock.
- Wind
Globals - Per-frame wind state, mirroring the WGSL
WindGlobalsstruct. - Wind
Material Params - Per-mesh material parameters for the wind deformer.
- Wind
Plugin - Wind plugin handle.
- Wind
Sway Weights - Per-vertex sway-mask weights.
Constants§
- SHARED_
WIND_ WGSL Deprecated - VIEWPORT_
LIB_ WGSL_ VERSION - Catalogue version of
viewport-libthis crate was built against. - WGSL_
VERSION - Catalogue version for
WIND_DEFORMER_BODY. Bump on any formula or slot-params layout change. - WIND_
DEFORMER_ BODY - WGSL body for the wind deformer. Composed into the mesh-family shaders
by
register_deformer. - WIND_
DEFORMER_ NAME - Name the wind deformer registers under.
- WIND_
MATERIAL_ PARAMS_ STRIDE_ BYTES - Per-mesh-instance material-params stride: three
f32(strength, density, speed) = 12 bytes. - WIND_
SWAY_ STRIDE_ BYTES - Per-vertex sway-mask stride: one
f32per vertex (4 bytes).