MONKEY (reviewfix): shade water in its source wave domain

Co-Authored-By: GPT-5.6 Sol (Codex)
This commit is contained in:
pkuzic
2026-09-25 23:37:11 +01:00
co-authored by GPT-5.6 Sol (Codex)
parent c59d42e708
commit 554d3a5eb9
2 changed files with 9 additions and 3 deletions
@@ -91,6 +91,8 @@ fn water_rain_open(world_pos: vec3<f32>) -> f32 {
struct WaterFragment {
clip_position: vec4<f32>,
world_position: vec4<f32>,
// MONKEY (reviewfix): world XZ before `water_swell`, so fragment waves share its source domain.
source_xz: vec2<f32>,
// The authored per-vertex swatch depth (UV1.x): ocean byte/255, about 148 yd at 1.0.
depth: f32,
// MONKEY (water): an interior WMO pool's authored MOMT diffuse colour; white on other lanes.
@@ -555,7 +557,7 @@ fn enhanced_water(in: WaterFragment, shallow: vec4<f32>, deep: vec4<f32>) -> vec
}
let t = water_time(); // WOW_CAPTURE_WATER_T pins the frozen water phase.
let fog = water_fog(in.world_position.xyz, in.room_fog);
let p = in.world_position.xz;
let p = in.source_xz;
let energy = clamp(water.mode.y, 0.0, 1.0);
let ocean_mesh = water.lane.y > 0.5 && water.lane.x < 0.5;
@@ -85,6 +85,8 @@ struct LiquidVsOut {
@location(5) vcolor: vec4<f32>,
// `MeshTag` bit 30: the room's per-frame interior-fog gate, the reference's `[0xca7f00]`.
@location(6) @interpolate(flat) room_fog: u32,
// MONKEY (reviewfix): the analytic water domain before the ocean's vertex displacement.
@location(7) source_xz: vec2<f32>,
}
// Sun sheen (`secondary`): the Blinn highlight `light_spec.rgb · (N·H)^shininess`.
@@ -147,8 +149,9 @@ fn vertex(in: Vertex) -> LiquidVsOut {
let world_from_local = mesh_functions::get_world_from_local(in.instance_index);
out.world_position =
mesh_functions::mesh_position_local_to_world(world_from_local, vec4<f32>(in.position, 1.0));
out.source_xz = out.world_position.xz;
// MONKEY (enhanced water): ocean Gerstner displacement; zero on Classic/other surfaces.
out.world_position += vec4<f32>(water_swell(out.world_position.xz, in.uv_b.x, in.uv_b.y), 0.0);
out.world_position += vec4<f32>(water_swell(out.source_xz, in.uv_b.x, in.uv_b.y), 0.0);
out.clip_position = position_world_to_clip(out.world_position.xyz);
out.world_normal = mesh_functions::mesh_normal_local_to_world(in.normal, in.instance_index);
out.uv = in.uv;
@@ -221,7 +224,8 @@ fn fragment(in: LiquidVsOut) -> @location(0) vec4<f32> {
return enhanced_water(
// MONKEY (water): the enhanced interior arm consumes the MOMT colour already carried
// by the reference fragment interface; exterior/ADT vertices supply white.
WaterFragment(in.clip_position, in.world_position, in.depth, in.vcolor, in.room_fog),
WaterFragment(in.clip_position, in.world_position, in.source_xz, in.depth, in.vcolor,
in.room_fog),
shallow_enhanced, deep_enhanced);
}