3D engine that AI agents drive
Expect the Cycles-measured albedo in the anisotropic furnace probes (#894)
Nguyen Xuan An31dc063f0f49
diff --git a/bench/cycles-parity/furnace-albedo.py b/bench/cycles-parity/furnace-albedo.pynew file mode 100644index 00000000..5c34e245--- /dev/null+++ b/bench/cycles-parity/furnace-albedo.py@@ -0,0 +1,93 @@+"""Blender 5.3 Cycles directional albedo of a white metallic Principled BSDF in a white furnace.+Usage: blender -b --factory-startup --python bench/cycles-parity/furnace-albedo.py -- <out.json> <samples> <device>+"""+import sys, os, json, math, tempfile, bpy, numpy as np+from mathutils import Vector++out_path, samples, device = sys.argv[sys.argv.index("--") + 1:][:3]+samples = int(samples)+WO = (0.5, 0.3, 0.8124)+CASES = [+ ("isotropic", 0.0, 0.0, WO),+ ("anisotropic-unrotated", 0.7, 0.0, WO),+ ("anisotropic-rotated", 0.7, 0.2, WO),+ ("anisotropic-unrotated-swapped-azimuth", 0.7, 0.0, (0.3, 0.5, 0.8124)),+]++def build(anisotropy, rotation, wo):+ bpy.ops.wm.read_factory_settings(use_empty=True)+ scene = bpy.context.scene+ scene.render.engine = "CYCLES"+ cycles = scene.cycles+ cycles.samples = samples+ cycles.use_denoising = False+ cycles.max_bounces = 12+ cycles.glossy_bounces = 12+ cycles.sample_clamp_direct = 0+ cycles.sample_clamp_indirect = 0+ if device == "gpu":+ prefs = bpy.context.preferences.addons["cycles"].preferences+ prefs.compute_device_type = "OPTIX"+ prefs.get_devices()+ for entry in prefs.devices:+ entry.use = entry.type == "OPTIX"+ cycles.device = "GPU"+ scene.render.resolution_x = 64+ scene.render.resolution_y = 64+ scene.render.resolution_percentage = 100+ scene.render.filter_size = 0.01+ scene.view_settings.view_transform = "Standard"+ scene.view_settings.look = "None"+ scene.display_settings.display_device = "sRGB"+ world = bpy.data.worlds.new("w")+ world.use_nodes = True+ background = world.node_tree.nodes["Background"]+ background.inputs["Color"].default_value = (1, 1, 1, 1)+ background.inputs["Strength"].default_value = 1.0+ scene.world = world+ bpy.ops.mesh.primitive_plane_add(size=200)+ plane = bpy.context.object+ material = bpy.data.materials.new("m")+ material.use_nodes = True+ nodes = material.node_tree.nodes+ principled = nodes["Principled BSDF"]+ principled.distribution = "MULTI_GGX"+ principled.inputs["Base Color"].default_value = (1, 1, 1, 1)+ principled.inputs["Metallic"].default_value = 1.0+ principled.inputs["Roughness"].default_value = 0.35+ principled.inputs["Anisotropic"].default_value = anisotropy+ principled.inputs["Anisotropic Rotation"].default_value = rotation+ geometry_vector = nodes.new("ShaderNodeCombineXYZ")+ geometry_vector.inputs["X"].default_value = 1.0+ geometry_vector.inputs["Y"].default_value = 0.0+ geometry_vector.inputs["Z"].default_value = 0.0+ material.node_tree.links.new(geometry_vector.outputs["Vector"], principled.inputs["Tangent"])+ plane.data.materials.append(material)+ camera_data = bpy.data.cameras.new("c")+ camera_data.type = "ORTHO"+ camera_data.ortho_scale = 1.0+ camera = bpy.data.objects.new("c", camera_data)+ scene.collection.objects.link(camera)+ direction = Vector(wo).normalized()+ camera.location = direction * 10.0+ camera.rotation_euler = (-direction).to_track_quat("-Z", "Y").to_euler()+ scene.camera = camera+ return scene++results = {}+for name, anisotropy, rotation, wo in CASES:+ scene = build(anisotropy, rotation, wo)+ path = os.path.join(tempfile.gettempdir(), "furnace-%s.exr" % name)+ scene.render.image_settings.file_format = "OPEN_EXR"+ scene.render.filepath = path+ bpy.ops.render.render(write_still=True)+ image = bpy.data.images.load(path)+ pixels = np.array(list(image.pixels), dtype=np.float64).reshape(-1, 4)[:, :3]+ # Orthographic camera on an infinite plane: every pixel sees the same point, so pixel variance is sample noise.+ mean = pixels.mean(axis=0)+ stderr = pixels.std(axis=0, ddof=1) / math.sqrt(len(pixels))+ results[name] = {"wo": list(wo), "anisotropy": anisotropy, "rotation": rotation, "samples": samples,+ "pixelCount": len(pixels), "meanRgb": mean.tolist(), "stderrRgb": stderr.tolist()}+ print("CASE", name, results[name])+with open(out_path, "w") as handle:+ json.dump({"blender": bpy.app.version_string, "cases": results}, handle, indent=2)diff --git a/bench/cycles-parity/test-lobes.mjs b/bench/cycles-parity/test-lobes.mjsindex 571f7e7d..8d017b92 100644--- a/bench/cycles-parity/test-lobes.mjs+++ b/bench/cycles-parity/test-lobes.mjs@@ -162,6 +162,8 @@ export const LOBE_PROBE_CASES = [wo: [0.5, 0.3, 0.8124],frontFace: true,expectWhiteFurnace: true,+ // Blender 5.3 Cycles measures this albedo; Cycles loses energy at anisotropy 0.7 (docs/cycles-parity.md).+ furnaceExpectedAlbedo: 0.9831,expectChiSquare: true,material: {baseColor: [1.0, 1.0, 1.0],@@ -179,6 +181,8 @@ export const LOBE_PROBE_CASES = [wo: [0.5, 0.3, 0.8124],frontFace: true,expectWhiteFurnace: true,+ // Blender 5.3 Cycles measures this albedo; Cycles loses energy at anisotropy 0.7 (docs/cycles-parity.md).+ furnaceExpectedAlbedo: 0.9848,expectChiSquare: true,material: {baseColor: [1.0, 1.0, 1.0],@@ -596,6 +600,7 @@ async function runLobeProbeCase(probeCase, options) {wo: probeCase.wo,frontFace: probeCase.frontFace,expectWhiteFurnace: probeCase.expectWhiteFurnace,+ furnaceExpectedAlbedo: probeCase.furnaceExpectedAlbedo ?? 1.0,expectColorOrder: probeCase.expectColorOrder ?? null,expectChiSquare: probeCase.expectChiSquare,sampleCount,diff --git a/bench/cycles-parity/verify-lobes.py b/bench/cycles-parity/verify-lobes.pyindex eec9594c..966dc2b0 100644--- a/bench/cycles-parity/verify-lobes.py+++ b/bench/cycles-parity/verify-lobes.py@@ -169,7 +169,8 @@ def evaluate_lobe_probe(probe_entry):consistency_pass = bool(rel_eval_diff <= EVAL_CONSISTENCY_TOLERANCE and rel_pdf_diff <= EVAL_CONSISTENCY_TOLERANCE)if probe_entry["expectWhiteFurnace"]:- furnace_pass = bool(all(abs(val - 1.0) <= FURNACE_TOLERANCE for val in furnace_mean))+ expected_albedo = probe_entry.get("furnaceExpectedAlbedo", 1.0)+ furnace_pass = bool(all(abs(val - expected_albedo) <= FURNACE_TOLERANCE for val in furnace_mean))else:bounded = all(0.01 <= val <= 1.0 + FURNACE_TOLERANCE for val in furnace_mean)order = probe_entry.get("expectColorOrder")@@ -195,6 +196,7 @@ def evaluate_lobe_probe(probe_entry):"expectWhiteFurnace": probe_entry["expectWhiteFurnace"],"furnaceMeanRgb": [round(float(val), 6) for val in furnace_mean],"furnaceStdErrRgb": [round(float(val), 6) for val in furnace_stderr],+ "furnaceExpectedAlbedo": probe_entry.get("furnaceExpectedAlbedo", 1.0),"furnaceTolerance": FURNACE_TOLERANCE,"furnacePass": furnace_pass,"maxRelativeEvalMismatch": round(rel_eval_diff, 7) if math.isfinite(rel_eval_diff) else None,diff --git a/docs/cycles-parity.md b/docs/cycles-parity.mdindex 36d48c1e..286b2cc7 100644--- a/docs/cycles-parity.md+++ b/docs/cycles-parity.md@@ -275,8 +275,8 @@ Evaluated across `20` `probeCyclesLobe` cases (`N = 262,144` samples each, `1024| `conductor-ggx-medium` | `glossy_ggx` | `[0.9999, 0.9999, 0.9999]` | `0` / `0` | `0.2616` (`1.039`, dof `512`) | **Pass** || `conductor-ggx-rough-grazing` | `glossy_ggx` | `[1.0002, 1.0002, 1.0002]` | `0` / `0` | `0.0760` (`1.091`, dof `512`) | **Pass** || `conductor-f82-gold-oblique` | `glossy_ggx` | `[0.9973, 0.7723, 0.3310]` | `0` / `0` | `0.5270` (`0.995`, dof `512`) | **Pass** |-| `anisotropic-ggx-unrotated` | `anisotropic_ggx` | `[0.9957, 0.9957, 0.9957]` | `0` / `0` | `0.9291` (`0.905`, dof `466`) | **Pass** |-| `anisotropic-ggx-rotated` | `anisotropic_ggx` | `[0.9972, 0.9972, 0.9972]` | `0` / `0` | `0.6095` (`0.980`, dof `457`) | **Pass** |+| `anisotropic-ggx-unrotated` | `anisotropic_ggx` | `[0.9828, 0.9828, 0.9828]` (expects `0.9831`) | `0` / `0` | `0.9291` (`0.905`, dof `466`) | **Pass** |+| `anisotropic-ggx-rotated` | `anisotropic_ggx` | `[0.9846, 0.9846, 0.9846]` (expects `0.9848`) | `0` / `0` | `0.6095` (`0.980`, dof `457`) | **Pass** || `glass-ggx-frontface-sharp` | `glass_ggx` | `[1.0000, 1.0000, 1.0000]` | `0` / `0` | singular (`—`) | **Pass** || `glass-ggx-frontface-rough` | `glass_ggx` | `[1.0005, 1.0005, 1.0005]` | `0` / `0` | `0.8493` (`0.922`, dof `353`) | **Pass** || `glass-ggx-backface-subcritical` | `glass_ggx` | `[1.0004, 1.0004, 1.0004]` | `0` / `0` | `0.8372` (`0.937`, dof `487`) | **Pass** |@@ -287,6 +287,14 @@ Evaluated across `20` `probeCyclesLobe` cases (`N = 262,144` samples each, `1024| `sheen-over-diffuse-rough` | `sheen` | `[1.0000, 1.0000, 1.0000]` | `0` / `0` | `0.5533` (`0.990`, dof `511`) | **Pass** || `sheen-over-diffuse-grazing` | `sheen` | `[1.0000, 1.0000, 1.0000]` | `0` / `0` | `0.5333` (`0.994`, dof `511`) | **Pass** |+The two `anisotropic-ggx-*` probes (white base color, metallic `1`, roughness `0.35`, anisotropy `0.7`, multiscatter GGX) do not expect `1.0`: Cycles 5.3 itself loses energy for anisotropic GGX (the measured albedo is below 1 at anisotropy `0.7`), so the probes carry `furnaceExpectedAlbedo` (Blender 5.3 Cycles measurement, same `0.01` tolerance). The isotropic probes keep `1.0`. Measured with [`bench/cycles-parity/furnace-albedo.py`](../bench/cycles-parity/furnace-albedo.py): Blender 5.3.0 Cycles on OptiX, an orthographic camera looking down `wo = (0.5, 0.3, 0.8124)` at an infinite plane with a Principled BSDF (base color `1`, metallic `1`, roughness `0.35`, Multiscatter GGX, tangent `+X`), uniform white world of strength `1`, Standard view transform, no denoise, no clamp, `8192` spp, `64 x 64` pixels, so each pixel is the directional albedo (standard error under `0.02 %`).++| Material | Cycles 5.3 albedo | Cook albedo |+| --- | --- | --- |+| isotropic control (anisotropy `0`) | `1.0004` | not probed at this angle; the isotropic probes pass at `1.0` within `0.0004` |+| anisotropic, rotation `0.0` | `0.9831` | `0.9828` |+| anisotropic, rotation `0.2` | `0.9848` | `0.9846` |+| Sphere Furnace Scene (`traceNative`, `512` spp, `bounces = 64`) | Full-Image Mean | Center Mean | Limb Mean | Gate || --- | --- | --- | --- | --- || `furnace-scene-diffuse` | `1.0000` | `1.0000` | `0.9999` | **Pass** |