Files
shinyobjectz 56ff2a7031 LightBench LB5: diffuse bounces through the BVH, each hit lit by the pixel's own light sampling; an f32 history
--bounce N follows N cosine-chosen rays from each pixel to the nearest triangle (a closest-hit walk of the same BVH,
with a CPU twin checked against every triangle) and lights each hit as a pixel is lit: one light sample in the
sampled modes, every light with --mode all. Triangles carry their albedo in their vec4s' w. --view bounce shows the
bounced light alone. The light history is now rgba32float: past a few hundred frames its 1/n steps vanished in f16
and the mean stopped moving.

Measured on the M5 Pro at 1280x720, the knot scene: the 512- and 1024-frame references agree to RMSE 0.33 (0-255),
and the weighted bounce falls as 1/sqrt(frames) to it, 15.3 / 6.5 / 3.7 / 2.0 / 1.1 at 1 / 4 / 16 / 64 / 256 frames,
its bias going to 0; two bounces 1.1 at 256. A sampled pixel traces at most K + 2N rays at 16 or 256 lights
(4 / 6 / 8 for N = 0 / 1 / 2); the lighting pass takes 3.1 / 6.2 / 9.8 ms at 16 lights and 8.4 / 13.3 / 16.9 ms at
256, where the every-light reference with one bounce traces up to 513 rays and takes 207 ms.
2026-11-21 17:30:27 -08:00

27 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# LightBench's sweeps (docs/lightbench.feature LB4): light counts by mode, then detail by distance and field of view,
# at a fixed resolution, each a headless run of the release build. Prints one line a run; frames go to OUT.
# usage: bench/lightbench/sweep.sh OUT_DIR (build first: cargo build --release -p raea-lightbench)
set -euo pipefail
out="${1:?usage: sweep.sh OUT_DIR}"
mkdir -p "$out"
root="$(cd "$(dirname "$0")/../.." && pwd)"
lb="$root/target/release/lightbench"
[ -x "$lb" ] || { echo "no $lb: cargo build --release -p raea-lightbench" >&2; exit 1; }
run() { "$lb" --t 0 --size 1280x720 "$@" 2>/dev/null | grep -E '^(FRAME|LOD|RAYS|GPU)' || { echo "FAILED: $*" >&2; return 1; }; }
echo "# frame time (the GPU waited for each frame) by light count and mode"
for n in 16 64 256; do
run --lights "$n" --bench 30 --shot "$out/all-$n.png"
for m in uniform weighted; do run --lights "$n" --mode "$m" --k 4 --bench 30 --raw --shot "$out/$m-$n.png"; done
done
echo "# bounces (LB5): rays a pixel and the lighting pass's time, 0 to 2 bounces"
for b in 0 1 2; do run --lights 64 --mode weighted --k 4 --bounce "$b" --bench 30 --shot "$out/bounce-$b.png"; done
echo "# detail: full against adaptive, then the field of view"
run --scene field --detail full --view lod --shot "$out/field-full.png"
for fov in 45 20 8; do run --scene field --fov "$fov" --view lod --shot "$out/field-fov$fov.png"; done
echo "# frame time of the field, full against adaptive"
for d in full adaptive; do run --scene field --detail "$d" --mode weighted --bench 30 --shot "$out/field-time-$d.png"; done