3D engine that AI agents drive
Add named looks for the grand reference scenes
Nguyen Xuan An760fe8824fc0
diff --git a/bench/reference/README.md b/bench/reference/README.mdindex 91ce5ffc..00d0c6a4 100644--- a/bench/reference/README.md+++ b/bench/reference/README.md@@ -1430,3 +1430,20 @@ The second option was tried: for alpha-mask materials only, the base map got its| EEVEE against Cycles | 0.0924 | 0.0924 |Worse by 0.0002 against Cycles, so the default suite and `--grand` were not run and the code was reverted. Reading (inferred): the lost coverage is at full-size edges, not at coarse mips, since the crown is seen at about one texel per pixel; keeping more coverage in the coarse levels cannot reach it. Same direction as the one mip finer attempt (0.0979 to 0.0982). Next idea: match Cycles' edge softness at level 0 (a slightly blurred alpha, or the leaf alpha edge drawn with a ramp wider than a texel) instead of changing the mips.++## Named looks for the grand scenes (2026-11-03, part of issue #168)++`look-options.js` holds a second round of options for the three grand scenes, each a named variant: `node bench/reference/run.mjs --option mountain-valley:dawn` (several separated by commas) draws it with the GPU only into `artifacts/reference-look/<scene>-<option>-gpu.png`, with no Blender, no score and no baseline change. Sheets: `uv run --no-project --with pillow python -I bench/reference/look-sheets.py artifacts/reference-look artifacts/look-168` copies each frame to `artifacts/look-168/<scene>/<option>.png` and writes one contact sheet per scene. The default scenes and the letters of `grand-scenes.js` are unchanged. Blender would get the same geometry and materials: ground cover is vertex colour, facades are material graphs (Emission through the graph), halls use Emission panels and volume fog. An picks; no option is claimed to match anyone's taste.++| Option | What changes |+| --- | --- |+| `mountain-valley:dawn` | Cool dawn, sun behind the far massif, a river down a flat floor, a mist layer, ridges fading into haze, a snowy hero peak |+| `mountain-valley:tarn` | Midday on the shore of a turquoise lake, forest across the water, rounded snow massifs, boulders at the camera |+| `mountain-valley:sunset` | Low orange sun from the left, long tree shadows over wildflower drifts, one peak lit pink |+| `temple-hall:rose` | The nave seen down its axis toward a stained glass rose window and five lancets (all Emission), roof openings with sun shafts, candles along the carpet |+| `temple-hall:court` | Hall open to the sky over the nave, high sun and blue sky light, pale floor, two colossi and a glowing door at the far end |+| `megacity-dusk:golden-avenue` | Street level on a broad avenue at sunset, the right-hand towers lit gold, lines of car lights, street trees |+| `megacity-dusk:blue-hour` | Elevated bank over a river, a 560 m landmark tower, windows lit in drifts, lit bridges, parkland trees |+| `megacity-dusk:night-grid` | High night view of avenue grids, dense towers with most windows lit, cyan and magenta signs |++Terrain shape: the rim is rounded massifs (erosion noise) with a little ridged noise for crags, in place of the reference's needle ridges. Towers have a lit podium, one to three setbacks and a crown (plant, stepped or spire), and a facade graph gives panes in a wall with lit panes in drifts instead of full-width stripes. No downloaded textures or models are used: the terrain chunks and tower boxes carry no UV sets in the export, so a scanned texture would not reach Blender the same way.diff --git a/bench/reference/grand-scenes.js b/bench/reference/grand-scenes.jsindex 6b25531f..b3ac2a4e 100644--- a/bench/reference/grand-scenes.js+++ b/bench/reference/grand-scenes.js@@ -11,12 +11,12 @@ import {normalized, part, seededRandom, smoothBetween, sunShadow,} from './scenes.js';-const UNIT_BOX = box(0, 1);-const UNIT_CYLINDER = cylinder(32, 0, 1);-const UNIT_SPHERE = sphere(20, 14);+export const UNIT_BOX = box(0, 1);+export const UNIT_CYLINDER = cylinder(32, 0, 1);+export const UNIT_SPHERE = sphere(20, 14);// A part with a turn about Y (yaw) and then about X (pitch), which `part` does not have.-function turnedPart(name, geometry, translation, scale, material, yaw = 0, pitch = 0) {+export function turnedPart(name, geometry, translation, scale, material, yaw = 0, pitch = 0) {const [cosYaw, sinYaw] = [Math.cos(yaw), Math.sin(yaw)];const [cosPitch, sinPitch] = [Math.cos(pitch), Math.sin(pitch)];const turn = ([x, y, z]) => [cosYaw * x + sinYaw * z, y, -sinYaw * x + cosYaw * z];@@ -28,7 +28,7 @@ function turnedPart(name, geometry, translation, scale, material, yaw = 0, pitch// Sky colour by elevation: horizon to zenith above the horizon (raised to `power`), horizon to ground below it.// render-blender.py (gradient_sky_image) uses the same formula, and `intensity` scales all three colours.-function skyGradient({ zenith, horizon, ground = horizon, power = 0.5, intensity = 1 }) {+export function skyGradient({ zenith, horizon, ground = horizon, power = 0.5, intensity = 1 }) {const [width, height] = [256, 128];const scaled = colors => colors.map(color => color.map(channel => channel * intensity));const [zenithColor, horizonColor, groundColor] = scaled([zenith, horizon, ground]);@@ -44,14 +44,14 @@ function skyGradient({ zenith, horizon, ground = horizon, power = 0.5, intensityreturn { map, blenderWorld: { type: 'gradient', zenith: zenithColor, horizon: horizonColor, ground: groundColor, power } };}-const WATER = { color: [0.02, 0.05, 0.08], roughness: 0.04 };+export const WATER = { color: [0.02, 0.05, 0.08], roughness: 0.04 };// ---------------------------------------------------------------------------------------------------------------------// Mountain valley// The reference valley (floor hills, a rim of ridged peaks, a far wall) with options: a flatter floor, a hero peak, and// `carve(x, z, height)` for a lake or a river.-function valleyHeight({ floorScale = 1, floorOffset = 0, rimScale = 1, hero = null, carve = (x, z, height) => height }) {+export function valleyHeight({ floorScale = 1, floorOffset = 0, rimScale = 1, hero = null, carve = (x, z, height) => height }) {const floorHills = createNoiseHeight({ amplitude: 14, featureSize: 260, mountainMask: () => 0 }, 3);const peaks = createNoiseHeight({ amplitude: 0, mountainAmplitude: 1100, featureSize: 800, octaves: 7, warp: 260, warpFeatureSize: 700, mountainMask: () => 1 }, 11);return (x, z) => {@@ -86,7 +86,7 @@ function paintGrandTerrain(terrain, { grass, alpine, rock, snow, shore, treeLine}// Boulders around a point: squashed spheres and tilted blocks, so the near ground reads as rock and not as a bare slope.-function boulderParts({ terrain, center, innerRadius, outerRadius, count, size, seed, facing = 0 }) {+export function boulderParts({ terrain, center, innerRadius, outerRadius, count, size, seed, facing = 0 }) {const random = seededRandom(seed);const parts = [];const tones = [[0.3, 0.27, 0.24], [0.24, 0.23, 0.22], [0.36, 0.32, 0.27], [0.2, 0.22, 0.17]];@@ -188,7 +188,7 @@ async function mountainValleyC() {const ROBES = [[0.5, 0.1, 0.08], [0.1, 0.2, 0.45], [0.55, 0.45, 0.15], [0.15, 0.3, 0.18], [0.4, 0.4, 0.42], [0.6, 0.3, 0.1]];// People at the given [x, z] spots: a robe and a head, 1.5 to 1.8 m tall, for scale.-function peopleParts(spots, prefix = 'person') {+export function peopleParts(spots, prefix = 'person') {const parts = [];spots.forEach(([x, z, yaw = 0], index) => {const height = 1.55 + (index % 4) * 0.08;@@ -198,17 +198,17 @@ function peopleParts(spots, prefix = 'person') {return parts;}-function fogBox(density, minimum, maximum, maxDistance, anisotropy = 0.6) {+export function fogBox(density, minimum, maximum, maxDistance, anisotropy = 0.6) {return { density, minimum, maximum, color: [1, 0.95, 0.85], ambient: [0.02, 0.02, 0.02], anisotropy, noiseAmount: 0, steps: 48, maxDistance };}-const NAVE_LENGTH = HALL.front - HALL.back;-const NAVE_MIDDLE = (HALL.front + HALL.back) / 2;-const STONE = { color: [0.52, 0.45, 0.36], roughness: 0.85 };-const FLOOR_STONE = { color: [0.36, 0.32, 0.27], roughness: 0.6 };+export const NAVE_LENGTH = HALL.front - HALL.back;+export const NAVE_MIDDLE = (HALL.front + HALL.back) / 2;+export const STONE = { color: [0.52, 0.45, 0.36], roughness: 0.85 };+export const FLOOR_STONE = { color: [0.36, 0.32, 0.27], roughness: 0.6 };// The reference nave without the roof openings: floor, carpet, solid roof, the far wall and the columns.-function closedNaveParts() {+export function closedNaveParts() {const roofY = HALL.roofHeight;const parts = [part('hall-floor', HALL_BLOCK, [0, -0.5, NAVE_MIDDLE], [HALL.halfWidth * 2, 1, NAVE_LENGTH], FLOOR_STONE),@@ -329,10 +329,10 @@ async function templeHallC() {// ---------------------------------------------------------------------------------------------------------------------// Megacity-const GROUND = { color: [0.1, 0.1, 0.11], roughness: 0.95 };-const ROAD = { color: [0.14, 0.14, 0.15], roughness: 0.6 };+export const GROUND = { color: [0.1, 0.1, 0.11], roughness: 0.95 };+export const ROAD = { color: [0.14, 0.14, 0.15], roughness: 0.6 };-function lampParts(prefix, positions, { height = 10, emission = 14, color = [1, 0.75, 0.4] } = {}) {+export function lampParts(prefix, positions, { height = 10, emission = 14, color = [1, 0.75, 0.4] } = {}) {const parts = [];positions.forEach(([x, z], index) => {parts.push(part(`${prefix}-post-${index}`, UNIT_BOX, [x, height / 2, z], [0.5, height, 0.5], { color: [0.15, 0.15, 0.16], roughness: 0.5, metallic: 0.8 }));@@ -342,7 +342,7 @@ function lampParts(prefix, positions, { height = 10, emission = 14, color = [1,}// Towers from a list of [x, z, height] sites, with the reference city's facades, windows and spires.-function towerParts(sites, seed) {+export function towerParts(sites, seed) {const parts = [];const random = seededRandom(seed);sites.forEach(([x, z, towerHeight], index) => cityTowerParts(parts, UNIT_BOX, x, z, random, index, towerHeight));@@ -350,7 +350,7 @@ function towerParts(sites, seed) {}// Sites on a grid with jitter. `heightAt(x, z, random)` gives the height, `skip(x, z)` leaves a gap.-function gridSites({ xs, zs, jitter = 6, heightAt, skip = () => false, seed }) {+export function gridSites({ xs, zs, jitter = 6, heightAt, skip = () => false, seed }) {const random = seededRandom(seed);const sites = [];for (const z of zs) {@@ -364,8 +364,8 @@ function gridSites({ xs, zs, jitter = 6, heightAt, skip = () => false, seed }) {}// Values from `from` to `to` inclusive, in either direction.-const range = (from, to, step) => Array.from({ length: Math.floor(Math.abs(to - from) / step) + 1 }, (_, index) => from + Math.sign(to - from) * index * step);-const downtown = (x, z, centreZ, spreadX, spreadZ) => Math.exp(-(((z - centreZ) / spreadZ) ** 2)) * Math.exp(-((x / spreadX) ** 2));+export const range = (from, to, step) => Array.from({ length: Math.floor(Math.abs(to - from) / step) + 1 }, (_, index) => from + Math.sign(to - from) * index * step);+export const downtown = (x, z, centreZ, spreadX, spreadZ) => Math.exp(-(((z - centreZ) / spreadZ) ** 2)) * Math.exp(-((x / spreadX) ** 2));// A: blue hour on a river. The sun is down, the sky goes from deep blue to a warm band on the horizon, and every bridge and// quay is a line of light. Towers stand on both banks.diff --git a/bench/reference/harness.js b/bench/reference/harness.jsindex ba3cb561..2ea6507d 100644--- a/bench/reference/harness.js+++ b/bench/reference/harness.js@@ -2,6 +2,7 @@import { Renderer67 } from '/src/renderer.js';import { REFERENCE_SCENES, KHRONOS_SCENES, CLOTH_SCENES } from './scenes.js';import { GRAND_SCENES } from './grand-scenes.js';+import { LOOK_OPTIONS } from './look-options.js';import { skinnedGeometry } from '/src/path-tracer-scene.js';import { boxProjectedGeometry } from '/src/export-box-uv.js';import '/src/material-layer-shaders.js';@@ -26,7 +27,7 @@ const WATER_REFLECTION = { off: false, ssr: 'ssr' }[new URLSearchParams(location// ?set=khronos draws the Khronos sample assets (npm run reference -- --khronos) and ?set=cloth the cloth scenes// (npm run reference -- --cloth) instead of the fixed scenes.-const SCENE_SETS = { khronos: KHRONOS_SCENES, cloth: CLOTH_SCENES, grand: GRAND_SCENES };+const SCENE_SETS = { khronos: KHRONOS_SCENES, cloth: CLOTH_SCENES, grand: GRAND_SCENES, look: LOOK_OPTIONS };const SCENES = SCENE_SETS[new URLSearchParams(location.search).get('set')] ?? REFERENCE_SCENES;function encodeBytes(typedArray) {diff --git a/bench/reference/look-options.js b/bench/reference/look-options.jsnew file mode 100644index 00000000..f972960c--- /dev/null+++ b/bench/reference/look-options.js@@ -0,0 +1,482 @@+// Named looks for the grand scenes (issue #168), drawn with `npm run reference -- --option mountain-valley:dawn`. Each option changes+// composition and light (camera, sun, terrain and ground cover, hall openings, city massing and facades) and builds only what+// Blender draws too: terrain vertex colours, plain geometry, Emission, volume fog and material graphs. The default scenes of+// scenes.js and the letters of grand-scenes.js stay as they are; nothing here touches the baseline.+//+// No downloaded assets are used: ground cover is vertex colour noise on the terrain, and facades are material graphs, so+// Blender evaluates the same nodes. Real CC0 textures would need UV sets on the terrain chunks, which the export does not carry.+import { createNoiseHeight, createTerrain } from '/src/terrain.js';+import { materialPatternTextures, normalizeMaterialPattern } from '/src/material-patterns.js';+import { scatterVegetation, selectLevels } from '/src/vegetation.js';+import {+ GROUND, ROAD, STONE, FLOOR_STONE, UNIT_BOX, UNIT_CYLINDER, UNIT_SPHERE, WATER, NAVE_LENGTH, NAVE_MIDDLE,+ boulderParts, closedNaveParts, downtown, fogBox, gridSites, lampParts, peopleParts, range, skyGradient, turnedPart,+} from './grand-scenes.js';+import {+ HALL, HALL_BLOCK, VALLEY_TERRAIN, constantLighting, environment, hallRoofParts, mixColors, normalized, part,+ seededRandom, smoothBetween, sunShadow,+} from './scenes.js';++// ---------------------------------------------------------------------------------------------------------------------+// Mountain valley++function latticeHash(cellX, cellZ, seed) {+ const value = Math.sin(cellX * 127.1 + cellZ * 311.7 + seed * 74.7) * 43758.5453;+ return value - Math.floor(value);+}++// Smooth value noise in [0, 1]; `scale` is the size of one feature in metres.+function groundNoise(x, z, scale, seed) {+ const [cellX, cellZ] = [Math.floor(x / scale), Math.floor(z / scale)];+ const [fractionX, fractionZ] = [x / scale - cellX, z / scale - cellZ];+ const [easedX, easedZ] = [fractionX * fractionX * (3 - 2 * fractionX), fractionZ * fractionZ * (3 - 2 * fractionZ)];+ const top = latticeHash(cellX, cellZ, seed) * (1 - easedX) + latticeHash(cellX + 1, cellZ, seed) * easedX;+ const bottom = latticeHash(cellX, cellZ + 1, seed) * (1 - easedX) + latticeHash(cellX + 1, cellZ + 1, seed) * easedX;+ return top * (1 - easedZ) + bottom * easedZ;+}++function carveDisc(center, radii, depth) {+ return (x, z, height) => {+ const basin = 1 - smoothBetween(0.45, 1, Math.hypot((x - center[0]) / radii[0], (z - center[1]) / radii[1]));+ return height * (1 - basin) + depth * basin;+ };+}++function carveRiver(centreAt, depth, halfWidth) {+ return (x, z, height, rise) => {+ const channel = (1 - smoothBetween(halfWidth * 0.3, halfWidth, Math.abs(x - centreAt(z)))) * (1 - smoothBetween(0.05, 0.3, rise));+ return height * (1 - channel) + depth * channel;+ };+}++// Rim of rounded massifs (erosion noise, smooth flanks and rough crests) instead of the reference's needle ridges; `ridgeMix` adds+// a little of the ridged noise back for crags.+function lookValleyHeight({ ridgeMix = 0.25, rimScale = 1, floorScale = 1, floorOffset = 0, hero = null, carve = (x, z, height) => height }) {+ const floorHills = createNoiseHeight({ amplitude: 14, featureSize: 260, mountainMask: () => 0 }, 3);+ const massifs = createNoiseHeight({ amplitude: 1000, featureSize: 900, octaves: 6, warp: 300, warpFeatureSize: 700, mountainMask: () => 0 }, 17);+ const crags = createNoiseHeight({ amplitude: 0, mountainAmplitude: 1100, featureSize: 800, octaves: 7, warp: 260, warpFeatureSize: 700, mountainMask: () => 1 }, 11);+ return (x, z) => {+ const rise = smoothBetween(520, 1500, Math.hypot(x, z * 0.75));+ const farWall = smoothBetween(2000, 2600, Math.hypot(x, z * 0.75)) * 600;+ const rim = massifs(x, z) * 1.25 * (1 - ridgeMix) + crags(x, z) * 1.5 * ridgeMix + 420;+ let height = floorHills(x, z) * floorScale + floorOffset + rise * rim * rimScale + farWall;+ if (hero) {+ const distance = Math.hypot(x - hero.x, z - hero.z) / hero.radius;+ height += hero.height * Math.exp(-distance * distance);+ }+ return carve(x, z, height, rise);+ };+}++// Ground cover as colour: two greens in drifts, dry patches, flower drifts, darker forest floor, strata in the rock, snow with a+// ragged edge, wet gravel at the shore, and the far ground pulled toward the haze colour so ridges separate by depth.+function paintLookTerrain(terrain, { eye, palette, waterLevel, haze }) {+ const { grassLight, grassDark, dry, flowers, rock, rockDark, snow, shore, treeLine, snowLine } = palette;+ for (const terrainPart of terrain.parts) {+ const { positions, normals } = terrainPart.geometry;+ const colors = new Float32Array(positions.length);+ for (let vertex = 0; vertex < positions.length; vertex += 3) {+ const [x, height, z] = [positions[vertex], positions[vertex + 1], positions[vertex + 2]];+ const flatness = normals[vertex + 1];+ const drift = groundNoise(x, z, 70, 1);+ let color = mixColors(grassDark, grassLight, smoothBetween(0.3, 0.7, drift));+ color = mixColors(color, dry, smoothBetween(0.55, 0.8, groundNoise(x, z, 190, 2)) * 0.8);+ color = mixColors(color, flowers[Math.floor(groundNoise(x, z, 400, 4) * flowers.length) % flowers.length], smoothBetween(0.72, 0.9, groundNoise(x, z, 28, 3)) * smoothBetween(0.9, 0.97, flatness) * (1 - smoothBetween(treeLine * 0.5, treeLine * 0.8, height)));+ color = mixColors(color, grassDark.map(channel => channel * 0.6), smoothBetween(0.5, 0.75, groundNoise(x, z, 110, 5)) * (1 - smoothBetween(treeLine * 0.9, treeLine * 1.2, height)) * 0.7);+ color = mixColors(color, rockDark, smoothBetween(treeLine * 0.8, treeLine * 1.6, height) * 0.6);+ const strata = groundNoise(x, z, 120, 6) * 0.6 + groundNoise(x, z, 35, 8) * 0.4;+ color = mixColors(color, mixColors(rock, rockDark, strata), smoothBetween(0.9, 0.68, flatness));+ const snowEdge = snowLine + (groundNoise(x, z, 45, 7) - 0.5) * 90;+ color = mixColors(color, snow, smoothBetween(snowEdge, snowEdge + 70, height) * smoothBetween(0.5, 0.78, flatness));+ if (Number.isFinite(waterLevel)) color = mixColors(color, shore, 1 - smoothBetween(waterLevel + 0.5, waterLevel + 3.5, height));+ const distance = Math.hypot(x - eye[0], z - eye[2]);+ color = mixColors(color, haze.color, smoothBetween(haze.start, haze.end, distance) * haze.amount);+ colors.set(color, vertex);+ }+ terrainPart.geometry.colors = colors;+ }+}++function lookValleyScene({ sky, key, sunDirection, height, palette, water, haze, eyeGround, eyeLift, target, fov = 50, boulders, forestDensity = 0.0018, forestMix = { conifer: 1 }, treeExclusion = () => false, mist, seed = 5 }) {+ const waterLevel = water ? water.level : -Infinity;+ const eyeHeightGuess = [eyeGround[0], 100, eyeGround[1]];+ const terrain = createTerrain({ ...VALLEY_TERRAIN, height, eye: eyeHeightGuess, material: { color: [1, 1, 1], metallic: 0, roughness: 0.95, emission: 0 } });+ const eye = [eyeGround[0], terrain.heightAt(eyeGround[0], eyeGround[1]) + eyeLift, eyeGround[1]];+ paintLookTerrain(terrain, { eye, palette, waterLevel, haze });+ const forest = scatterVegetation({+ area: { minX: -1500, maxX: 1500, minZ: -1700, maxZ: 1100 }, density: forestDensity, terrainHeight: terrain.heightAt, slopeLimit: 28,+ exclusion: (x, z) => terrain.heightAt(x, z) > palette.treeLine || (water && terrain.heightAt(x, z) < waterLevel + 2.5) || treeExclusion(x, z, eye),+ mix: forestMix, variants: 3, scale: [0.8, 1.4], seed,+ });+ const parts = [...terrain.parts, ...selectLevels(forest.instances, eye, { cullDistance: 1800, distanceScale: 3 }).parts];+ if (water) parts.push(part('water', UNIT_BOX, [water.center[0], waterLevel - 0.5, water.center[1]], [water.size[0], 1, water.size[1]], water.material ?? WATER));+ if (boulders) parts.push(...boulderParts({ terrain, center: [eye[0], eye[2]], ...boulders }));+ return {+ parts, blenderWorld: sky.blenderWorld,+ environment: environment(sky, { keyColor: key, lightDirection: normalized(sunDirection), ...(mist ? { volumeFog: mist } : {}) }),+ camera: { eye, target, up: [0, 1, 0], fov, near: 0.5, far: 8000 },+ shadow: sunShadow(sunDirection, [0, 150, -400], 2300, 3500),+ };+}++const ALPINE = {+ grassLight: [0.17, 0.27, 0.08], grassDark: [0.08, 0.16, 0.05], dry: [0.3, 0.27, 0.12],+ flowers: [[0.55, 0.45, 0.08], [0.5, 0.5, 0.5], [0.3, 0.12, 0.4]],+ rock: [0.4, 0.34, 0.29], rockDark: [0.19, 0.17, 0.16], snow: [0.88, 0.9, 0.94], shore: [0.28, 0.26, 0.21],+ treeLine: 520, snowLine: 640,+};++const DAWN_RIVER = z => 120 * Math.sin(z / 280) + 35 * Math.sin(z / 90);++// Dawn: a cool, misty valley seen from the meadow edge with the sun rising behind the far massif, so the forest and the river+// are backlit and the ridges stack into pale layers.+function mountainValleyDawn() {+ return lookValleyScene({+ sky: skyGradient({ zenith: [0.14, 0.24, 0.55], horizon: [1, 0.66, 0.55], ground: [0.2, 0.17, 0.2], power: 0.4, intensity: 1.1 }),+ key: [6.2, 3.7, 2.4], sunDirection: [0.45, 0.24, -0.85],+ height: lookValleyHeight({ ridgeMix: 0.2, floorScale: 0.6, floorOffset: 3, hero: { x: 80, z: -1250, radius: 380, height: 700 }, carve: carveRiver(DAWN_RIVER, -6, 60) }),+ palette: ALPINE, water: { level: -1, center: [0, -400], size: [3000, 3000] },+ haze: { color: [0.75, 0.62, 0.64], start: 900, end: 4200, amount: 0.55 },+ eyeGround: [-200, 430], eyeLift: 45, target: [60, 330, -1500], fov: 52, forestDensity: 0.002,+ forestMix: { conifer: 1, birch: 0.12 },+ boulders: { innerRadius: 8, outerRadius: 70, count: 40, size: [0.5, 2.6], seed: 8, facing: -0.3 },+ treeExclusion: (x, z, eye) => Math.hypot(x - eye[0], z - eye[2]) < 70,+ mist: { density: 0.0022, minimum: [-1600, -20, -1800], maximum: [1600, 38, 1200], color: [1, 0.84, 0.8], ambient: [0.02, 0.02, 0.03], anisotropy: 0.55, noiseAmount: 0, steps: 48, maxDistance: 2600 },+ });+}++const TARN = { x: -60, z: -220 };++// Tarn: midday on the shore of a turquoise lake, a forest across the water and snowy massifs behind it, a few boulders at the camera.+function mountainValleyTarn() {+ return lookValleyScene({+ sky: skyGradient({ zenith: [0.08, 0.28, 0.72], horizon: [0.62, 0.78, 0.95], ground: [0.2, 0.22, 0.2], power: 0.5, intensity: 1 }),+ key: [4.8, 4.4, 3.8], sunDirection: [-0.3, 0.8, 0.3],+ height: lookValleyHeight({ ridgeMix: 0.3, rimScale: 0.92, carve: carveDisc([TARN.x, TARN.z], [420, 260], -14) }),+ palette: { ...ALPINE, snowLine: 520, treeLine: 560 },+ water: { level: -1.2, center: [TARN.x, TARN.z], size: [1000, 1000], material: { color: [0.02, 0.17, 0.2], roughness: 0.03 } },+ haze: { color: [0.62, 0.74, 0.9], start: 700, end: 3600, amount: 0.7 },+ eyeGround: [-130, 140], eyeLift: 3.2, target: [60, 260, -1500], fov: 55, forestDensity: 0.0021,+ boulders: { innerRadius: 4, outerRadius: 70, count: 70, size: [0.5, 3.2], seed: 14, facing: 0.1 },+ treeExclusion: (x, z, eye) => Math.hypot(x - eye[0], z - eye[2]) < 30,+ });+}++// Meadow at sunset: a low orange sun from the left throws long tree shadows across wildflower drifts, one massif lit pink.+function mountainValleySunset() {+ return lookValleyScene({+ sky: skyGradient({ zenith: [0.09, 0.14, 0.42], horizon: [1, 0.45, 0.2], ground: [0.22, 0.12, 0.1], power: 0.42, intensity: 0.7 }),+ key: [7.4, 3.5, 1.4], sunDirection: [-0.85, 0.2, -0.15],+ height: lookValleyHeight({ ridgeMix: 0.4, hero: { x: 140, z: -1100, radius: 340, height: 650 }, floorScale: 1.4 }),+ palette: { ...ALPINE, grassLight: [0.2, 0.28, 0.07], flowers: [[0.6, 0.5, 0.05], [0.55, 0.15, 0.25], [0.45, 0.45, 0.5]], snowLine: 470, snow: [0.95, 0.85, 0.82] },+ haze: { color: [0.8, 0.45, 0.35], start: 600, end: 3400, amount: 0.65 },+ eyeGround: [-300, 400], eyeLift: 2.4, target: [100, 330, -1400], fov: 50, forestDensity: 0.0026,+ forestMix: { conifer: 1, birch: 0.2 },+ boulders: { innerRadius: 5, outerRadius: 40, count: 25, size: [0.5, 2], seed: 3, facing: 0.5 },+ treeExclusion: (x, z, eye) => Math.hypot(x - eye[0], z - eye[2]) < 18,+ });+}++// ---------------------------------------------------------------------------------------------------------------------+// Temple hall++const SANDSTONE = { color: [0.74, 0.62, 0.46], roughness: 0.8 };+const SANDSTONE_FLOOR = { color: [0.55, 0.46, 0.34], roughness: 0.55 };+const GOLD = { color: [0.85, 0.62, 0.2], metallic: 0.9, roughness: 0.3 };++function glowPart(name, translation, scale, color, emission) {+ return part(name, HALL_BLOCK, translation, scale, { color, roughness: 1, emission });+}++// A stained glass rose window and three lancets in the far wall, every pane Emission so Cycles lights the nave from them.+function roseWindowParts() {+ const parts = [];+ const [centreY, glassZ] = [21, HALL.back + 0.4];+ const [red, blue, amber, green] = [[0.95, 0.12, 0.08], [0.1, 0.25, 1], [1, 0.62, 0.15], [0.15, 0.8, 0.3]];+ parts.push(turnedPart('rose-frame', UNIT_CYLINDER, [0, centreY, HALL.back + 0.1], [11.4, 0.3, 11.4], STONE, 0, Math.PI / 2));+ parts.push(turnedPart('rose-core', UNIT_CYLINDER, [0, centreY, glassZ], [2.6, 0.2, 2.6], { color: amber, roughness: 1, emission: 7 }, 0, Math.PI / 2));+ for (let petal = 0; petal < 12; petal++) {+ const angle = (petal / 12) * Math.PI * 2;+ parts.push(turnedPart(`rose-petal-${petal}`, UNIT_CYLINDER, [Math.cos(angle) * 5.2, centreY + Math.sin(angle) * 5.2, glassZ], [2.2, 0.2, 2.2], { color: petal % 2 ? blue : red, roughness: 1, emission: 6 }, 0, Math.PI / 2));+ }+ for (let jewel = 0; jewel < 24; jewel++) {+ const angle = ((jewel + 0.5) / 24) * Math.PI * 2;+ parts.push(turnedPart(`rose-jewel-${jewel}`, UNIT_CYLINDER, [Math.cos(angle) * 9, centreY + Math.sin(angle) * 9, glassZ], [0.85, 0.2, 0.85], { color: jewel % 3 === 0 ? green : jewel % 3 === 1 ? amber : red, roughness: 1, emission: 6 }, 0, Math.PI / 2));+ }+ [[-22, amber], [-11, blue], [0, red], [11, blue], [22, amber]].forEach(([x, color], index) => {+ parts.push(part(`lancet-frame-${index}`, HALL_BLOCK, [x, 8, HALL.back + 0.1], [5.4, 15.4, 0.3], STONE));+ parts.push(glowPart(`lancet-${index}`, [x, 8, glassZ], [4.2, 14.2, 0.2], color, 5));+ });+ return parts;+}++function candleParts(spots) {+ return spots.flatMap(([x, z], index) => [+ part(`candle-stand-${index}`, UNIT_CYLINDER, [x, 0.7, z], [0.18, 1.4, 0.18], { color: [0.2, 0.17, 0.1], metallic: 0.8, roughness: 0.4 }),+ part(`candle-flame-${index}`, UNIT_SPHERE, [x, 1.6, z], [0.22, 0.34, 0.22], { color: [1, 0.7, 0.3], roughness: 1, emission: 12 }),+ ]);+}++// Rose window: the nave seen down its axis toward a wall of stained glass, sun shafts through the roof openings, candles along+// the carpet and people for scale.+function templeHallRose() {+ const lighting = constantLighting(0.16);+ const sunDirection = [0.3, 0.82, 0.25];+ const parts = closedNaveParts().filter(({ name }) => name !== 'roof');+ hallRoofParts(parts, STONE);+ parts.push(+ part('wall-left', HALL_BLOCK, [-HALL.halfWidth - 1, HALL.roofHeight / 2, NAVE_MIDDLE], [2, HALL.roofHeight + 1, NAVE_LENGTH], STONE),+ part('wall-far', HALL_BLOCK, [0, HALL.roofHeight / 2, HALL.back - 1], [HALL.halfWidth * 2 + 4, HALL.roofHeight + 1, 2], STONE),+ part('altar-step-low', HALL_BLOCK, [0, 0.35, HALL.back + 8], [30, 0.7, 14], FLOOR_STONE),+ part('altar-step-high', HALL_BLOCK, [0, 1.05, HALL.back + 5], [16, 0.7, 7], STONE),+ part('altar', HALL_BLOCK, [0, 2.2, HALL.back + 5], [6, 1.7, 2.4], GOLD),+ );+ parts.push(...roseWindowParts());+ parts.push(...candleParts(range(30, -100, 13).flatMap(z => [[-3.4, z], [3.4, z]])));+ parts.push(...peopleParts([[-1.5, 24], [1.4, 12, 1], [-1.2, -2, 2], [1.5, -18], [-12, 6, 1], [14, -8, 2], [0.8, -40, 3], [-16, -30, 2]]));+ return {+ parts, blenderWorld: lighting.blenderWorld,+ environment: environment(lighting, { keyColor: [11, 9.6, 7.4], lightDirection: normalized(sunDirection), volumeFog: fogBox(0.012, [-HALL.halfWidth, 0, HALL.back], [HALL.halfWidth, HALL.roofHeight - 1, HALL.front + 2], 190, 0.55) }),+ camera: { eye: [0, 1.8, HALL.front - 3], target: [0, 13, HALL.back], up: [0, 1, 0], fov: 58, near: 0.1, far: 300 },+ shadow: sunShadow(sunDirection, [0, 15, NAVE_MIDDLE], 105, 200),+ };+}++// A seated colossus from boxes and a sphere: plinth, legs, torso, arms, head and a flat crown.+function colossusParts(prefix, x, z, scale, material) {+ const at = (offsetX, y, offsetZ, sizeX, sizeY, sizeZ, name, geometry = HALL_BLOCK) => part(`${prefix}-${name}`, geometry, [x + offsetX * scale, y * scale, z + offsetZ * scale], [sizeX * scale, sizeY * scale, sizeZ * scale], material);+ return [+ at(0, 1.5, 0, 9, 3, 9, 'plinth'),+ at(0, 4.5, 0.6, 7, 3, 7, 'legs'),+ at(0, 9.5, 0, 5.4, 7, 3.4, 'torso'),+ at(-3.2, 8.2, 1.4, 1.4, 1.6, 3.6, 'arm-left'),+ at(3.2, 8.2, 1.4, 1.4, 1.6, 3.6, 'arm-right'),+ at(0, 14.2, 0, 2.8, 3, 2.8, 'head', UNIT_SPHERE),+ at(0, 16.2, 0, 4.2, 1.2, 3.2, 'crown'),+ ];+}++// Open court: the roof is open over the nave, so the hall is lit from above by a high sun and a blue sky, the columns throw+// bars of shadow across a pale floor, and two colossi sit at the far end.+function templeHallCourt() {+ const lighting = constantLighting(0.42);+ const sunDirection = [0.42, 0.78, 0.3];+ const parts = closedNaveParts().filter(({ name }) => name !== 'roof');+ const aisleWidth = HALL.halfWidth - 17;+ for (const side of [-1, 1]) {+ parts.push(part(`roof-aisle-${side}`, HALL_BLOCK, [side * (17 + aisleWidth / 2 + 2), HALL.roofHeight, NAVE_MIDDLE], [aisleWidth + 4, 2, NAVE_LENGTH], SANDSTONE));+ }+ parts.push(+ part('wall-left', HALL_BLOCK, [-HALL.halfWidth - 1, HALL.roofHeight / 2, NAVE_MIDDLE], [2, HALL.roofHeight + 1, NAVE_LENGTH], SANDSTONE),+ part('wall-far', HALL_BLOCK, [0, HALL.roofHeight / 2, HALL.back - 1], [HALL.halfWidth * 2 + 4, HALL.roofHeight + 1, 2], SANDSTONE),+ part('far-door-glow', HALL_BLOCK, [0, 10, HALL.back + 0.2], [9, 20, 0.3], { color: [1, 0.78, 0.45], roughness: 1, emission: 5 }),+ part('far-door-lintel', HALL_BLOCK, [0, 21, HALL.back + 0.5], [12, 2, 1.4], SANDSTONE),+ );+ parts.push(...colossusParts('colossus-left', -22, HALL.back + 9, 0.9, GOLD), ...colossusParts('colossus-right', 22, HALL.back + 9, 0.9, GOLD));+ parts.push(...candleParts(range(30, -100, 13).flatMap(z => [[-3.4, z], [3.4, z]])));+ parts.push(...peopleParts([[-1.5, 30], [1.4, 18, 1], [-1.2, 4, 2], [1.5, -14], [-8, 12, 1], [8, -2, 2], [0.8, -45, 3], [-14, -26, 2], [15, -60, 1]]));+ return {+ parts, blenderWorld: lighting.blenderWorld,+ environment: environment(lighting, { keyColor: [9, 8.2, 6.6], lightDirection: normalized(sunDirection), volumeFog: fogBox(0.006, [-HALL.halfWidth, 0, HALL.back], [HALL.halfWidth, HALL.roofHeight - 1, HALL.front + 2], 190, 0.6) }),+ camera: { eye: [-8, 1.7, HALL.front - 3], target: [4, 11, -110], up: [0, 1, 0], fov: 60, near: 0.1, far: 300 },+ shadow: sunShadow(sunDirection, [0, 15, NAVE_MIDDLE], 105, 200),+ };+}++// ---------------------------------------------------------------------------------------------------------------------+// Megacity++// A facade as a material graph: a grid of window panes in a wall, a share of them lit warm or cool in drifts. Blender builds the+// same nodes. The tile is 36 m, 6 window columns by 10 floors.+function facadeMaterial({ wall, glass, lit, litShare, warm, cool, seed }) {+ const across = { smoothstep: [0.22, 0.34, { wave: { frequency: 6, direction: 'u', shape: 'triangle' } }] };+ const along = { smoothstep: [0.18, 0.3, { wave: { frequency: 10, direction: 'v', shape: 'triangle' } }] };+ const pane = { min: [across, along] };+ const litPane = { mul: [pane, { smoothstep: [1 - litShare, 1 - litShare + 0.02, { voronoi: { scale: 8, seed, output: 'cell' } }] }] };+ const tint = { ramp: { value: { noise: { scale: 4, seed: seed + 5 } }, stops: [[0, warm], [1, cool]] } };+ const graph = { color: { mix: [wall, glass, pane] }, emission: { mix: [[0, 0, 0], tint, litPane] } };+ const pattern = normalizeMaterialPattern({ type: 'graph', graph, size: 36, bump: 0, resolution: 512 });+ const textures = materialPatternTextures(pattern);+ return { color: [1, 1, 1], roughness: 0.4, metallic: 0.2, emission: lit, ...textures, graph: pattern.graph, graphBump: 0 };+}++const WARM = [1, 0.66, 0.3];+const COOL = [0.65, 0.8, 1];++function facadePalette(litShare, lit) {+ return [+ facadeMaterial({ wall: [0.12, 0.13, 0.16], glass: [0.03, 0.05, 0.09], lit, litShare, warm: WARM, cool: COOL, seed: 3 }),+ facadeMaterial({ wall: [0.42, 0.38, 0.32], glass: [0.07, 0.08, 0.1], lit, litShare, warm: WARM, cool: [1, 0.9, 0.7], seed: 8 }),+ facadeMaterial({ wall: [0.3, 0.17, 0.12], glass: [0.06, 0.05, 0.05], lit, litShare, warm: [1, 0.55, 0.22], cool: WARM, seed: 13 }),+ facadeMaterial({ wall: [0.22, 0.26, 0.3], glass: [0.04, 0.07, 0.1], lit, litShare, warm: WARM, cool: COOL, seed: 21 }),+ ];+}++const snapTo = (value, step) => Math.max(step, Math.round(value / step) * step);++// A tower with a podium (lit shopfronts), one to three setbacks, and a crown: flat with plant, stepped, or a spire and beacon.+// Sizes snap to a grid so towers share box projections.+function massedTower(parts, random, x, z, totalHeight, index, materials, shopMaterial) {+ const width = [26, 30, 36, 42][Math.floor(random() * 4)];+ const depth = [26, 30, 36, 42][Math.floor(random() * 4)];+ const facade = materials[Math.floor(random() * materials.length)];+ const podiumHeight = snapTo(10 + random() * 12, 4);+ parts.push(part(`podium-${index}`, UNIT_BOX, [x, podiumHeight / 2, z], [width + 10, podiumHeight, depth + 10], shopMaterial));+ const tiers = totalHeight > 140 ? 2 + Math.floor(random() * 2) : 1;+ let baseY = podiumHeight;+ let tierWidth = width;+ let tierDepth = depth;+ for (let tier = 0; tier < tiers; tier++) {+ const remaining = totalHeight - baseY;+ const tierHeight = snapTo(tier === tiers - 1 ? remaining : remaining * (0.42 + random() * 0.16), 6);+ parts.push(part(`tower-${index}-${tier}`, UNIT_BOX, [x, baseY + tierHeight / 2, z], [tierWidth, tierHeight, tierDepth], facade));+ baseY += tierHeight;+ tierWidth = snapTo(tierWidth * 0.78, 6);+ tierDepth = snapTo(tierDepth * 0.78, 6);+ }+ const crown = random();+ const topWidth = tierWidth / 0.78;+ const topDepth = tierDepth / 0.78;+ if (crown < 0.4) {+ parts.push(part(`plant-${index}`, UNIT_BOX, [x + 2, baseY + 3, z - 2], [topWidth * 0.5, 6, topDepth * 0.4], { color: [0.2, 0.2, 0.22], roughness: 0.6 }));+ } else if (crown < 0.75 && totalHeight > 100) {+ parts.push(part(`crown-${index}`, UNIT_BOX, [x, baseY + 9, z], [topWidth * 0.55, 18, topDepth * 0.55], facade));+ parts.push(part(`crown-glow-${index}`, UNIT_BOX, [x, baseY + 18.4, z], [topWidth * 0.55 + 0.4, 1.2, topDepth * 0.55 + 0.4], { color: [1, 0.85, 0.6], roughness: 1, emission: 6 }));+ } else if (totalHeight > 140) {+ parts.push(part(`spire-${index}`, UNIT_BOX, [x, baseY + 24, z], [1.6, 48, 1.6], { color: [0.2, 0.2, 0.22], roughness: 0.4, metallic: 0.8 }));+ parts.push(part(`beacon-${index}`, UNIT_BOX, [x, baseY + 49, z], [2.4, 2.4, 2.4], { color: [1, 0.15, 0.1], roughness: 1, emission: 12 }));+ }+}++function streetTreeParts(prefix, spots) {+ return spots.flatMap(([x, z], index) => [+ part(`${prefix}-trunk-${index}`, UNIT_CYLINDER, [x, 2, z], [0.3, 4, 0.3], { color: [0.2, 0.14, 0.09], roughness: 0.9 }),+ part(`${prefix}-crown-${index}`, UNIT_SPHERE, [x, 6, z], [2.8, 2.6, 2.8], { color: [0.1, 0.22, 0.07], roughness: 0.9 }),+ ]);+}++function trafficStreak(name, x, z, length, axis, color, emission) {+ const scale = axis === 'z' ? [0.9, 0.4, length] : [length, 0.4, 0.9];+ return part(name, UNIT_BOX, [x, 0.3, z], scale, { color, roughness: 1, emission });+}++function cityTowers(sites, seed, materials, shopMaterial) {+ const random = seededRandom(seed);+ const parts = [];+ sites.forEach(([x, z, height], index) => massedTower(parts, random, x, z, height, index, materials, shopMaterial));+ return parts;+}++// Golden avenue: street level on a broad avenue at sunset. The sun is low behind the camera on the left, so the right-hand towers+// glow gold, the left ones stand in blue shade, and the road is lines of car lights between street trees and lamps.+function megacityGoldenAvenue() {+ const lighting = skyGradient({ zenith: [0.15, 0.3, 0.62], horizon: [1, 0.62, 0.35], ground: [0.2, 0.15, 0.12], power: 0.42, intensity: 0.8 });+ const sunDirection = [-0.7, 0.16, 0.5];+ const materials = facadePalette(0.22, 0.8);+ const shop = facadeMaterial({ wall: [0.3, 0.25, 0.2], glass: [0.08, 0.07, 0.06], lit: 1.4, litShare: 0.6, warm: WARM, cool: [1, 0.85, 0.6], seed: 30 });+ const parts = [+ part('city-ground', UNIT_BOX, [0, -1, -500], [9000, 2, 9000], GROUND),+ part('avenue', UNIT_BOX, [0, 0.05, -500], [60, 0.1, 2600], ROAD),+ part('sidewalk-left', UNIT_BOX, [-38, 0.15, -500], [16, 0.3, 2600], { color: [0.3, 0.29, 0.28], roughness: 0.7 }),+ part('sidewalk-right', UNIT_BOX, [38, 0.15, -500], [16, 0.3, 2600], { color: [0.3, 0.29, 0.28], roughness: 0.7 }),+ ];+ for (const lane of [-18, -9, 9, 18]) {+ parts.push(trafficStreak(`lane-${lane}`, lane, -500, 2500, 'z', lane < 0 ? [1, 0.12, 0.08] : [1, 0.92, 0.75], 2.6));+ }+ parts.push(...lampParts('avenue-lamp', range(260, -1000, 36).flatMap(z => [[-31, z], [31, z]]), { height: 10, emission: 12 }));+ parts.push(...streetTreeParts('avenue-tree', range(240, -1000, 24).flatMap(z => [[-44, z], [44, z]])));+ const sites = gridSites({+ xs: range(70, 70 + 4 * 52, 52).flatMap(x => [x, -x]), zs: range(250, -1250, 44), seed: 52, jitter: 4,+ heightAt: (x, z, random) => snapTo(36 + Math.exp(-(((z + 650) / 420) ** 2)) * 380 * (0.35 + random() * 0.8), 6),+ skip: (x, z) => Math.abs(x) < 62,+ });+ parts.push(...cityTowers(sites.map(([x, z, height]) => [x + Math.sign(x) * 0, z, height]), 53, materials, shop));+ return {+ parts, blenderWorld: lighting.blenderWorld,+ environment: environment(lighting, { keyColor: [7.2, 4.1, 2], lightDirection: normalized(sunDirection) }),+ camera: { eye: [0, 7, 270], target: [0, 70, -700], up: [0, 1, 0], fov: 58, near: 0.5, far: 5000 },+ shadow: sunShadow(sunDirection, [0, 0, -400], 1000, 2500),+ };+}++// Blue hour skyline: an elevated bank above a river, a tall landmark tower in the middle of the skyline, lit windows in drifts+// and a warm band on the horizon. Parkland trees on the near bank.+function megacityBlueHour() {+ const lighting = skyGradient({ zenith: [0.02, 0.07, 0.3], horizon: [0.8, 0.45, 0.35], ground: [0.05, 0.06, 0.1], power: 0.35, intensity: 0.65 });+ const materials = facadePalette(0.5, 1);+ const shop = facadeMaterial({ wall: [0.3, 0.25, 0.2], glass: [0.08, 0.07, 0.06], lit: 1.6, litShare: 0.7, warm: WARM, cool: [1, 0.85, 0.6], seed: 31 });+ const parts = [+ part('far-land', UNIT_BOX, [0, -1.5, -1400], [9000, 2, 2400], GROUND),+ part('river', UNIT_BOX, [0, -1.19, 0], [9000, 1.4, 1500], WATER),+ part('near-bank', UNIT_BOX, [0, 1, 460], [9000, 4, 160], { color: [0.12, 0.16, 0.08], roughness: 0.95 }),+ part('embankment', UNIT_BOX, [0, 0.4, -230], [6000, 1.6, 30], ROAD),+ ];+ parts.push(...lampParts('embankment-lamp', range(-700, 700, 36).map(x => [x, -218]), { height: 9, emission: 14 }));+ parts.push(...streetTreeParts('bank-tree', range(-300, 300, 17).flatMap(x => [[x, 430 + (x % 3) * 9], [x + 8, 470 + (x % 5) * 6]])));+ for (const [index, x] of [-260, 40, 330].entries()) {+ parts.push(part(`bridge-deck-${index}`, UNIT_BOX, [x, 6, -230 + 0], [22, 2.4, 520], { color: [0.12, 0.12, 0.13], roughness: 0.5 }));+ parts.push(part(`bridge-light-${index}`, UNIT_BOX, [x, 7.6, -230], [0.5, 0.5, 520], { color: [1, 0.8, 0.5], roughness: 1, emission: 9 }));+ }+ const sites = gridSites({+ xs: range(-900, 900, 60), zs: range(-300, -1300, 46), seed: 71, jitter: 8,+ heightAt: (x, z, random) => snapTo(34 + downtown(x, z, -820, 420, 380) * 380 * (0.3 + random() * 0.85), 6),+ skip: (x, z) => Math.abs(x - 20) < 28 && Math.abs(z + 800) < 40,+ });+ const landmark = [[20, -800, 560]];+ parts.push(...cityTowers([...sites, ...landmark], 72, materials, shop));+ return {+ parts, blenderWorld: lighting.blenderWorld,+ environment: environment(lighting, { keyColor: [0, 0, 0], lightDirection: normalized([0, 1, 0]) }),+ camera: { eye: [-70, 34, 420], target: [20, 150, -800], up: [0, 1, 0], fov: 50, near: 1, far: 5000 },+ shadow: sunShadow([0, 1, 0], [0, 0, -420], 900, 2500),+ };+}++// Night grid: a high view over avenues of car lights, dense towers with most windows lit, and a few lit signs in cyan and+// magenta on the tower faces.+function megacityNightGrid() {+ const lighting = skyGradient({ zenith: [0.004, 0.008, 0.03], horizon: [0.07, 0.05, 0.1], power: 0.4, intensity: 1 });+ const materials = facadePalette(0.6, 1.2);+ const shop = facadeMaterial({ wall: [0.25, 0.22, 0.2], glass: [0.06, 0.05, 0.05], lit: 1.8, litShare: 0.8, warm: WARM, cool: [1, 0.85, 0.6], seed: 32 });+ const parts = [part('city-ground', UNIT_BOX, [0, -1.5, -400], [9000, 2, 9000], GROUND)];+ for (const x of range(-500, 500, 125)) {+ parts.push(part(`avenue-x-${x}`, UNIT_BOX, [x, 0.05, -350], [26, 0.1, 1700], ROAD));+ parts.push(trafficStreak(`cars-white-${x}`, x - 4, -350, 1700, 'z', [1, 0.9, 0.7], 3));+ parts.push(trafficStreak(`cars-red-${x}`, x + 4, -350, 1700, 'z', [1, 0.12, 0.08], 3));+ }+ for (const z of range(300, -1000, 130)) {+ parts.push(part(`avenue-z-${z}`, UNIT_BOX, [0, 0.06, z], [1300, 0.1, 26], ROAD));+ parts.push(trafficStreak(`cars-z-white-${z}`, 0, z - 4, 1300, 'x', [1, 0.9, 0.7], 3));+ parts.push(trafficStreak(`cars-z-red-${z}`, 0, z + 4, 1300, 'x', [1, 0.12, 0.08], 3));+ }+ const sites = gridSites({+ xs: range(-560, 560, 125).map(value => value + 62), zs: range(240, -1000, 130).map(value => value - 65), jitter: 8, seed: 91,+ heightAt: (x, z, random) => snapTo(40 + downtown(x, z, -380, 420, 520) * 470 * (0.3 + random() * 0.95), 6),+ });+ const blockSites = sites.flatMap(([x, z, height]) => [[x - 24, z - 24, height], [x + 24, z + 24, height * 0.7], [x + 24, z - 24, height * 0.45], [x - 24, z + 24, height * 0.6]]);+ parts.push(...cityTowers(blockSites, 92, materials, shop));+ const signRandom = seededRandom(93);+ sites.forEach(([x, z, height], index) => {+ if (height < 150 || signRandom() < 0.4) return;+ const color = signRandom() < 0.5 ? [0.1, 0.9, 1] : [1, 0.15, 0.7];+ parts.push(part(`sign-${index}`, UNIT_BOX, [x - 24, height * 0.55, z - 24 + 22], [12, 30, 0.8], { color, roughness: 1, emission: 6 }));+ });+ return {+ parts, blenderWorld: lighting.blenderWorld,+ environment: environment(lighting, { keyColor: [0, 0, 0], lightDirection: normalized([0, 1, 0]) }),+ camera: { eye: [300, 470, 760], target: [0, 20, -250], up: [0, 1, 0], fov: 54, near: 1, far: 5000 },+ shadow: sunShadow([0, 1, 0], [0, 0, -400], 900, 2500),+ };+}++// Option ids are `<scene>-<option>`; the command line writes them `<scene>:<option>`.+export const LOOK_OPTIONS = {+ 'mountain-valley-dawn': mountainValleyDawn,+ 'mountain-valley-tarn': mountainValleyTarn,+ 'mountain-valley-sunset': mountainValleySunset,+ 'temple-hall-rose': templeHallRose,+ 'temple-hall-court': templeHallCourt,+ 'megacity-dusk-golden-avenue': megacityGoldenAvenue,+ 'megacity-dusk-blue-hour': megacityBlueHour,+ 'megacity-dusk-night-grid': megacityNightGrid,+};diff --git a/bench/reference/look-sheets.py b/bench/reference/look-sheets.pynew file mode 100644index 00000000..8d5c1e6c--- /dev/null+++ b/bench/reference/look-sheets.py@@ -0,0 +1,42 @@+"""Collects the 67js renders of the named looks into artifacts/look-168/<scene>/<option>.png and one contact sheet per scene.++uv run --no-project --with pillow python -I bench/reference/look-sheets.py artifacts/reference-look artifacts/look-168++Reads <scene>-<option>-gpu.png written by `node bench/reference/run.mjs --option <scene>:<option>`.+"""+import shutil+import sys+from pathlib import Path++from PIL import Image, ImageDraw++SCENES = ["mountain-valley", "temple-hall", "megacity-dusk"]+LABEL_HEIGHT = 22+++def main():+ source, target = Path(sys.argv[1]), Path(sys.argv[2])+ for scene in SCENES:+ renders = sorted(source.glob(f"{scene}-*-gpu.png"))+ if not renders:+ continue+ (target / scene).mkdir(parents=True, exist_ok=True)+ images = []+ for render in renders:+ option = render.name[len(scene) + 1:-len("-gpu.png")]+ shutil.copyfile(render, target / scene / f"{option}.png")+ images.append((option, Image.open(render).convert("RGB")))+ width, height = images[0][1].size+ columns = 2+ rows = (len(images) + columns - 1) // columns+ sheet = Image.new("RGB", (width * columns, (height + LABEL_HEIGHT) * rows), (16, 16, 16))+ draw = ImageDraw.Draw(sheet)+ for index, (option, image) in enumerate(images):+ left, top = (index % columns) * width, (index // columns) * (height + LABEL_HEIGHT)+ draw.text((left + 8, top + 5), f"{scene}:{option}", fill=(235, 235, 235))+ sheet.paste(image, (left, top + LABEL_HEIGHT))+ sheet.save(target / scene / "contact-sheet.png")+ print(f"{scene}: {len(images)} options, sheet {sheet.size}")+++main()diff --git a/bench/reference/run.mjs b/bench/reference/run.mjsindex e113687f..eeb612a1 100644--- a/bench/reference/run.mjs+++ b/bench/reference/run.mjs@@ -24,7 +24,10 @@ const cloth = process.argv.includes('--cloth');// --no-water draws the scenes without the water reflection (src/water-reflection.js), which is otherwise found from the materials; --ssr-water draws them with bench/reference/ssr-water.js instead.// --grand draws the options for the grand scenes (grand-scenes.js, issue #168) and scores them into grand.json.const grand = process.argv.includes('--grand');-const sceneSet = khronos ? 'khronos' : cloth ? 'cloth' : grand ? 'grand' : null;+// --option <scene>:<option>,<scene>:<option> draws named looks (look-options.js, issue #168) with the GPU only, into artifacts/reference-look/<scene>-<option>-gpu.png. No Blender, no score, no baseline.+const optionFlag = process.argv.indexOf('--option');+const lookIds = optionFlag >= 0 ? process.argv[optionFlag + 1].split(',').map(name => name.replace(':', '-')) : null;+const sceneSet = khronos ? 'khronos' : cloth ? 'cloth' : grand ? 'grand' : lookIds ? 'look' : null;const WORK_DIRECTORY = resolve(sceneSet ? `artifacts/reference-${sceneSet}` : 'artifacts/reference');const OUTPUT_DIRECTORY = resolve('bench/reference');const CHROME = process.env.CHROME_PATH ?? 'C:/Program Files/Google/Chrome/Application/chrome.exe';@@ -41,9 +44,9 @@ const BACKEND_ARGUMENTS = {const argumentsGiven = process.argv.slice(2);const scoreOnly = argumentsGiven.includes('--score-only');-const skipBlender = argumentsGiven.includes('--skip-blender');+const skipBlender = argumentsGiven.includes('--skip-blender') || lookIds !== null;// --skip-cpu leaves out the SwiftShader render (very slow for the 9 million triangle scenes) and the scoring, which needs it.-const skipCpuFlag = argumentsGiven.includes('--skip-cpu');+const skipCpuFlag = argumentsGiven.includes('--skip-cpu') || lookIds !== null;const sceneFlag = argumentsGiven.indexOf('--scene');const occlusionFlag = argumentsGiven.indexOf('--ambient-occlusion');const ambientOcclusion = occlusionFlag >= 0 ? Number(argumentsGiven[occlusionFlag + 1]) : 0;@@ -78,7 +81,7 @@ const pathTracerSamples = samplesFlag >= 0 ? Number(argumentsGiven[samplesFlag +const noiseThresholdFlag = argumentsGiven.indexOf('--noise-threshold');const pathTracerNoiseThreshold = noiseThresholdFlag >= 0 ? Number(argumentsGiven[noiseThresholdFlag + 1]) : undefined;// --scene takes one id or several separated by commas.-const sceneIdsGiven = sceneFlag >= 0 ? argumentsGiven[sceneFlag + 1].split(',') : null;+const sceneIdsGiven = lookIds ?? (sceneFlag >= 0 ? argumentsGiven[sceneFlag + 1].split(',') : null);// --bake <id>,<id> alone is a baked-score run: it draws and scores only those scenes, with the GPU, against the Cycles and EEVEE renders// of an earlier run (use --skip-blender), and writes bake.json. With an option that changes the bake (--sky-only, --bake-preset, --probes,// --ambient, --ambient-occlusion, --cascades) the scores go to the work directory and the committed files stay as they are.