Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(render): Voxel GI's screen samples take a different pixel of four each frame, so a thin face no longer makes a wall's bounce change with the size of the picture

yhh5335657486f5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31e1eb0db..e635d247a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ published separately; it ships inside the editor.
### Fixed
+- **Voxel GI no longer changes with the size of the picture.** It took the same one pixel in four for its cache every frame, so a face a few rows tall (the top of a block seen nearly edge on) landed in it at one row or two according to the window's size, and the light around it moved: a wall read 18% apart across sizes, up to 11% for a window one pixel taller. The pixel now changes each frame. Across eight of nine sizes the same wall is within 7%, one size with an odd width and height still reads higher, and the light against Cycles and the frame-to-frame stability are unchanged.
- **Voxel GI costs a third of what it did.** Every cell a ray crossed took two integer divisions, a hash, and a read in the 32 MB grid, which is a cache miss, for a cell that is nearly always empty. Wrapping is now a mask, the hash check is gone (the cache re-tags every slot each frame, so it could not fail), and the tags hold a mark saying whether a slot has anything, read before the grid is. On an RTX 3060 at 720p the default settings went from 17.3 to about 5.4 ms a frame, and the picture is the same: held against the old kernels, the difference is no larger than between two runs of one build.
- **Writing an entity list on the web replaces it.** A `SpringBone.colliders` or `MeshSkin.joints` written to a component that already had one was added to what was there, so a `[a, b]` written twice read `[a, b, a, b]`, a `Mut` row grew it on every write-back (72 entries in a few frames) and writing `[]` cleared nothing. Number lists and native builds were right.
- **A spring bone's colliders work in a native build.** Entity lists were left out of the native bindings unless written by hand, and only `MeshSkin` and `Children` were. `SpringBone.colliders` from a scene never reached the engine on a device, with no error: hair and tails passed through what they should have been kept out of, and a script reading the field got `undefined`. Every entity list now crosses as a generated pair, as other lists do.
diff --git a/src/esengine/renderer/frame/VoxelGI.cpp b/src/esengine/renderer/frame/VoxelGI.cpp
index e1d80b5fa..091c46114 100644
--- a/src/esengine/renderer/frame/VoxelGI.cpp
+++ b/src/esengine/renderer/frame/VoxelGI.cpp
@@ -141,7 +141,11 @@ const char* kInject = R"WGSL(
@compute @workgroup_size(8, 8)
fn main(@builtin(global_invocation_id) id : vec3u) {
let size = vec2i(textureDimensions(depthTex));
- let t = vec2i(id.xy) * 2;
+ // One pixel in four, a different one each frame, as the gather takes its own: always the same four left a face two rows tall (a block's
+ // top seen nearly edge on) in the grid at one row or two by the size of the picture, and what it lit moved with it. The grid ages over
+ // more frames than this takes, so it holds them all.
+ let frameIndex = i32(gi.origin.w);
+ let t = vec2i(id.xy) * 2 + vec2i(frameIndex & 1, (frameIndex >> 1) & 1);
if (t.x >= size.x || t.y >= size.y) { return; }
let depth = textureLoad(depthTex, t, 0);
if (depth >= 1.0) { return; }
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 503e2b1db..087b43f70 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -3852,4 +3852,6 @@ export const NOTED = {
{"note":"A spring bone's colliders work in a native build"},
"perf(render): a Voxel GI ray asks a small table whether a cell holds anything and wraps it with a mask, so a default frame costs a third of what it did":
{"note":"Voxel GI costs a third of what it did."},
+ "fix(render): Voxel GI's screen samples take a different pixel of four each frame, so a thin face no longer makes a wall's bounce change with the size of the picture":
+ {"note":"Voxel GI no longer changes with the size of the picture."},
};
diff --git a/tools/render-lab/README.md b/tools/render-lab/README.md
index b848c1ea1..e3b37c1e5 100644
--- a/tools/render-lab/README.md
+++ b/tools/render-lab/README.md
@@ -133,4 +133,10 @@ Windows host, hidden, RTX 3060, 720p, uncapped (`ESTELLA_BENCH_FRAMES`), scene `
A two-level walk, skipping an empty 4x4x4 block in one step, was tried on top and measured nothing, in this room, with its walls removed, and at 12 cm: with the mark, a cell is already nearly free. It was taken out. About 1 ms of what is left does not depend on rays (the upkeep, the inject, the apply), and each ray costs about 0.4 ms.
-Held against the old kernels with this lab, the light share and the pixels match within the noise of two runs of one build (0.90 at the default size, 0.70 at 12 cm). Those are lower than the 0.95 and 0.74 recorded above, and that came with an earlier commit, not with this.
+Held against the old kernels with this lab, the light share and the pixels match within the noise of two runs of one build (0.90 at the default size, 0.70 at 12 cm). Those are lower than the 0.95 and 0.74 recorded above because of how those were taken, not because light was lost: they came from the editor's game view (1345x677, scaled and cropped to 1280x720). The current code taken that way reads 0.95 again. Compare readings only within one capture route.
+
+### Size of the picture (2026-11-05, WebGPU)
+
+The route above differed by 5% of the frame because the picture's exact size moved the light. It is not the aspect (1440x720 and 1600x720 read alike) and not chance (five restarts of one size read the same): the green wall probe went 47.3 to 52.7 from 1344x676 to 1344x677. Subtracting the two pictures put the difference on thin faces, the block's top and the patch's edge, and on the wall beside them. The inject took the same one pixel in four every frame, so a face two rows tall landed at one row or two. It now takes a different one each frame: 49.2 to 52.9 across eight sizes, with 1345x677 (odd both ways) still at 55.5, unexplained. Light share, mean error, the leak and frame-to-frame swing (1-3%) are unchanged.
+
+Moving the samples off the surface along the normal, as the sun's are, was tried for the same symptom. It did not help and darkened the wall by 18%, so it was taken out.