@@ -1508,26 +1508,31 @@ fn cs_main(@builtin(global_invocation_id) gid: vec3<u32>) {
15081508 var seed_m2 = 0.0;
15091509 var seed_n = 0.0;
15101510 var seed_w = 0.0;
1511- // 7x7: under TRANSLATION a whole COLUMN of texels streams in per
1512- // frame (rotation only trickles a few px), so a 5x5 often found
1513- // nothing but fellow newborns and the band stayed raw.
1514- for (var by = -3; by <= 3; by = by + 1) {
1515- for (var bx = -3; bx <= 3; bx = bx + 1) {
1516- if (bx == 0 && by == 0) { continue; }
1517- let q = vec2<i32>(i32(gid.x) + bx, i32(gid.y) + by);
1518- if (q.x < 0 || q.y < 0 || q.x >= i32(u.size.x) || q.y >= i32(u.size.y)) {
1519- continue;
1511+ // A global reset leaves old bytes allocated, but size.w = 0
1512+ // makes them invalid. Do not let neighbour seeding resurrect
1513+ // those moments after a mode toggle, camera cut, or seed change.
1514+ if (u.size.w > 0u) {
1515+ // 7x7: under TRANSLATION a whole COLUMN of texels streams in
1516+ // per frame (rotation only trickles a few px), so a 5x5 often
1517+ // found nothing but fellow newborns and the band stayed raw.
1518+ for (var by = -3; by <= 3; by = by + 1) {
1519+ for (var bx = -3; bx <= 3; bx = bx + 1) {
1520+ if (bx == 0 && by == 0) { continue; }
1521+ let q = vec2<i32>(i32(gid.x) + bx, i32(gid.y) + by);
1522+ if (q.x < 0 || q.y < 0 || q.x >= i32(u.size.x) || q.y >= i32(u.size.y)) {
1523+ continue;
1524+ }
1525+ let qidx = u32(q.y) * u.size.x + u32(q.x);
1526+ let m = moments[qidx];
1527+ if (m.w >= 0.9999999 || m.z < 4.0) { continue; }
1528+ if (abs(lin_depth(m.w) - zl_here) > btol) { continue; }
1529+ let wt = m.z;
1530+ seed_rgb += accum[qidx].rgb * wt;
1531+ seed_m1 += m.x * wt;
1532+ seed_m2 += m.y * wt;
1533+ seed_n += m.z * wt;
1534+ seed_w += wt;
15201535 }
1521- let qidx = u32(q.y) * u.size.x + u32(q.x);
1522- let m = moments[qidx];
1523- if (m.w >= 0.9999999 || m.z < 4.0) { continue; }
1524- if (abs(lin_depth(m.w) - zl_here) > btol) { continue; }
1525- let wt = m.z;
1526- seed_rgb += accum[qidx].rgb * wt;
1527- seed_m1 += m.x * wt;
1528- seed_m2 += m.y * wt;
1529- seed_n += m.z * wt;
1530- seed_w += wt;
15311536 }
15321537 }
15331538 if (seed_w > 0.0) {
0 commit comments