Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Add the transparent-bounces scene and a transparent bounces flag to the Cycles parity harness (#894)

Nguyen Xuan An873df33439c3
diff --git a/bench/cycles-parity/render-cycles.py b/bench/cycles-parity/render-cycles.py
index 5c7f2ce5..d8ca2b72 100644
--- a/bench/cycles-parity/render-cycles.py
+++ b/bench/cycles-parity/render-cycles.py
@@ -51,12 +51,17 @@ def parse_cli_arguments():
raise ValueError("Pass script arguments after '--': <sceneJsonPath> <outputPrefix> [options].")
argument_list = sys.argv[sys.argv.index("--") + 1:]
if len(argument_list) < 2 or argument_list[0].startswith("--") or argument_list[1].startswith("--"):
- raise ValueError("Usage: blender -b --factory-startup --python bench/cycles-parity/render-cycles.py -- <sceneJsonPath> <outputPrefix> [--samples 256] [--bounces 8] [--seed 1] [--width 960] [--height 540] [--filter-type box|gaussian|blackman-harris] [--filter-width 1.0] [--keep-exr] [--part-ids]")
+ raise ValueError("Usage: blender -b --factory-startup --python bench/cycles-parity/render-cycles.py -- <sceneJsonPath> <outputPrefix> [--samples 256] [--bounces 8] [--transparent-bounces 8] [--seed 1] [--width 960] [--height 540] [--filter-type box|gaussian|blackman-harris] [--filter-width 1.0] [--keep-exr] [--part-ids]")
return {
"scene_json_path": os.path.abspath(argument_list[0]),
"output_prefix": os.path.abspath(argument_list[1]),
"samples": int(read_flag_value(argument_list, "--samples", "256")),
"bounces": int(read_flag_value(argument_list, "--bounces", "8")),
+ # Transparent Max Bounces on its own; absent means the same value as --bounces.
+ "transparent_bounces": (
+ int(read_flag_value(argument_list, "--transparent-bounces", "-1"))
+ if "--transparent-bounces" in argument_list else None
+ ),
"seed": int(read_flag_value(argument_list, "--seed", "1")),
"width": int(read_flag_value(argument_list, "--width", "960")),
"height": int(read_flag_value(argument_list, "--height", "540")),
@@ -463,7 +468,8 @@ def configure_cycles_parity(scene, options):
scene.cycles.glossy_bounces = bounces
scene.cycles.transmission_bounces = bounces
scene.cycles.volume_bounces = bounces
- scene.cycles.transparent_max_bounces = bounces
+ transparent_bounces = options["transparent_bounces"]
+ scene.cycles.transparent_max_bounces = bounces if transparent_bounces is None else transparent_bounces
return used_devices
diff --git a/bench/cycles-parity/trace-native.mjs b/bench/cycles-parity/trace-native.mjs
index 265c0095..0322eb74 100644
--- a/bench/cycles-parity/trace-native.mjs
+++ b/bench/cycles-parity/trace-native.mjs
@@ -96,7 +96,7 @@ function parseLightSamplingOption(argumentList) {
function parseTraceArguments(argumentList) {
if (argumentList.length < 2 || argumentList[0].startsWith('--') || argumentList[1].startsWith('--')) {
- throw new RangeError('Usage: node bench/cycles-parity/trace-native.mjs <sceneJsonPath> <outputPrefix> [--kernel legacy|cycles] [--samples 256] [--bounces 8] [--seed 1] [--width 960] [--height 540] [--sampler white|sobol-burley] [--light-sampling auto|tree|uniform] [--filter-type box|gaussian|blackman-harris] [--filter-width 1.0] [--clamp-direct 0] [--clamp-indirect 0] [--firefly-clamp 1e9] [--noise-threshold 0]');
+ throw new RangeError('Usage: node bench/cycles-parity/trace-native.mjs <sceneJsonPath> <outputPrefix> [--kernel legacy|cycles] [--samples 256] [--bounces 8] [--transparent-bounces 8] [--seed 1] [--width 960] [--height 540] [--sampler white|sobol-burley] [--light-sampling auto|tree|uniform] [--filter-type box|gaussian|blackman-harris] [--filter-width 1.0] [--clamp-direct 0] [--clamp-indirect 0] [--firefly-clamp 1e9] [--noise-threshold 0]');
}
return {
sceneJsonPath: resolve(argumentList[0]),
@@ -106,6 +106,10 @@ function parseTraceArguments(argumentList) {
height: parseIntegerOption(argumentList, '--height', 540, 16),
samples: parseIntegerOption(argumentList, '--samples', 256, 1),
bounces: parseIntegerOption(argumentList, '--bounces', 8, 0),
+ // Transparent max bounces on its own; undefined keeps the pack default (the larger of --bounces and 8).
+ transparentBounces: argumentList.includes('--transparent-bounces')
+ ? parseIntegerOption(argumentList, '--transparent-bounces', 8, 0)
+ : undefined,
seed: parseIntegerOption(argumentList, '--seed', 1, 0),
filterType: parseFilterTypeOption(argumentList),
sampler: parseSamplerOption(argumentList),
@@ -199,6 +203,7 @@ async function runCli() {
samplesPerDispatch: traced.samplesPerDispatch ?? null,
longestDispatchSeconds: traced.longestDispatchSeconds ?? null,
bounces: options.bounces,
+ transparentBounces: options.transparentBounces ?? null,
seed: options.seed,
filterType: options.filterType,
sampler: options.sampler,
diff --git a/bench/reference/scenes.js b/bench/reference/scenes.js
index 367789e9..8a2fecd9 100644
--- a/bench/reference/scenes.js
+++ b/bench/reference/scenes.js
@@ -1047,6 +1047,36 @@ export const REFERENCE_SCENES = {
};
},
+ // Issue #894: three blended layers of opacity 0.5 (red, green, blue, nearest first) in front of a lit grey backdrop, seen head on.
+ // The layers cover different parts of the frame, so the left third of the picture sees one layer, the middle third two and the
+ // right third three. The backdrop stops short of the top of the frame, where a uniform sky shows through the layers. The picture
+ // tells how many transparent surfaces a camera path passes at each transparent bounce limit and whether it still reaches the sky.
+ async 'transparent-bounces'() {
+ const lighting = constantLighting(0.3);
+ const cube = box(0, 1);
+ const layer = (name, color, depth, left, width) => part(
+ name,
+ wallQuad(1, 5),
+ [left + width / 2, -2, depth],
+ [width, 1, 1],
+ { color, roughness: 0.6, alphaMode: 'blend', opacity: 0.5 },
+ );
+ const parts = [
+ part('backdrop', cube, [0, 0.2, -2.05], [12, 3.2, 0.1], { color: [0.7, 0.7, 0.7], roughness: 0.9 }),
+ layer('layer-near-red', [0.9, 0.3, 0.25], 2, -3, 6),
+ layer('layer-middle-green', [0.3, 0.85, 0.35], 1, -0.863, 4.863),
+ layer('layer-far-blue', [0.3, 0.4, 0.9], 0, 1.078, 2.922),
+ ];
+ const pointLights = [
+ { position: [1, 2.5, 4.5], color: [1, 0.95, 0.9], intensity: 40, radius: 0.15, castShadow: true },
+ ];
+ return {
+ parts, blenderWorld: lighting.blenderWorld,
+ environment: environment(lighting, { pointLights }),
+ camera: { eye: [0, 0.7, 5], target: [0, 0.7, -2], up: [0, 1, 0], fov: 40, near: 0.05, far: 50 },
+ };
+ },
+
// Issue #623: a 36 m corridor with 24 lamps (16 point, 8 spot) along the ceiling and nothing else lighting it, so most lamps are far from
// any point and a light tree has something to choose. The lamps do not cast shadow maps (the rasterizer's atlas holds 24 tiles); the path tracer and Cycles shadow every light.
async 'many-lights'() {