3D engine that AI agents drive
Tile the graph noise by default, keep Blender's endless lattice behind tile: false (part of #50)
Nguyen Xuan An15dd78b2a2ab
diff --git a/bench/reference/README.md b/bench/reference/README.mdindex b77d34ec..667ad46a 100644--- a/bench/reference/README.md+++ b/bench/reference/README.md@@ -1483,7 +1483,7 @@ What is left is not in the bake. On the bump-only wall across the dark side of a## The graph noise node is Blender's Noise Texture (2026-11-04, part of issue #50, RTX 3060 960 x 540)-The brick-tone error of `brick-graph` was a pattern error: the `noise` node was a periodic gradient noise with its own hash, so its blotches sat in other places than Cycles' and EEVEE's. Blender 5.2.2 headless baked its Noise Texture (2D, Fac) over the unit square to float arrays (Cycles on the CPU, 1 sample, filter 0.01, `Geometry > Position` as the vector), and the 67js node was evaluated at the same pixel centres, 256 x 256.+The brick-tone error of `brick-graph` was a pattern error: the `noise` node was a periodic gradient noise with its own hash, so its blotches sat in other places than Cycles' and EEVEE's. Blender 5.2.2 headless baked its Noise Texture (2D, Fac) over the unit square to float arrays (Cycles on the CPU, 1 sample, filter 0.01, `Geometry > Position` as the vector), and the 67js node (`tile: false`) was evaluated at the same pixel centres, 256 x 256.| Property | Before | Blender 5.2 | Now || --- | --- | --- | --- |@@ -1492,7 +1492,7 @@ The brick-tone error of `brick-graph` was a pattern error: the `noise` node was| Output scale | `1.5 * gradient`, range about -1 to 1 | `0.6616 * perlin` | the same || Octaves | cells doubled per octave inside a wrapped period, gain 0.5, own seed per octave | Detail `n - 1`: `n` octaves, Roughness 0.5, Lacunarity 2, same lattice shifted by the frequency | the same || Normalize and offset | `value * 0.5 + 0.5` of the amplitude-normalised sum | `0.5 * sum / amplitude sum + 0.5` | the same |-| Tiling | wrapped over the unit square | none | none by default, `"tile": true` wraps it |+| Tiling | wrapped over the unit square | none | wrapped by default; `"tile": false` is Blender's endless lattice (exact, does not repeat) || Seed | per-octave seed in the hash | none | moves the lattice by whole cells; Blender's side adds the same shift |Node output against the Cycles bake: scale 10, detail 2: max 0.000048, mean 0.000011 over 65,536 pixels (both ranges 0.120 to 0.831); scale 7, detail 5 (6 octaves): max 0.000052, mean 0.000010. That is float precision, so the match is per pixel; `tests/material-graph.test.js` keeps six Cycles values. The colour ramp (LINEAR in RGB, stops in linear colour) and the Map Range smoothstep were read and need no change. Not touched: `voronoi`, which no reference scene uses and which Blender computes with its own jittered-point hash; it still differs from Blender's Voronoi Texture.diff --git a/bench/reference/render-blender.py b/bench/reference/render-blender.pyindex 8ca3056a..a2b42bf1 100644--- a/bench/reference/render-blender.py+++ b/bench/reference/render-blender.py@@ -234,7 +234,7 @@ GRAPH_MATH_OPERATIONS = {"pow": "POWER", "abs": "ABSOLUTE", "floor": "FLOOR", "fract": "FRACT", "sqrt": "SQRT",}# The graph noise node of 67js is Blender's Noise Texture (2D, fBm, Roughness 0.5, Lacunarity 2, Normalize), value for-# value (bench/reference/README.md, 2026-11-04). A graph noise with "tile": true wraps its lattice and is not translated.+# value (bench/reference/README.md, 2026-11-04) when it says "tile": false. A tiling noise (the default) wraps its lattice.GRAPH_BUMP_DISTANCE = 0.15@@ -319,8 +319,8 @@ class GraphTranslator:return node.outputs["Result"]def noise(self, settings):- if settings.get("tile"):- raise NotImplementedError("Blender's noise lattice does not wrap, so a tiled noise has no Blender node.")+ if settings.get("tile", True):+ raise NotImplementedError("Blender's noise lattice does not wrap: a reference noise needs \"tile\": false.")node = self.nodes.new("ShaderNodeTexNoise")node.noise_dimensions = "2D"node.inputs["Scale"].default_value = settings.get("scale", 4)diff --git a/bench/reference/scenes.js b/bench/reference/scenes.jsindex 8c6afc5a..680109ca 100644--- a/bench/reference/scenes.js+++ b/bench/reference/scenes.js@@ -78,7 +78,7 @@ function brickGraph() {const jointAcross = { smoothstep: [0.12, 0.3, { wave: { frequency: BRICK_COLUMNS, direction: 'u', shape: 'triangle', at: shifted } }] };const jointAlong = { smoothstep: [0.08, 0.2, { wave: { frequency: BRICK_ROWS, direction: 'v', shape: 'triangle' } }] };const body = { min: [jointAcross, jointAlong] };- const tone = { ramp: { value: { noise: { scale: 10, octaves: 3 } }, stops: [[0, [0.3, 0.09, 0.05]], [1, [0.58, 0.24, 0.14]]] } };+ const tone = { ramp: { value: { noise: { scale: 10, octaves: 3, tile: false } }, stops: [[0, [0.3, 0.09, 0.05]], [1, [0.58, 0.24, 0.14]]] } };return { color: { mix: [[0.45, 0.42, 0.38], tone, body] }, height: body };}diff --git a/changes/50-noise.md b/changes/50-noise.mdindex 70d73b5d..94f49ea1 100644--- a/changes/50-noise.md+++ b/changes/50-noise.md@@ -1 +1 @@-- Make the graph `noise` node Blender's Noise Texture node, value for value (issue #50). It was a periodic gradient noise with its own hash; it is now Blender's 2D Perlin (Jenkins hash, 8 gradients, quintic fade) summed as fractal Brownian motion with detail `octaves - 1`, roughness 0.5, lacunarity 2 and Normalize on, and matches a Cycles bake of the node to 5e-5 at every pixel. The seed shifts the lattice by whole cells, and `"tile": true` wraps the lattice for a texture that must repeat.+- Make the graph `noise` node Blender's Noise Texture node, value for value (issue #50). It was a periodic gradient noise with its own hash; it is now Blender's 2D Perlin (Jenkins hash, 8 gradients, quintic fade) summed as fractal Brownian motion with detail `octaves - 1`, roughness 0.5, lacunarity 2 and Normalize on, and matches a Cycles bake of the node to 5e-5 at every pixel. The seed shifts the lattice by whole cells, and `"tile": false` keeps Blender's endless lattice (exact match, does not repeat); by default the lattice wraps so the texture tiles.diff --git a/docs/agent-scene.md b/docs/agent-scene.mdindex a752dcc1..12c622af 100644--- a/docs/agent-scene.md+++ b/docs/agent-scene.md@@ -175,10 +175,9 @@ Nodes: `uv` (`"u"`, `"v"` or `"both"`), `noise`, `voronoi` (`output`: `distance`(2 to 8 stops of numbers or colours), `vec`, and the maths nodes `add`, `sub`, `mul`, `div`, `min`, `max`, `pow`, `abs`, `floor`,`fract`, `sqrt`, `invert`, `clamp`, `smoothstep` and `mix`. Maths nodes work on each component of a vector. Every texturenode takes `at`, a vector expression such as `{ "add": [{ "uv": "both" }, { "mul": [{ "vec": [0.1, 0, 0] }, 1] }] }`, to warp-it. Scales and counts are whole numbers (1 to 64, even for `checker`), so every texture node tiles, except `noise`: it is-Blender's Noise Texture node value for value (2D, detail `octaves - 1`, roughness 0.5, lacunarity 2, normalized; `seed` moves the-lattice by whole cells), whose lattice does not wrap. Add `"tile": true` to a `noise` that must repeat, at the cost of a different-last cell row and column.+it. Scales and counts are whole numbers (1 to 64, even for `checker`), so every texture node tiles. `noise` is Blender's Noise Texture+(2D, detail `octaves - 1`, roughness 0.5, lacunarity 2, normalized; `seed` moves the lattice by whole cells) with the lattice+wrapped so it repeats. `"tile": false` matches Blender's Noise Texture exactly, does not repeat.Limits, checked while the recipe is read: at most 64 nodes in all outputs, depth 12 (the field expression limits), at most 8 rampstops, `resolution` of 256, 512 or 1024, and a work budget of 30 million units, where a plain node costs 1, a `noise` octave 3diff --git a/src/material-graph.js b/src/material-graph.jsindex 9daaa3cb..96b81a1e 100644--- a/src/material-graph.js+++ b/src/material-graph.js@@ -209,7 +209,7 @@ function compileNoise(node, state, depth) {const seed = integerInRange(settings.seed ?? 0, 0, MAX_SEED, 'noise seed');const octaves = integerInRange(settings.octaves ?? 4, 1, NOISE_OCTAVE_LIMIT, 'noise octaves');if (settings.tile !== undefined && typeof settings.tile !== 'boolean') throw graphError('noise tile must be true or false.');- const tileCells = settings.tile ? scale : 0;+ const tileCells = settings.tile === false ? 0 : scale;const shiftX = (seed * SEED_SHIFT_X) % SEED_SHIFT_RANGE;const shiftY = (seed * SEED_SHIFT_Y) % SEED_SHIFT_RANGE;state.cost += octaves * NOISE_COST_PER_OCTAVE;diff --git a/tests/material-graph.test.js b/tests/material-graph.test.jsindex ca9ad8ab..388c58e1 100644--- a/tests/material-graph.test.js+++ b/tests/material-graph.test.js@@ -94,7 +94,7 @@ test('the slope of a sharp joint edge stays within one texel of the edge instead});test('every graph texture node tiles across the seam', () => {- const nodes = [{ noise: { scale: 6, tile: true } }, { voronoi: { scale: 5, output: 'edge' } }, { wave: { frequency: 3, direction: 'diagonal' } }, { checker: { count: 8 } }];+ const nodes = [{ noise: { scale: 6 } }, { voronoi: { scale: 5, output: 'edge' } }, { wave: { frequency: 3, direction: 'diagonal' } }, { checker: { count: 8 } }];for (const node of nodes) {const { outputs } = compileMaterialGraph({ height: node });const evaluate = outputs.height.evaluate;@@ -117,15 +117,15 @@ test('the noise node returns the values of Blender 5.2 Noise Texture (2D, scale[0.998046875, 0.998046875, 0.511450],[0.978515625, 0.013671875, 0.487824],];- const { outputs } = compileMaterialGraph({ height: { noise: { scale: 10, octaves: 3 } } });+ const { outputs } = compileMaterialGraph({ height: { noise: { scale: 10, octaves: 3, tile: false } } });for (const [u, v, expected] of golden) {assert.ok(Math.abs(outputs.height.evaluate(u, v) - expected) < 1e-4, `noise at ${u}, ${v}`);}});-test('a tiled noise repeats over the unit square and differs from the endless one only near the far edges', () => {- const endless = compileMaterialGraph({ height: { noise: { scale: 10, octaves: 3 } } }).outputs.height.evaluate;- const tiled = compileMaterialGraph({ height: { noise: { scale: 10, octaves: 3, tile: true } } }).outputs.height.evaluate;+test('a noise tiles by default and differs from the endless one (tile false) only near the far edges', () => {+ const endless = compileMaterialGraph({ height: { noise: { scale: 10, octaves: 3, tile: false } } }).outputs.height.evaluate;+ const tiled = compileMaterialGraph({ height: { noise: { scale: 10, octaves: 3 } } }).outputs.height.evaluate;assert.ok(Math.abs(tiled(0.4, 0.3) - endless(0.4, 0.3)) < 1e-12);assert.ok(Math.abs(tiled(0.4, 0.3) - tiled(1.4, 2.3)) < 1e-9);assert.throws(() => compileMaterialGraph({ height: { noise: { tile: 'yes' } } }), /tile/);