Skip to content

3D engine that AI agents drive

Test that the vertexGroup weight map reaches the GPU tracer atlas (#1957)

Nguyen Xuan An5b7a2c5458d1
diff --git a/changes/1957.size.md b/changes/1957.size.md
index 4ce997e3..de3b512f 100644
--- a/changes/1957.size.md
+++ b/changes/1957.size.md
@@ -1,3 +1,3 @@
- scene:agent-scene: 185 bytes gzip for the vertexGroup graph node and its per-mesh weight-map rasterizer, which lets a graph mix a vertex group with noise and layers on every backend
- scene:agent-scene+lazy: 1773 bytes gzip for the same node, its weight-map rasterizer and the per-mesh material view, which is the only way a vertex group reaches the path tracers
-- goal:agent-scene: 185 bytes gzip for the vertexGroup graph node, an agent-facing capability that mixes a mesh vertex group into a material graph; the tracers read it only through the per-mesh baked texture
+- goal:agent-scene: 185 bytes gzip for the vertexGroup graph node, an agent-facing capability that mixes a mesh vertex group into a material graph; the lead accepted the growth as a new agent capability (the tracers read it only through the per-mesh baked texture)
diff --git a/tests/material-graph-vertex-group.test.js b/tests/material-graph-vertex-group.test.js
index bbd9bf81..549d3e0c 100644
--- a/tests/material-graph-vertex-group.test.js
+++ b/tests/material-graph-vertex-group.test.js
@@ -5,6 +5,8 @@ import { createAgentScene } from '../src/agent-scene.js';
import { compileMaterialGraph } from '../src/material-graph.js';
import { bakeMaterialPattern, normalizeMaterialPattern } from '../src/material-patterns.js';
import { vertexGroupMap } from '../src/material-vertex-group-map.js';
+import { packAtlas } from '../src/path-tracer-gpu-pack.js';
+import { buildTraceScene } from '../src/path-tracer-scene.js';
const EDGE_GRAPH = { color: { mul: [[1, 1, 1], { vertexGroup: { name: 'edge' } }] } };
@@ -86,3 +88,21 @@ test('the part bakes the graph with its own mesh weights; a graph without the no
const direct = bakeMaterialPattern(normalizeMaterialPattern(plainPattern));
assert.deepEqual(redChannel(plain.material.map), redChannel(direct.map), 'a graph without the node bakes exactly as before');
});
+
+test('the baked weight map reaches the GPU tracer texture list and the atlas holds its texels', () => {
+ const scene = createAgentScene(recipeWith({ edits: withUvs, pattern: graphPattern(EDGE_GRAPH) }));
+ const traced = buildTraceScene(scene.parts, {});
+ const [material] = traced.materials;
+ assert.ok(material.texture, 'the traced material carries the baked graph as its colour texture');
+ const baked = redChannel(scene.parts[0].material.map);
+ assert.equal(material.texture.width * material.texture.height, baked.length);
+ const atlas = packAtlas(traced.materials);
+ const placement = atlas.placements.get(material.texture.data);
+ assert.ok(placement, 'the atlas placed the baked texture');
+ const atlasTexels = [];
+ for (let row = 0; row < material.texture.height; row++) {
+ const start = ((placement.y + row) * atlas.width + placement.x) * 4;
+ for (let column = 0; column < material.texture.width; column++) atlasTexels.push(atlas.data[start + column * 4]);
+ }
+ assert.ok(atlasTexels.some(value => value > 200) && atlasTexels.some(value => value < 40), 'the atlas keeps the bright edge and dark interior of the weight map');
+});