Skip to content

Commit bf37d45

Browse files
committed
test(render): reproduce combined shadow motion
1 parent 8d85719 commit bf37d45

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

examples/bistro/main.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ let sunShaftOverride = -1;
6767
let ssgiOverride = -1;
6868
let ssrOverride = -1;
6969
let vsmMotionPath = false;
70+
let motionYaw = 0.0;
71+
let motionFrames = 0;
7072
let shadowsAlwaysFresh = false;
7173
for (let i = 1; i < argv.length; i = i + 1) {
7274
if (argv[i] === "--capture" && i + 2 < argv.length) {
@@ -109,6 +111,12 @@ for (let i = 1; i < argv.length; i = i + 1) {
109111
if (argv[i] === "--vsm-motion-path") {
110112
vsmMotionPath = true;
111113
}
114+
if (argv[i] === "--motion-yaw" && i + 1 < argv.length) {
115+
motionYaw = parseFloat(argv[i + 1]);
116+
}
117+
if (argv[i] === "--motion-frames" && i + 1 < argv.length) {
118+
motionFrames = Math.max(0, Math.floor(parseFloat(argv[i + 1])));
119+
}
112120
if (argv[i] === "--shadows-always-fresh") {
113121
shadowsAlwaysFresh = true;
114122
}
@@ -207,15 +215,25 @@ while (!windowShouldClose()) {
207215
// Bistro camera on frame 240 for a matched static/transition comparison.
208216
let renderCamX = camX;
209217
let renderCamZ = camZ;
218+
let renderYaw = camYaw;
210219
if (vsmMotionPath) {
211220
fixtureFrame = fixtureFrame + 1;
212-
const pathStep = Math.floor(fixtureFrame / 30) % 2;
221+
// With --motion-frames, interpolate once from the launch pose to the
222+
// endpoint so the fixture crosses the same refit/cache boundaries as
223+
// interactive walking. The default keeps the established 30-frame
224+
// square wave used by the original translation-only oracle.
225+
const pathStep = motionFrames > 0
226+
? Math.min(fixtureFrame / motionFrames, 1.0)
227+
: Math.floor(fixtureFrame / 30) % 2;
213228
renderCamX = camX + pathStep * 3.748170285;
214229
renderCamZ = camZ + pathStep * 4.685212856;
230+
renderYaw = camYaw + pathStep * motionYaw;
215231
}
216-
const lookX = renderCamX + Math.cos(camPitch) * fwdX * 100;
232+
const renderFwdX = -Math.sin(renderYaw);
233+
const renderFwdZ = -Math.cos(renderYaw);
234+
const lookX = renderCamX + Math.cos(camPitch) * renderFwdX * 100;
217235
const lookY = camY + Math.sin(camPitch) * 100;
218-
const lookZ = renderCamZ + Math.cos(camPitch) * fwdZ * 100;
236+
const lookZ = renderCamZ + Math.cos(camPitch) * renderFwdZ * 100;
219237

220238
beginDrawing();
221239

native/shared/src/shadows.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,14 @@ impl ShadowMap {
792792
far: f32,
793793
scene_bounds: Option<([f32; 3], [f32; 3])>,
794794
) {
795+
// The diagnostic "always fresh" mode must isolate the complete
796+
// shadow state, not just depth-texture reuse. Recomputing an exact
797+
// fit here lets visual A/B captures distinguish accepted-fit history
798+
// from cached shadow contents without changing the default path.
799+
if self.always_fresh {
800+
self.accepted_fit = [None; NUM_CASCADES];
801+
}
802+
795803
let len = (light_dir[0] * light_dir[0]
796804
+ light_dir[1] * light_dir[1]
797805
+ light_dir[2] * light_dir[2])

0 commit comments

Comments
 (0)