Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Record the four-polygon parity run and refresh the comparison picture (#896)

Nguyen Xuan Anecc99eb61bbf
diff --git a/docs/cook-depth-of-field-comparison.jpg b/docs/cook-depth-of-field-comparison.jpg
index ba756b75..39acc9d8 100644
Binary files a/docs/cook-depth-of-field-comparison.jpg and b/docs/cook-depth-of-field-comparison.jpg differ
diff --git a/docs/cycles-parity.md b/docs/cycles-parity.md
index a27d2bdc..02fa15fc 100644
--- a/docs/cycles-parity.md
+++ b/docs/cycles-parity.md
@@ -897,13 +897,15 @@ Cycles comparison (`dof-depth` scene in `bench/reference/scenes.js`: objects 2 m
| Aperture, Cook 4096 spp against Cycles 4096 spp | mean ratio (R / G / B) | relMSE (eps 0.01) | Cycles seed 2 against seed 1 | tiles within 5 % |
| --- | --- | ---: | ---: | ---: |
-| disk, focus 6 m | 0.9996 / 0.9996 / 0.9996 | 3.4e-5 | 3.4e-5 | 45 of 45 |
-| hexagon, rotation 15, default focus, with the sign flip of commit `272003cd` | 0.9997 / 0.9997 / 0.9998 | 3.3e-5 | 3.0e-5 | 44 of 44 |
-| pentagon, rotation 40, default focus, with the sign flip of commit `272003cd` | 0.9994 / 0.9994 / 0.9995 | 9.2e-4 | 3.2e-5 | 44 of 44 |
+| disk, focus 6 m | 0.9996 / 0.9996 / 0.9996 | 3.4e-5 | 3.5e-5 | 45 of 45 |
+| triangle, rotation 10 | 0.9996 / 0.9997 / 0.9998 | 2.8e-5 | 2.6e-5 | 44 of 44 |
+| pentagon, rotation 40 | 0.9994 / 0.9995 / 0.9995 | 3.0e-5 | 3.2e-5 | 44 of 44 |
+| hexagon, rotation 15 | 0.9996 / 0.9996 / 0.9996 | 3.6e-5 | 3.0e-5 | 44 of 44 |
+| heptagon, rotation 25 | 0.9995 / 0.9995 / 0.9996 | 3.4e-5 | 3.2e-5 | 44 of 44 |
-Of 64 tiles, 19 (disk) and 20 (hexagon, pentagon) are too dark to count. For the disk and the hexagon the relMSE is at Cycles' own noise floor. A Cook pinhole against the Cycles disk image scores 7.8e-3 (230 times worse), with 35 of 45 tiles within 5 percent and a tile ratio as low as 0.44, so the scene does tell a lens from a pinhole.
+Of 64 tiles, 19 (disk) and 20 (polygons) are too dark to count. Every row is at Cycles' own noise floor (the polygon rows differ from their floor by at most 6e-6, and the lamp-region relMSE, where bokeh shows, is 0.0039 to 0.0047 against 0.0038 to 0.0043 for Cycles seed 2). Odd and even corner counts and four rotations leave no symmetry to hide a wrong offset or sign. A Cook pinhole against the Cycles disk image scores 7.8e-3 (230 times worse), with 35 of 45 tiles within 5 percent and a tile ratio as low as 0.44, so the scene does tell a lens from a pinhole.
-The polygon is where the two renderers disagree, and a hexagon alone could not show how: its 60 degree symmetry lets a sign flip and a half-step offset look the same. The pentagon at 40 degrees separates them. Against Cycles the kernel's polygon sits half a corner step away, not mirrored: on the hexagon, Cook at 45 degrees matched Cycles at 15 (lamp-region relMSE 0.004, Cycles' own seed noise is 0.004) while Cook at 0 or 30 scored 0.029 and at 15 scored 0.055; on the pentagon neither the flipped sign (-40, equal to 32 modulo 72: 0.138) nor 40 (0.164) matched, and both orderings fit a target near 76 degrees, which is 40 plus half the 72 degree step. So `createCamera` adds half a corner step (`180 / blades` degrees) to the rotation, and the sign flip of `272003cd` was wrong for polygons other than a hexagon. That last change was derived from the measurements above and has not been rendered. Pictures: `docs/cook-depth-of-field-comparison.jpg` (rows disk and hexagon with the sign flip; Cook and Cycles at 256 spp, Cook and Cycles at 4096, difference times 4).
+The polygon conventions differ in one place, derived from Cycles' code and not fitted. Cycles' `regular_polygon_sample` (`intern/cycles/kernel/sample/mapping.h`) builds each sector as a triangle whose outer points sit at -pi/n and +pi/n around an axis at `rotation + 2 pi k / n`, so its corners are at `rotation + pi/n + 2 pi k / n`; Blender's `aperture_rotation` reaches `bladesrotation` unchanged in radians (`intern/cycles/blender/camera.cpp`, `camera_sample_aperture` in `kernel/camera/camera.h`). Cook's `cam_sample_regular_polygon` (`camera.wgsl`) puts corners at `rotation + 2 pi k / n`. Same direction and same unit, so `createCamera` adds `180 / blades` degrees (`kernelApertureRotation` in `src/camera.js`). A first fit on the hexagon alone (a sign flip, commit `272003cd`) was wrong, as the pentagon at 40 degrees showed (relMSE 9.2e-4 against a floor of 3.2e-5). Picture: `docs/cook-depth-of-field-comparison.jpg` (rows disk and pentagon; Cook and Cycles at 256 spp, Cook and Cycles at 4096, difference times 4).
Bundle size (`node scripts/measure-size.mjs`, growth against origin/main, gzip bytes): `entry:path-tracer` 29,509 to 29,857 (+348, allowed 590), `entry:path-tracer-progressive` 38,118 to 38,468 (+350), `entry:path-tracer-realtime` 42,565 to 42,906 (+341), `entry:core` 90,098 to 90,103 (+5, allowed 64), `scene:lit-box` unchanged at 58,841. No bundle grew past its allowance, so there is no size note.