Shadow: authentic terrain tilt + decal draw order (feet layer correctly)
User report: the ground shadow painted OVER the mech's feet. Root cause: the
flat quad + big depth-bias (-0.004 ~= 2-4 world units) workaround for slope
burial -- a bias big enough to beat the TERRAIN also beat the FEET in the
depth test, and the shadow drew in the late alpha-blend pass (after the mech),
so z-arbitration was the only layering control.
Fix, four co-dependent parts (user-verified live: feet on top, opaque,
survives inclines/declines):
- TILT (mech.cpp UpdateShadowJoint): apply the SKL's own contract for
jointshadow ("apply terrain angle to pitch and roll") -- quad up aligned to
the surface normal via an orthonormal basis fed to the ENGINE's own
LinearMatrix->EulerAngles conversion. Hand-derived Euler signs are exactly
how the prior tilt attempts "dug into the hillside"; the engine conversion
is convention-proof. ~35 deg cliff-guard cap.
- SAMPLER (mech4.cpp): surface gradient from the collision probes PLUS
BTVisualGroundLift per probe -- the quad hugs the VISIBLE terrain, whose
lift varies across a slope; world->local rotation by the TRUE yaw from
localToWorld, not the drift-prone gDriveHeading mirror (the task-#48 bug
class). BT_SHADOW_LOG traces the normals.
- DRAW ORDER (new PASS_SHADOW, l4d3d.h/L4VIDRND/L4VIDEO): shadows draw
between the STATIC terrain and the DYNAMIC opaque bodies -- the classic
decal order. The mech, drawn after, z-passes over the shadow: the bias
can never paint the shadow over the feet, structurally.
- BIAS pairing (L4D3D.cpp): tilt on (default) -> decal epsilon -0.0008;
BT_SHADOW_TILT=0 flat fallback -> the old -0.004. BT_SHADOW_BIAS overrides.
KB (locomotion.md): the four-part arrangement recorded as co-dependent, with
the gait-desync-symptom diagnostic hint retained.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
099cad998d
commit
b6fe686b22
+22
-10
@@ -86,16 +86,28 @@ them out) → poll `GetAsyncKeyState` per frame, gated on foreground. Virtual co
|
||||
persistent throttle LEVER with a zero detent; A/D a momentary auto-centering stick. [T2]
|
||||
|
||||
## Shadow (default-on, `BT_SHADOW_TILT`)
|
||||
BT 4.10's shadow is the flat `*_tshd.bgf` proxy drawn as blend-pass geometry, posed by `jointshadow`
|
||||
(terrain tilt) + `jointtshadow` (torso twist). Terrain-tilt samples the collision surface gradient;
|
||||
a depth-bias (`D3DRS_DEPTHBIAS`, decal-style) stops it z-fighting/vanishing on inclines. Polar maps
|
||||
have STUB `*_tshd` (shadow authored-off on snow). Also the visual-ground conform (`btvisgnd.cpp`,
|
||||
render-only lift to the visible terrain triangles — presentation only, never touches localOrigin). [T2]
|
||||
⚠ **"Shadow vanishes on inclines" can be a GAIT-DESYNC symptom, not a bias/tilt bug.** The 2026-07-09
|
||||
recurrence CO-RESOLVED with the gait v5 fix (user-confirmed live; no shadow code changed). The bias
|
||||
margin is only ~2-4 world units, so anything that pops the displayed root pose (v4's out-of-phase leg
|
||||
channel showing through) can push the flat quad under the slope → vanish [T2 observation; mechanism
|
||||
T4]. Before touching bias/tilt for this report, check `[sync]`/`BT_SYNC_LOG` for channel drift first.
|
||||
BT 4.10's shadow is the `*_tshd.bgf` proxy, posed by `jointshadow` (terrain tilt — the SKL's own
|
||||
contract: "apply terrain angle to pitch and roll") + `jointtshadow` (torso twist). The working 2026-07-09
|
||||
arrangement (user-verified live: feet layer over it, opaque, survives inclines/declines) has FOUR
|
||||
co-dependent parts — change one, re-check the others:
|
||||
1. **TILT** (mech.cpp `UpdateShadowJoint`): quad up aligned to the surface normal via an orthonormal
|
||||
basis fed to the ENGINE's own LinearMatrix→EulerAngles conversion — hand-derived Euler signs are
|
||||
exactly how two prior tilt attempts "dug into the hillside"/vanished. ~35° cliff-guard cap.
|
||||
2. **SAMPLER** (mech4.cpp): gradient from the collision probes PLUS `BTVisualGroundLift` per probe
|
||||
(the quad hugs the VISIBLE terrain, whose lift varies across a slope); world→local by the TRUE yaw
|
||||
from `localToWorld` (NOT the `gDriveHeading` scalar mirror — the task-#48 drift bug class).
|
||||
`BT_SHADOW_LOG` traces the normals.
|
||||
3. **DRAW ORDER** (`PASS_SHADOW`, l4d3d.h/L4VIDRND/L4VIDEO): shadows draw between the STATIC terrain
|
||||
and the DYNAMIC opaque bodies (classic decal order), so the mech z-passes over the shadow — the
|
||||
bias can never paint the shadow OVER the feet, structurally.
|
||||
4. **BIAS pairing** (L4D3D.cpp): tilt on (default) → decal epsilon −0.0008; `BT_SHADOW_TILT=0`
|
||||
(flat A/B fallback) → the old −0.004 it needs to survive slope burial. `BT_SHADOW_BIAS` overrides.
|
||||
Polar maps have STUB `*_tshd` (shadow authored-off on snow). The visual-ground conform (`btvisgnd.cpp`)
|
||||
stays render-only (never touches localOrigin). [T2]
|
||||
⚠ **"Shadow vanishes on inclines" can also be a GAIT-DESYNC symptom.** The first 2026-07-09 recurrence
|
||||
CO-RESOLVED with the gait v5 fix (no shadow code changed): a popping root pose (out-of-phase leg
|
||||
channel showing through) can push the quad past the bias margin. Check `[sync]`/`BT_SYNC_LOG` for
|
||||
channel drift before touching the shadow itself. [T2 observation; mechanism T4]
|
||||
|
||||
## Key Relationships
|
||||
- Detail: `docs/P3_LOCOMOTION.md`. Uses: [[asset-formats]] (SKL/ANI), [[decomp-reference]] (offsets).
|
||||
|
||||
Reference in New Issue
Block a user