The whole workspace compiles with his water in place of ours. Nothing is
verified beyond that yet -- no capture, no gates -- so this lands on
`water-port`, not on main.
Method: scripts/water-port-merge.sh stitches the common ancestor our squashed
history hides (both forks descend from samwhosung/benilla) and runs a real
three-way merge. 134 of his 168 files land clean; the 34 that conflict were
resolved by hand, 82 hunks, and the log is in docs/WATER_PORT.md.
What went, per grom's call (full swap, drop the extras): enhanced_water.wgsl,
liquid/{reflect,scene_depth,waves,lod}.rs, water_fx/bob.rs and the Water Quality
dropdown, with our LiquidExt bindings and the WaterDepth prepass they fed.
What was kept and re-applied onto his tree: the Ironforge magma palette
(MagmaTone, now multiplying the body before his stylised grade so a tinted pool's
crust and glow are its own colour) and our shader hooks -- fog, emissive,
monkey_frame, wind, wet, moonlight -- which his liquid.wgsl knew nothing about.
Four things needed real work rather than a side:
* static_gx now keys its pipelines per VIEW, not per world camera, because his
mirror and probe faces carry their own samples and format; our torch and
light groups and the shadow-filter def ride along, and the depth-only twin
his Hi-Z prepass needs is built beside each colour pipeline.
* the booth layer ladder moved past the liquid render layers. His seam claims
30 and 31; our pane block grew from UI_MODELS_LAYER with nothing stopping it
reaching them, and the const assert fired exactly as the doc predicted.
* two SystemParam tuples were already at the 16 ceiling (the minimap's blip
inputs, the capture driver) and had to nest to take his.
* sky.rs grew `dome_uniforms`, the one law his water march and the dome now
share, without losing our Enhanced sky inputs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
116 lines
4.2 KiB
Rust
116 lines
4.2 KiB
Rust
//! The WGSL tripwire: `liquid.wgsl` composed with naga_oil and validated with naga, as Bevy's
|
|
//! shader cache composes it ([`wgsl`]), under the defs of every liquid pipeline a player reaches
|
|
//! ([`LiquidKey::shipped`]) and the debug variants, on each view key the world camera takes and
|
|
//! each liquid vertex layout.
|
|
//!
|
|
//! One liquid layout and one shader file serve every pipeline, and naga validates the whole
|
|
//! composed module, called or not: a helper outside the `WATER_STYLISED` region that names a
|
|
//! symbol inside it fails the reference and magma pipelines, whose draws then drop with nothing
|
|
//! but a pipeline error in the log. This finds that without a GPU.
|
|
//!
|
|
//! The Bevy modules come from the registry sources of the resolved `bevy_*` packages; where they
|
|
//! are absent the test is skipped as a data-gated test is, which fails under
|
|
//! `BENILLA_REQUIRE_DATA=1`.
|
|
|
|
#[path = "support/wgsl.rs"]
|
|
mod wgsl;
|
|
|
|
use std::collections::{BTreeSet, HashMap};
|
|
use std::path::Path;
|
|
|
|
use benilla_assets::materials::LiquidKey;
|
|
|
|
/// Every key the tripwire covers: the union of [`LiquidKey::shipped`] over its arguments, and each
|
|
/// stylised one with each combination of the debug variants' bits, which the debug panel and the
|
|
/// environment allow at once.
|
|
fn covered_keys() -> Vec<LiquidKey> {
|
|
let mut keys = Vec::new();
|
|
for set in 0..8 {
|
|
for key in LiquidKey::shipped(set & 1 != 0, set & 2 != 0, set & 4 != 0) {
|
|
if !keys.contains(&key) {
|
|
keys.push(key);
|
|
}
|
|
}
|
|
}
|
|
let debug: Vec<LiquidKey> = keys
|
|
.iter()
|
|
.filter(|k| k.composite())
|
|
.flat_map(|k| {
|
|
[LiquidKey::VIEW].map(|bits| {
|
|
let (y, w) = k.path_lanes();
|
|
let caps = (w as u16) | (bits >> LiquidKey::CAPS_SHIFT);
|
|
LiquidKey::from_lanes(
|
|
bevy::math::Vec4::ZERO,
|
|
bevy::math::Vec4::new(0.0, y, 0.0, f32::from(caps)),
|
|
)
|
|
})
|
|
})
|
|
.collect();
|
|
for key in debug {
|
|
if !keys.contains(&key) {
|
|
keys.push(key);
|
|
}
|
|
}
|
|
keys
|
|
}
|
|
|
|
#[test]
|
|
fn liquid_wgsl_compiles_for_every_liquid_pipeline() {
|
|
let Some(modules) = wgsl::bevy_modules() else {
|
|
return;
|
|
};
|
|
let liquid_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("src/shaders/liquid.wgsl");
|
|
let liquid = std::fs::read_to_string(&liquid_path).expect("liquid.wgsl");
|
|
let mut composer = wgsl::composer_for(&liquid, &modules)
|
|
.unwrap_or_else(|e| panic!("liquid.wgsl's imports do not compose: {e}"));
|
|
|
|
// Keys that push the same defs compile the same text: compose each def set once.
|
|
let keys = covered_keys();
|
|
assert_eq!(
|
|
keys.len(),
|
|
22 + 20,
|
|
"22 shipped keys and the debug view of each of the stylised 20 (the screen-space \
|
|
march's variants are gone with it)"
|
|
);
|
|
let mut by_defs: HashMap<Vec<&str>, Vec<LiquidKey>> = HashMap::new();
|
|
for key in keys {
|
|
by_defs.entry(key.frag_defs()).or_default().push(key);
|
|
}
|
|
let mut failures = Vec::new();
|
|
let mut composed = 0;
|
|
for (key_defs, keys) in &by_defs {
|
|
for view in wgsl::LIQUID_VIEW_KEYS {
|
|
for layout in wgsl::LIQUID_LAYOUTS {
|
|
let named: BTreeSet<&str> =
|
|
key_defs.iter().chain(view).chain(layout).copied().collect();
|
|
composed += 1;
|
|
let verdict = wgsl::compose(
|
|
&mut composer,
|
|
&liquid,
|
|
&liquid_path,
|
|
wgsl::liquid_defs(named.iter().copied()),
|
|
)
|
|
.and_then(|m| wgsl::validate(&m));
|
|
if let Err(e) = verdict {
|
|
failures.push(format!("keys {keys:?}, defs {named:?}: {e}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
assert!(
|
|
failures.is_empty(),
|
|
"liquid.wgsl fails {} of {composed} def sets; the pipelines of these keys drop every \
|
|
liquid draw they make:\n{}",
|
|
failures.len(),
|
|
failures.join("\n")
|
|
);
|
|
assert_eq!(
|
|
composed,
|
|
by_defs.len() * wgsl::LIQUID_VIEW_KEYS.len() * wgsl::LIQUID_LAYOUTS.len()
|
|
);
|
|
println!(
|
|
"liquid.wgsl validated under {composed} def sets ({} key def sets)",
|
|
by_defs.len()
|
|
);
|
|
}
|