Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(render): a bake solves the probes in the light field it already has

esengine24ba37fc5da3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3338d275a..072d0f9a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,24 @@ published separately; it ships inside the editor.
### Added
+- **A bake now solves the probes too, and refuses to light what moves.** One pass
+ over one light field produces both: the atlas the surfaces read, and nine
+ coefficients at every point of each `LightProbeVolume`'s grid. A probe gathers
+ the whole sphere where a lumel gathers a hemisphere, and reads the same atlas a
+ bounce does — so a character standing in a red room is lit red by the walls that
+ are lit.
+
+ What a bake may hold still is the physics components' to say, and nothing else
+ declares it: a `CharacterController3D` exists to walk, and a `RigidBody3D` that
+ is not Static is moved by the solver. Those objects are refused an atlas patch —
+ a bake writes light into a PLACE, and they will not be there — and take the
+ volume's light instead. Bake Lighting and `estella.mjs bake-scene` go through
+ the same rule, so the editor and CI cannot disagree about which objects moved.
+
+ `physics-3d` now carries a volume. It also stopped baking its thirteen moving
+ bodies, its hero among them — a character had been wearing the light of the spot
+ it spawns at.
+
- **Light probes: what lights a thing a bake cannot hold still.** A bake answers
"what light reaches this surface" for geometry that never moves, and nothing
answered it for a character — a figure walking out of a lit room kept the one
@@ -45,6 +63,26 @@ published separately; it ships inside the editor.
### Fixed
+- **A scene's ambient light reaches its bake.** `LightType.Ambient` is the third
+ value of the enum and `Spot` the fourth, and both bake collectors read the third
+ as a spot lamp — so the sky lit nothing it was not standing next to. An ambient
+ light occupies no slot and aims nowhere; it is now the bake's ambient term, the
+ way the renderer already folds it into its own. Outdoors this is most of the
+ indirect light there is: `physics-3d`'s probes go from black to carrying its
+ sky's blue.
+
+- **A bake's products can be carried by a package.** `bake-scene` wrote the atlas
+ and nothing else — no `.meta`, so the cook had no identity to carry it by, and
+ the export said so in a warning nobody reads. The scene named an atlas the
+ package did not hold, and the room shipped unlit. The check now fails on a
+ product with no `.meta` and says which command mints one; the editor's own bake
+ already minted them.
+
+- **A gather reads the lit side of a surface.** Light bounced off the BACK of a
+ wall as readily as off its front, because an atlas is per triangle and has no
+ side. A ray arriving at a face from behind now finds it unlit, which is what
+ keeps a probe standing behind a wall from being lit by what the wall hides.
+
- **A per-draw block reaches the draw that wrote it.** The pose of a skinned
draw, the shapes of a morphed one and (now) the indirect light of a probe-lit
one shared one buffer each, rewritten immediately before the draw that reads
diff --git a/desktop b/desktop
index a4027c7b0..cb3b28b14 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit a4027c7b0ec4f30eb5bb6b446f04af831db35def
+Subproject commit cb3b28b146211ed9add002c1a8ff1127c68977f3
diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.json
index 1fb2df77e..b919cb7ff 100644
--- a/docs/astro/src/data/apiStability.generated.json
+++ b/docs/astro/src/data/apiStability.generated.json
@@ -3,10 +3,10 @@
"counts": {
"public": 114,
"beta": 101,
- "experimental": 1892,
+ "experimental": 1900,
"deprecated": 3
},
- "total": 2107,
+ "total": 2115,
"subsystems": [
{
"id": "ecs",
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index 9177757c5..e1ccfb704 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -2066,6 +2066,13 @@
"doc": "Half the box this volume covers, from the entity's position.",
"range": "≥ 0"
},
+ {
+ "key": "spacing",
+ "type": "number",
+ "default": "100",
+ "doc": "World units between probes the next bake lays down.",
+ "range": "≥ 1"
+ },
{
"key": "enabled",
"type": "boolean",
diff --git a/examples/physics-3d/assets/scenes/main.esscene b/examples/physics-3d/assets/scenes/main.esscene
index 9e0124beb..715dbd5fd 100644
--- a/examples/physics-3d/assets/scenes/main.esscene
+++ b/examples/physics-3d/assets/scenes/main.esscene
@@ -359,18 +359,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.05078125,
- "y": 0.05078125,
- "z": 0.939453125,
- "w": 0.3935546875
- }
- }
}
]
},
@@ -429,18 +417,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.05078125,
- "y": 0.05078125,
- "z": 0.666015625,
- "w": 0.4267578125
- }
- }
}
]
},
@@ -499,18 +475,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.05078125,
- "y": 0.05078125,
- "z": 0.59765625,
- "w": 0.4326171875
- }
- }
}
]
},
@@ -575,8 +539,8 @@
"scaleOffset": {
"x": 0.0712890625,
"y": 0.0712890625,
- "z": 0.8818359375,
- "w": 0.322265625
+ "z": 0.7431640625,
+ "w": 0.21875
}
}
}
@@ -656,18 +620,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.138671875,
- "y": 0.138671875,
- "z": 0.7431640625,
- "w": 0.322265625
- }
- }
}
]
},
@@ -716,18 +668,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.0625,
- "y": 0.0625,
- "z": 0.666015625,
- "w": 0.3642578125
- }
- }
}
]
},
@@ -855,18 +795,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.044921875,
- "y": 0.044921875,
- "z": 0.939453125,
- "w": 0.4443359375
- }
- }
}
]
},
@@ -928,18 +856,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.0419921875,
- "y": 0.0419921875,
- "z": 0.759765625,
- "w": 0.4609375
- }
- }
}
]
},
@@ -994,18 +910,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.0576171875,
- "y": 0.0576171875,
- "z": 0.8818359375,
- "w": 0.3935546875
- }
- }
}
]
},
@@ -1133,8 +1037,8 @@
"scaleOffset": {
"x": 0.033203125,
"y": 0.033203125,
- "z": 0.6484375,
- "w": 0.4775390625
+ "z": 0.7431640625,
+ "w": 0.2900390625
}
}
}
@@ -1209,18 +1113,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.037109375,
- "y": 0.037109375,
- "z": 0.8017578125,
- "w": 0.4609375
- }
- }
}
]
},
@@ -1277,18 +1169,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.04296875,
- "y": 0.04296875,
- "z": 0.8818359375,
- "w": 0.451171875
- }
- }
}
]
},
@@ -1351,18 +1231,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.04296875,
- "y": 0.04296875,
- "z": 0.716796875,
- "w": 0.4609375
- }
- }
}
]
},
@@ -1426,8 +1294,8 @@
"scaleOffset": {
"x": 0.0283203125,
"y": 0.0283203125,
- "z": 0.681640625,
- "w": 0.4775390625
+ "z": 0.96875,
+ "w": 0.169921875
}
}
}
@@ -1494,18 +1362,6 @@
"a": 1
}
}
- },
- {
- "type": "MeshLightmap",
- "data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.0341796875,
- "y": 0.0341796875,
- "z": 0.8388671875,
- "w": 0.4609375
- }
- }
}
]
},
@@ -1569,8 +1425,8 @@
"scaleOffset": {
"x": 0.025390625,
"y": 0.025390625,
- "z": 0.59765625,
- "w": 0.4833984375
+ "z": 0.96875,
+ "w": 0.1982421875
}
}
}
@@ -1648,18 +1504,38 @@
"a": 1
}
}
- },
+ }
+ ]
+ },
+ {
+ "id": 50,
+ "name": "Probes",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
{
- "type": "MeshLightmap",
+ "type": "Transform",
"data": {
- "lightmap": "main_lightmap.png",
- "scaleOffset": {
- "x": 0.068359375,
- "y": 0.068359375,
- "z": 0.59765625,
- "w": 0.3642578125
+ "position": {
+ "x": 0,
+ "y": 140,
+ "z": 0
}
}
+ },
+ {
+ "type": "LightProbeVolume",
+ "data": {
+ "probes": "main_probes_50.esprobes",
+ "halfExtents": {
+ "x": 750,
+ "y": 220,
+ "z": 550
+ },
+ "spacing": 250,
+ "enabled": true
+ }
}
]
}
diff --git a/examples/physics-3d/assets/scenes/main_lightmap.png b/examples/physics-3d/assets/scenes/main_lightmap.png
index ea9cc1820..fff03c2f1 100644
Binary files a/examples/physics-3d/assets/scenes/main_lightmap.png and b/examples/physics-3d/assets/scenes/main_lightmap.png differ
diff --git a/examples/physics-3d/assets/scenes/main_lightmap.png.meta b/examples/physics-3d/assets/scenes/main_lightmap.png.meta
new file mode 100644
index 000000000..eb4a34aad
--- /dev/null
+++ b/examples/physics-3d/assets/scenes/main_lightmap.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "b55cdc1e-9d77-4868-aa6e-e24c4156a10f",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "repeat",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}
diff --git a/examples/physics-3d/assets/scenes/main_probes_50.esprobes b/examples/physics-3d/assets/scenes/main_probes_50.esprobes
new file mode 100644
index 000000000..db44f4b7a
--- /dev/null
+++ b/examples/physics-3d/assets/scenes/main_probes_50.esprobes
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "resolution": [7,3,5],
+ "irradiance": [0.784199,0.942269,1.21392,-0.0142376,-0.0165754,-0.0212008,-0.0245614,-0.028769,-0.0361766,-0.0244906,-0.0283473,-0.0367389,-0.00665394,-0.00767136,-0.00994106,-0.00701993,-0.00822114,-0.0103364,-0.00276686,-0.00336581,-0.00380017,-0.0117273,-0.0136756,-0.0174229,-0.00418741,-0.00477321,-0.0063521,0.754259,0.909105,1.16567,-0.0345292,-0.0391108,-0.0533632,-0.0501601,-0.0571411,-0.0775201,-0.0088015,-0.0102453,-0.0136023,-0.00117761,-0.00132565,-0.00181995,-0.018883,-0.0213939,-0.0291829,-0.00813457,-0.00932471,-0.0125716,-0.00544638,-0.00635937,-0.00841712,0.0000724218,0.0000144798,0.000111941,0.738265,0.891448,1.14096,-0.0415297,-0.0469878,-0.0641821,-0.0613031,-0.0693331,-0.0947412,-0.00666444,-0.00754115,-0.0102996,-0.000164009,-0.000158209,-0.000253467,-0.0219174,-0.0247971,-0.0338723,-0.00980345,-0.0110879,-0.0151508,-0.00276039,-0.00312344,-0.00426606,-0.00145615,-0.00164875,-0.0022504,0.744343,0.89828,1.15104,-0.03519,-0.0398193,-0.0543158,-0.0558161,-0.0631664,-0.0856054,0.000189076,0.000184484,0.000743749,0.00124699,0.00143617,0.0019597,-0.0181382,-0.0205242,-0.0279844,-0.00841612,-0.00953069,-0.0128094,0.00111209,0.00123831,0.00202939,-0.00399545,-0.00452841,-0.00607028,0.742763,0.896543,1.14791,-0.0353461,-0.0399907,-0.0546252,-0.0573173,-0.0648191,-0.0885785,-0.000871625,-0.000992239,-0.00135044,0.0011701,0.00135073,0.00180801,-0.018246,-0.0206427,-0.028198,-0.00887104,-0.0100326,-0.0137096,0.000384958,0.000432524,0.000593141,-0.00423153,-0.00478725,-0.00653856,0.738265,0.891448,1.14096,-0.0416913,-0.0471706,-0.0644319,-0.0603309,-0.068233,-0.0932387,0.000216157,0.000243746,0.00033406,0.000435549,0.000520148,0.000673122,-0.021933,-0.0248148,-0.0338965,-0.00877747,-0.00992704,-0.0135652,0.00134987,0.00152703,0.00208617,-0.00202098,-0.00228781,-0.00312331,0.79544,0.955654,1.22912,-0.00940559,-0.0107506,-0.0145809,-0.0152349,-0.0172778,-0.0235728,0.0183886,0.0213473,0.0286434,0.00559651,0.0064483,0.00868594,-0.00430449,-0.00488046,-0.00665698,-0.000572243,-0.000514363,-0.000830958,0.00848739,0.00965783,0.0131397,-0.00373633,-0.00444115,-0.00586229,0.772995,0.92721,1.19073,0.0156568,0.0187821,0.0243505,-0.0304957,-0.0368945,-0.0501687,-0.0329498,-0.0398915,-0.0543751,0.00939764,0.0112841,0.0146848,0.00606617,0.00727504,0.00945592,-0.00326612,-0.00395759,-0.00544392,-0.0134409,-0.0163278,-0.0227269,-0.00654415,-0.00797784,-0.0112697,0.737739,0.883698,1.13571,0.0502358,0.0603404,0.0781974,-0.0521571,-0.0641002,-0.0840785,-0.0194365,-0.0233208,-0.0345867,0.00868505,0.0104803,0.01388,0.0222874,0.0267773,0.0347541,-0.00208196,-0.00297235,-0.00369737,-0.00446887,-0.00527781,-0.00951411,0.00303563,0.0034651,0.00362123,0.735961,0.881039,1.12779,0.0590688,0.0710825,0.0926497,-0.0481937,-0.0596633,-0.0838551,-0.00854988,-0.00949225,-0.0156736,0.00316073,0.00373754,0.00501625,0.0263225,0.0317281,0.0417299,0.00323935,0.00344181,0.0018006,-0.00115812,-0.00100151,-0.00317411,0.00433423,0.0048066,0.00558303,0.714247,0.855221,1.09368,0.06859,0.0825754,0.108054,-0.0689963,-0.0840343,-0.11344,0.00276033,0.00348374,-0.000307282,0.00000670818,0.0000754151,0.000816506,0.0321691,0.0387326,0.0506588,-0.00281841,-0.0035513,-0.00572177,-0.00238017,-0.00259134,-0.00391107,0.00376683,0.00404903,0.00364189,0.734335,0.878646,1.11513,0.0610943,0.0739989,0.100608,-0.0501035,-0.0623038,-0.0958982,0.0166474,0.0196178,0.0187282,-0.00387643,-0.00444879,-0.00413205,0.0272609,0.0331659,0.0462326,0.00267804,0.00262673,-0.00185161,0.00691217,0.00800603,0.0070264,0.00496906,0.00564523,0.00629537,0.766586,0.916199,1.1574,0.0355324,0.0444834,0.0700594,-0.0271072,-0.0359082,-0.0661516,0.0343287,0.0406591,0.0459899,-0.0115031,-0.0134864,-0.0145026,0.0139961,0.0179476,0.030892,0.00452149,0.00444707,0.000564079,0.0128677,0.0152393,0.0166112,0.00203075,0.00255397,0.00448063,0.807805,0.966265,1.22377,0.00640457,0.00892532,0.0210773,0.00357563,0.00164713,-0.0170758,0.017284,0.0222929,0.0370407,-0.00532931,-0.00680186,-0.0118873,-0.00043037,0.000269435,0.00643293,0.00845229,0.00949207,0.00654081,0.00308294,0.00451171,0.0110695,-0.00497992,-0.00612681,-0.00759717,0.796579,0.955355,1.2261,0.0188647,0.0228383,0.0309956,-0.0111487,-0.013681,-0.0200058,-0.0108242,-0.0134996,-0.0214125,0.00722447,0.0088065,0.0124232,0.0069183,0.00838324,0.0114375,0.00148119,0.00182296,0.00270685,-0.00316506,-0.00400486,-0.00678846,0.00354749,0.00410948,0.00412924,0.781209,0.933057,1.19376,0.03891,0.0484258,0.0654506,-0.0117539,-0.0169952,-0.0282949,-0.011117,-0.0165785,-0.0257551,0.00814059,0.0106279,0.0149025,0.00998522,0.012837,0.0183826,0.00832184,0.00991642,0.0113832,-0.00250387,-0.00431323,-0.00756037,0.0113409,0.0127375,0.0155265,0.767462,0.918146,1.17093,0.0514351,0.0629985,0.0861086,-0.016532,-0.021992,-0.0377673,-0.00382119,-0.00467636,-0.0140137,0.00351939,0.00420428,0.00794936,0.0131131,0.016424,0.024176,0.0109369,0.0127794,0.0145259,-0.0000799089,-0.000162786,-0.0041708,0.0141417,0.0166999,0.0204783,0.771396,0.923642,1.17305,0.050376,0.0615198,0.0881349,-0.0159891,-0.0207714,-0.0394943,0.00643533,0.0066681,0.000172818,-0.00270073,-0.00281661,-0.000176066,0.013557,0.0168586,0.0265791,0.00989844,0.0115653,0.0124726,0.00240895,0.00242648,-0.000584461,0.0164391,0.0196565,0.0249405,0.76076,0.907035,1.15219,0.0563835,0.0711325,0.101368,-0.0203383,-0.0292334,-0.0518636,0.0174632,0.0203628,0.0218053,-0.007993,-0.00908902,-0.00959919,0.0154576,0.0206553,0.0325931,0.0117701,0.013106,0.0130732,0.00634608,0.00703338,0.00716447,0.0146574,0.0178473,0.0244963,0.792702,0.94451,1.19034,0.0263686,0.0359672,0.0665118,-0.00508029,-0.0116303,-0.0334027,0.0159928,0.0198603,0.0232139,-0.00932277,-0.0112423,-0.0126261,0.00507186,0.00849597,0.0202364,0.0079036,0.00826282,0.00853673,0.00362481,0.0049074,0.00611633,0.00635199,0.00837685,0.0157786,0.807851,0.966315,1.22379,0.0067131,0.0102113,0.0290539,0.00233406,0.000733921,-0.0130576,0.01488,0.0193004,0.0327989,-0.00625796,-0.00810349,-0.0144711,-0.00105614,-0.000302662,0.00673953,0.00608864,0.00722108,0.00845138,0.001834,0.00290547,0.00779555,-0.00360499,-0.00402375,-0.00177022,0.756818,0.909566,1.17457,-0.0398756,-0.0471264,-0.0587807,-0.0134871,-0.0159045,-0.0188887,-0.0404375,-0.0475938,-0.058847,-0.0183207,-0.0216288,-0.0267031,-0.00425106,-0.00492478,-0.00598229,0.00198342,0.00245402,0.00294342,-0.00527483,-0.00626629,-0.00733988,0.00117488,0.00149262,0.00220849,0.750162,0.89968,1.16172,-0.031071,-0.0389917,-0.0469475,0.0177649,0.0186769,0.0271083,-0.00512136,-0.0034418,-0.0104419,0.00471313,0.00687444,0.00632632,0.00587031,0.00618493,0.00889823,-0.00420915,-0.00453919,-0.00686184,0.00439858,0.00501944,0.00687251,-0.00670441,-0.00709621,-0.00962245,0.579456,0.70952,0.89488,-0.156838,-0.17811,-0.242633,0.00628009,0.00521146,0.00921227,-0.0208579,-0.022875,-0.0317688,-0.00366041,-0.00384332,-0.00552483,0.00301846,0.00303845,0.00453058,0.00468273,0.00482789,0.00716455,-0.00943599,-0.0103705,-0.0143374,0.0104681,0.0115661,0.0160859,0.556705,0.685291,0.860314,-0.163754,-0.18529,-0.253021,-0.00290044,-0.00363065,-0.00460464,-0.00149607,-0.0016517,-0.00208774,0.000109404,0.000191911,0.000218934,-0.000362332,-0.000453049,-0.000576245,0.00599904,0.00687268,0.0092531,-0.00381695,-0.00412866,-0.00582922,0.00416029,0.00437663,0.00638839,0.548019,0.674761,0.847143,-0.167725,-0.190516,-0.259122,-0.00739549,-0.00878545,-0.0113116,-0.00437296,-0.00675094,-0.00689015,-0.00223183,-0.00312691,-0.00347981,-0.00137237,-0.00171972,-0.00208143,0.00632284,0.00738162,0.00976003,-0.00393683,-0.00489132,-0.00612822,0.0026806,0.00272464,0.00418396,0.564293,0.694816,0.872222,-0.163012,-0.184389,-0.251897,-0.000647106,-0.000677531,-0.000982319,0.0105591,0.0117138,0.0161692,0.00111864,0.00125392,0.00170365,-0.000219864,-0.000243505,-0.000336944,0.00517692,0.00580601,0.00796509,0.0000497696,0.0000335091,0.0000624096,0.00715478,0.00818434,0.0111156,0.735067,0.886074,1.13601,-0.0426551,-0.0497094,-0.0659214,0.00384984,0.00458429,0.00594976,0.0681741,0.0782958,0.10536,0.0240135,0.0278921,0.0371118,0.00243659,0.00289348,0.00376564,0.00721582,0.00843961,0.0111517,-0.00139218,-0.00162909,-0.00215155,-0.0112601,-0.0125901,-0.0174019,0.689005,0.827576,1.06977,0.0253091,0.0299982,0.0367148,-0.0219841,-0.025837,-0.030473,-0.118137,-0.141315,-0.17968,0.0155026,0.0184169,0.0227596,0.00159506,0.00177835,0.00159113,0.010682,0.0129119,0.0171105,-0.00940035,-0.0110806,-0.013241,-0.0336557,-0.0403724,-0.0519206,0.704671,0.835057,1.07982,0.0639723,0.0787988,0.100946,0.0340203,0.0386964,0.046929,-0.0254329,-0.0220496,-0.0380291,0.0185792,0.0213045,0.0288242,-0.0185148,-0.0219933,-0.0275792,0.011089,0.0137907,0.015684,0.00793668,0.00991749,0.0107483,-0.00790899,-0.0117555,-0.0135104,0.639521,0.76157,0.972264,0.146348,0.176683,0.230596,0.0439026,0.0504146,0.0586845,-0.0209996,-0.0253951,-0.04393,0.0148265,0.0181458,0.0255004,-0.0208126,-0.0246462,-0.0302359,0.0236861,0.0290691,0.0366895,-0.000612633,-0.000837605,-0.00515884,0.0233896,0.0260396,0.0318889,0.608601,0.726983,0.919215,0.172032,0.20775,0.274165,0.027132,0.0308657,0.026704,0.00581201,0.00630415,-0.00352678,-0.00117408,-0.000899663,0.00163941,-0.00918514,-0.0105668,-0.00989441,0.0294681,0.0353578,0.0428089,-0.00535005,-0.0067663,-0.0132471,0.0253411,0.0298891,0.0366262,0.680766,0.80332,0.983593,0.114641,0.146818,0.220816,0.0532381,0.0573682,0.0443223,0.0449448,0.0512281,0.0432908,-0.0151866,-0.0172412,-0.0131355,-0.0238193,-0.0259531,-0.0217786,0.015635,0.019451,0.0242179,0.00555879,0.00501545,0.00020741,0.0195749,0.0241786,0.0314057,0.791637,0.933388,1.10524,0.0100088,0.0235932,0.111019,0.0382651,0.0389334,0.0263243,0.0385535,0.0479598,0.0603231,-0.0194996,-0.0232905,-0.02619,-0.0171562,-0.0184372,-0.014595,-0.00523236,-0.0062387,0.00197848,-0.0135169,-0.0141765,-0.0112281,-0.00740195,-0.00719552,0.00710642,0.832447,0.991389,1.2243,-0.0156281,-0.0139204,0.0193378,0.0104725,0.0108226,0.00433424,-0.00605524,-0.00209579,0.0315365,0.00661951,0.00574571,-0.00959056,-0.00369894,-0.00401105,-0.0023597,-0.00403869,-0.00421518,-0.000590428,-0.00223625,-0.00198632,0.000257681,-0.00439418,-0.00539281,-0.00562498,0.777707,0.932328,1.19284,0.0367069,0.0444527,0.0607281,-0.00635955,-0.00836281,-0.0164995,-0.0225506,-0.0277589,-0.0419051,0.0148615,0.0180474,0.0251489,0.00468073,0.00585822,0.00943793,0.00661405,0.00787512,0.00982991,-0.000429273,-0.000926866,-0.00440924,0.00682454,0.00806019,0.00916061,0.75801,0.907335,1.16111,0.0545247,0.066961,0.0890903,0.0179765,0.0204984,0.0209569,-0.0206822,-0.0252076,-0.0395494,0.011754,0.0140535,0.0204486,-0.0111132,-0.0129703,-0.0149124,0.0131412,0.015822,0.0201448,0.00140203,0.00133499,-0.00152726,0.00936203,0.0113393,0.012979,0.774245,0.922986,1.15997,0.0535366,0.0679377,0.10371,0.0237292,0.0258226,0.0165064,0.00489379,0.00434907,-0.0143887,0.00129581,0.00220614,0.0107599,-0.0130477,-0.0145427,-0.0116795,0.0142642,0.0175928,0.0226185,0.00514687,0.00569378,0.00184287,0.020644,0.0242334,0.0289235,0.744603,0.889259,1.1161,0.0795205,0.0981954,0.146978,0.0187648,0.0202168,0.00685522,0.00308343,0.00320685,-0.00874973,-0.000770667,-0.000541343,0.00570633,-0.00985563,-0.0107257,-0.00442851,0.0214318,0.0257354,0.0317745,0.00193204,0.00197316,-0.00112685,0.0249731,0.0299661,0.0408241,0.765929,0.909764,1.12573,0.0538454,0.0720939,0.130694,0.0254219,0.0252826,0.00660351,0.0286347,0.0333314,0.0369937,-0.0163754,-0.0185136,-0.0191672,-0.0154001,-0.0155627,-0.00581817,0.0167572,0.0205833,0.0279289,0.00203534,0.00220456,0.00306382,0.013631,0.0177269,0.0309783,0.815468,0.965139,1.18442,0.00501852,0.0175747,0.0744477,0.0364174,0.0358531,0.0167162,0.0181562,0.0243681,0.0346216,-0.0109871,-0.0144941,-0.019222,-0.0220188,-0.0218843,-0.011639,0.00860509,0.0106241,0.017003,-0.004041,-0.00336585,-0.00152269,-0.00175364,0.000909946,0.0154651,0.823707,0.982631,1.22374,-0.00262265,0.00129797,0.0357387,0.0195615,0.0212149,0.00970947,-0.0020998,0.000797354,0.0227982,0.00228108,0.00109977,-0.0108788,-0.0105052,-0.011464,-0.00587305,0.00301494,0.00421986,0.00914167,-0.0066456,-0.00717245,-0.00296313,-0.000524501,-0.000108323,0.00557557,0.759121,0.912943,1.18209,-0.0387468,-0.0453784,-0.0545031,-0.0000392355,0.0000459978,0.000676434,-0.0385864,-0.0449305,-0.0539448,-0.0173451,-0.0202804,-0.024188,-0.00118356,-0.00128971,-0.00155062,0.00189862,0.00225903,0.00320426,0.000280022,0.000334604,0.000818536,0.000798879,0.00105032,0.00138111,0.754148,0.903881,1.17109,-0.0291065,-0.0365479,-0.0417463,-0.00366749,-0.00454963,-0.00531384,0.00632176,0.00860221,0.00545117,0.01015,0.0127436,0.0138554,-0.00210706,-0.00231623,-0.00282712,-0.00147027,-0.00144391,-0.00251562,-0.00100784,-0.00150627,-0.00166533,-0.00666542,-0.00738159,-0.00975548,0.759903,0.910472,1.17486,-0.0169629,-0.0215613,-0.0266921,-0.0106721,-0.0136992,-0.0178573,-0.0214193,-0.0223652,-0.0318332,-0.00326604,-0.00293254,-0.0046597,-0.00394109,-0.00481396,-0.0062389,-0.00628028,-0.00702046,-0.00946679,-0.00788202,-0.00970426,-0.0120299,-0.0109719,-0.0134035,-0.016695,0.564664,0.686104,0.872997,-0.154964,-0.180723,-0.239515,-0.0173195,-0.0250877,-0.0266913,-0.0360323,-0.03893,-0.0561112,-0.0160046,-0.0177141,-0.0247297,-0.00900357,-0.0124404,-0.013909,-0.00925018,-0.010999,-0.0144412,0.00319489,0.00375951,0.00485017,0.0102366,0.0119638,0.016046,0.553438,0.681029,0.855325,-0.165166,-0.187135,-0.255254,-0.00255531,-0.00412411,-0.00395952,0.00313121,0.00414916,0.00483215,0.000691386,0.000894232,0.00106758,-0.00072079,-0.00100343,-0.00111552,0.001431,0.00123307,0.00221444,0.00305555,0.00382867,0.00472654,0.00612384,0.00677528,0.0094658,0.557238,0.686194,0.861189,-0.163951,-0.185557,-0.253378,0.00294002,0.00302823,0.00454058,0.0122891,0.0142866,0.0189893,0.00135077,0.00159318,0.00208718,0.0000598677,0.0000364867,0.0000921394,0.00285937,0.00321544,0.00441954,0.00161987,0.002041,0.00250523,0.00631282,0.00702102,0.00975702,0.728669,0.878397,1.12613,-0.0443287,-0.0517178,-0.0685079,0.0108845,0.0130259,0.0168216,0.0696847,0.0801085,0.107694,0.0243005,0.0282365,0.0375553,0.00377303,0.00449721,0.00583105,0.00413922,0.00474768,0.00639699,-0.00259844,-0.0030766,-0.00401576,-0.0112306,-0.0125547,-0.0173564,0.680688,0.818363,1.06186,0.022113,0.0257377,0.0290372,0.00911259,0.011433,0.017289,-0.11909,-0.141658,-0.175995,0.0122771,0.0142583,0.0159203,-0.000844339,-0.00114456,-0.00215075,0.0032192,0.00375643,0.00428857,0.0023945,0.00312106,0.00529537,-0.0331474,-0.0395681,-0.0498837,0.760646,0.900888,1.16136,0.0205129,0.0267529,0.0352789,0.0212318,0.0251598,0.0256152,0.0120287,0.0220573,0.0147844,-0.000548861,-0.00128484,0.00107634,-0.00646785,-0.00797874,-0.00830856,0.000655726,0.000822237,-0.000466543,0.00950674,0.0107838,0.0115738,-0.00960974,-0.0141053,-0.0175441,0.783691,0.929514,1.15822,0.0181015,0.0251767,0.0525249,0.0620003,0.0702792,0.064155,0.00457323,0.00215661,-0.0217023,0.00277962,0.00471776,0.013983,-0.0236303,-0.0270575,-0.0251823,-0.00246198,-0.0021609,-0.00554843,0.0137127,0.0153856,0.01475,-0.00160354,-0.00472825,-0.00912181,0.793663,0.937764,1.10984,0.0135792,0.0259939,0.105412,0.094456,0.108291,0.0948853,0.0187092,0.0209947,0.0000580761,-0.008031,-0.00806645,0.00142392,-0.0442926,-0.0507085,-0.0443408,-0.00398788,-0.00415225,-0.00174304,-0.00260534,-0.00315685,-0.00365232,0.001379,0.00230466,0.0119867,0.877272,1.00754,1.15513,-0.0464468,-0.0216271,0.0773539,0.0472538,0.0456855,0.0372932,0.0240753,0.0155172,0.00842059,-0.0102956,-0.00481311,-0.00194327,-0.0165968,-0.0137683,-0.0110093,-0.00458634,-0.00266547,0.00316917,-0.00586261,-0.00744361,-0.00399418,-0.0055778,-0.00274026,0.00899836,0.894485,1.03591,1.18283,-0.0723902,-0.0588954,0.043579,0.0507454,0.0570368,0.0506337,-0.00888375,0.00605988,0.0243291,0.00407405,-0.00284791,-0.00802943,-0.0172349,-0.0192989,-0.017228,-0.0167328,-0.015173,-0.00875482,-0.00419992,-0.00439708,-0.00294079,-0.0156473,-0.0173214,-0.00258329,0.868377,1.0282,1.25039,-0.0318854,-0.030866,0.00663446,0.00784719,0.00954966,0.0067862,-0.0324996,-0.0280815,0.0131178,0.0148732,0.0139925,-0.0034729,-0.00227332,-0.00269459,-0.00196257,-0.0026289,-0.00184432,0.000902002,-0.00384482,-0.0048974,-0.00356837,0.000368704,-0.00131962,-0.00317245,0.767744,0.920679,1.17969,0.0394021,0.0474519,0.0635121,0.00773625,0.00936214,0.0120654,-0.0283639,-0.0349375,-0.0524912,0.0154943,0.0188923,0.0269671,-0.00218871,-0.002682,-0.00356104,0.00285348,0.00367903,0.00676501,0.00493919,0.0058844,0.00709371,0.00559463,0.00632721,0.00542256,0.79096,0.945627,1.19319,0.0188322,0.025384,0.0491345,0.0331222,0.0384266,0.0379806,-0.0124092,-0.0158639,-0.0348611,0.0053555,0.00678712,0.0150093,-0.0184676,-0.0213341,-0.0204947,0.00039291,0.000675935,0.00145006,0.00703535,0.00821286,0.00848828,0.000699819,0.00125744,0.00178122,0.803096,0.955407,1.18603,0.0121391,0.0204999,0.0607864,0.043949,0.0503579,0.0455957,0.00413402,0.00418895,-0.018119,-0.000728054,-0.000301007,0.0115515,-0.0244086,-0.0279005,-0.024824,-0.00243725,-0.00203998,0.0015167,0.0083159,0.00961119,0.00997856,0.00341372,0.00415318,0.00875538,0.799481,0.946947,1.15305,0.013228,0.025926,0.0907462,0.0443374,0.0506992,0.045148,0.0308511,0.0326651,0.0174954,-0.0145053,-0.0145208,-0.00529874,-0.0285754,-0.0326772,-0.0295079,-0.00297784,-0.0015259,0.00567907,0.00436619,0.00495414,0.00662989,0.0036675,0.00546858,0.0184608,0.844528,0.994424,1.19564,-0.0304798,-0.0184181,0.0549125,0.0387451,0.0444511,0.0378,0.0206045,0.0232313,0.0225447,-0.0121852,-0.0130303,-0.0118503,-0.0214022,-0.0244799,-0.0204182,-0.00777075,-0.0060764,0.00301066,-0.00440128,-0.00518065,-0.0042153,-0.0119218,-0.00921166,0.00854556,0.870412,1.02487,1.2358,-0.0496881,-0.0407682,0.0253682,0.0191002,0.0218903,0.0136603,-0.0106615,-0.00705935,0.00522397,0.00758925,0.00526139,-0.00141314,-0.010293,-0.011819,-0.00722223,-0.00822517,-0.00666423,0.00192585,-0.000897502,-0.00131004,-0.00104763,-0.0139383,-0.0115015,0.00575502,0.848519,1.00599,1.23925,-0.0275703,-0.0236254,0.0165705,0.00219567,0.0030639,0.00315818,-0.0141276,-0.00867618,0.0193014,0.0115378,0.00952749,-0.00482808,0.00010335,-0.00010712,-0.0000222003,-0.0019499,-0.00021329,0.00701512,-0.00260247,-0.00320224,-0.00230209,-0.0063577,-0.00717324,-0.00184599,0.75669,0.910026,1.17635,-0.0318456,-0.0369251,-0.0443549,0.0129422,0.015086,0.0183358,-0.04397,-0.0513144,-0.0636645,-0.0153826,-0.0178144,-0.021561,0.00222466,0.00257422,0.00294801,0.00221654,0.00243574,0.00319352,0.00180381,0.00195601,0.00227344,-0.00484155,-0.00576857,-0.00778837,0.708785,0.848455,1.09874,-0.0522876,-0.0647728,-0.0793694,-0.0167403,-0.0194667,-0.0262724,-0.0348278,-0.0404307,-0.0568487,-0.00647381,-0.00701274,-0.0110846,-0.0101897,-0.0119442,-0.0158615,-0.000151413,-0.0000682517,-0.000283832,-0.00905706,-0.0111211,-0.0137164,-0.0132296,-0.0152618,-0.0196483,0.540128,0.647173,0.835861,-0.196896,-0.237022,-0.304269,-0.0168887,-0.0198676,-0.0269746,-0.0394982,-0.04605,-0.0621087,-0.0114279,-0.0132393,-0.0177071,-0.0108565,-0.01279,-0.0168404,0.0203746,0.0245374,0.0315587,0.00650166,0.00740034,0.0106476,0.0170911,0.0204616,0.0268247,0.487875,0.585267,0.753643,-0.224098,-0.269056,-0.346419,0.015215,0.0182481,0.023733,-0.0209803,-0.0240996,-0.0321099,-0.00254961,-0.00290964,-0.00388179,0.00192191,0.00235241,0.00300666,0.0170738,0.0206296,0.0263901,0.00587094,0.0065507,0.008933,0.0134007,0.0159736,0.0206135,0.493244,0.594043,0.762286,-0.223698,-0.267875,-0.345715,0.0138255,0.0150402,0.0213667,-0.00294032,-0.00226936,-0.00454413,0.000588817,0.000954637,0.000909989,0.00193368,0.00202219,0.00298841,0.0156103,0.0190667,0.024125,-0.00074529,-0.0012921,-0.00115181,0.0158909,0.0194457,0.0245587,0.569629,0.698756,0.881325,-0.162416,-0.184446,-0.250926,0.0168615,0.0180627,0.0258033,0.0116184,0.0146095,0.0168459,0.00221449,0.00287827,0.00335696,0.00173892,0.00163441,0.00267237,0.00840974,0.00950065,0.012762,0.000348112,0.000804411,0.000746154,0.00716912,0.00771245,0.0115295,0.73646,0.886731,1.13801,-0.0434538,-0.050767,-0.0671683,0.0133,0.0158831,0.0205943,0.0620076,0.0719623,0.0960029,0.0236922,0.0275802,0.0366255,0.00404401,0.00481113,0.00625218,0.00360322,0.00425548,0.00560522,-0.0040009,-0.00476465,-0.00621566,-0.00848212,-0.00966392,-0.0131789,0.720411,0.866719,1.12627,0.0156282,0.0182032,0.0213357,0.0197844,0.023143,0.0255898,-0.087971,-0.103435,-0.123166,0.00927691,0.010768,0.0123373,-0.00187191,-0.00202706,-0.00105796,0.00644897,0.00742463,0.00776923,0.00746393,0.0087322,0.00955048,-0.024689,-0.0289907,-0.0341442,0.823739,0.972244,1.20482,-0.015495,-0.0122994,0.016186,0.0337796,0.0392156,0.0299986,0.0411179,0.0525955,0.0224002,-0.0143405,-0.0162769,-0.00405681,-0.0110884,-0.0121255,-0.00575574,-0.00720317,-0.00710042,-0.00363769,0.00637049,0.00648785,0.00295794,-0.00284745,-0.00601875,-0.00995277,0.880333,1.03792,1.21572,-0.0667597,-0.0669166,0.0114559,0.0402174,0.0458471,0.032259,0.015913,0.0173071,-0.0107476,-0.00645089,-0.00629264,0.00427706,-0.0138861,-0.0151047,-0.00650203,-0.0152643,-0.0159022,-0.00450969,0.00619024,0.00731414,0.0113254,-0.0170405,-0.019768,-0.0106367,0.926339,1.08462,1.22419,-0.0893191,-0.0893931,0.0154521,0.0207397,0.0271109,0.0332273,0.0197748,0.0198363,0.00810636,-0.00215958,-0.00156589,0.00131988,-0.00658836,-0.00809815,-0.00881415,-0.0186717,-0.0198245,-0.00757094,-0.00708481,-0.00727841,-0.00552076,-0.0115036,-0.0135599,-0.00362029,0.933986,1.09131,1.22945,-0.0993621,-0.0975518,0.0104287,0.011507,0.0201861,0.0324664,0.00906419,0.0107117,0.0110368,-0.00140435,-0.00135437,-0.00106797,0.0000533872,-0.00290234,-0.00629646,-0.0170216,-0.0196221,-0.0104206,-0.0034626,-0.00393145,-0.00542816,-0.0152995,-0.0156395,-0.0027918,0.937258,1.09624,1.24947,-0.0951159,-0.0943554,0.00631485,-0.00241992,0.0048305,0.0149163,-0.020357,-0.0174941,-0.000821169,0.00668122,0.00576101,0.00042048,0.00152051,-0.000584763,-0.00332222,-0.0113546,-0.0136552,-0.00520123,0.00514788,0.00333555,0.00110148,-0.0145161,-0.0152697,0.000143956,0.875522,1.03652,1.26091,-0.0338667,-0.0337311,0.00170319,-0.00939947,-0.00653908,0.00258503,-0.0408918,-0.0384442,0.00417442,0.0169724,0.0168456,-0.000439079,0.00240176,0.00196316,-0.0003827,-0.00396063,-0.00436777,0.000520268,0.00374301,0.00215401,-0.00126771,0.00299096,0.00205068,-0.00118328,0.786877,0.942403,1.19887,0.0256974,0.0317096,0.0484801,0.0142991,0.0172358,0.0222935,-0.0154805,-0.0204864,-0.0413023,0.00959932,0.0122029,0.0213356,-0.00577402,-0.00691188,-0.00865128,0.000235095,0.00070876,0.00452296,0.00596271,0.00721978,0.00950873,0.00570953,0.00630574,0.00424667,0.821947,0.978584,1.22393,-0.0100848,-0.00568959,0.0232035,0.00979673,0.0136381,0.0160453,0.00383371,0.00271012,-0.0169572,-0.00516222,-0.00525948,0.00422443,-0.00258081,-0.00400838,-0.00354597,-0.00479217,-0.00509853,0.000704173,0.009108,0.0105554,0.0123294,-0.00557668,-0.0055159,-0.00313217,0.844005,1.00319,1.22623,-0.0314086,-0.0295023,0.0207972,0.0117052,0.0143322,0.0180173,0.0144704,0.0152097,-0.00564452,-0.00806752,-0.00852652,0.00148663,-0.00599902,-0.00715754,-0.00801522,-0.0128302,-0.0134388,-0.00361115,-0.00509766,-0.00576244,-0.00314235,-0.00958559,-0.0103184,-0.00223772,0.839232,0.995584,1.20578,-0.0280667,-0.02406,0.0400025,0.0286821,0.0350268,0.0473046,0.00949037,0.0116271,0.0032036,-0.00459388,-0.00517348,-0.000782239,-0.0127745,-0.0155622,-0.0212495,-0.0169635,-0.0180734,-0.00761956,-0.0031252,-0.00351466,-0.00117334,-0.00795012,-0.00815758,0.00545,0.858982,1.01372,1.22206,-0.0487644,-0.0425633,0.0248597,0.0110424,0.0185906,0.0365474,0.00992875,0.0112199,0.0151843,-0.00315241,-0.00309755,-0.00472668,-0.00203482,-0.00582131,-0.0148415,-0.015584,-0.0166102,-0.00756867,-0.00695979,-0.00771665,-0.00790849,-0.0165605,-0.0154709,0.00136216,0.861098,1.018,1.22909,-0.0463725,-0.0421464,0.0203114,0.00954059,0.0154845,0.0296284,-0.00936778,-0.00593222,0.0153181,0.0062871,0.00483324,-0.0049859,-0.00167801,-0.00443183,-0.0114129,-0.0144975,-0.0152513,-0.00533917,-0.00309471,-0.00487278,-0.00773113,-0.0131331,-0.0128754,0.000352881,0.838405,0.996296,1.23314,-0.0179201,-0.0141773,0.0227249,0.00353873,0.00659782,0.0165769,-0.0139436,-0.0100115,0.0167429,0.00941132,0.00797565,-0.00584368,0.000113211,-0.0011112,-0.00612795,-0.00580514,-0.00533825,0.00129823,-0.00272184,-0.00428301,-0.00730564,-0.00163328,-0.00175258,0.002727,0.785946,0.943523,1.21541,-0.0104695,-0.0124628,-0.0169436,0.0235611,0.0278547,0.0347018,-0.023857,-0.0285058,-0.0370701,-0.00491798,-0.00587503,-0.00801944,0.0053483,0.0063335,0.0083087,-0.00248536,-0.00281044,-0.00260766,0.0102174,0.0121645,0.0155816,-0.00583963,-0.00699937,-0.00875844,0.73371,0.880762,1.13588,-0.0462048,-0.0553431,-0.0707501,0.067172,0.0802964,0.101831,-0.0131149,-0.0158627,-0.0210687,-0.00219836,-0.002671,-0.00360915,0.0258365,0.0309302,0.0394581,-0.0112908,-0.0134369,-0.0167348,0.0053427,0.00649904,0.00881955,-0.0000604388,-0.0000639413,-0.0000380694,0.720608,0.865193,1.11466,-0.049023,-0.0587818,-0.0755933,0.0735976,0.0880177,0.112938,-0.0075346,-0.00885653,-0.0124368,-0.000328835,-0.000395793,-0.000606835,0.0267937,0.0321288,0.0413083,-0.00917839,-0.0110166,-0.0140498,0.00293448,0.00346693,0.00500317,-0.00488942,-0.00572136,-0.0073363,0.710921,0.853018,1.09852,-0.0509142,-0.0611457,-0.0787159,0.0853832,0.102608,0.1321,-0.00953035,-0.0108101,-0.0145868,-0.000438369,-0.000472302,-0.000659809,0.0284353,0.0341546,0.0439634,-0.0152503,-0.0183781,-0.0235929,0.00403841,0.00453097,0.00615733,-0.00419478,-0.00501035,-0.00652225,0.712036,0.854752,1.10042,-0.0513118,-0.0615381,-0.0793001,0.0849512,0.101592,0.131288,-0.000499036,-0.0005501,-0.000771237,0.000320619,0.000388895,0.000495503,0.0286675,0.0343712,0.0443043,-0.0152876,-0.018181,-0.0236263,-0.00056832,-0.000722255,-0.000878313,-0.00373294,-0.00447824,-0.00576908,0.71613,0.860126,1.10774,-0.0493519,-0.05911,-0.0761908,0.0822787,0.0980798,0.126903,0.0124742,0.0150716,0.0181685,0.00228746,0.00277301,0.00346974,0.028027,0.0335603,0.0432995,-0.0152714,-0.0181393,-0.0238361,-0.00397297,-0.00491752,-0.00593188,-0.00287236,-0.00332002,-0.00398913,0.777929,0.934132,1.20226,-0.0153399,-0.0182305,-0.0237071,0.0280004,0.0330698,0.0432734,0.0298748,0.0354268,0.0461702,0.00781883,0.00929985,0.0120836,0.007765,0.00920409,0.0120005,-0.00201665,-0.00230225,-0.00311664,-0.0125649,-0.014815,-0.0194185,-0.00632249,-0.00750003,-0.00977111,0.815255,0.976191,1.25044,-0.000442714,-0.000131311,0.00313842,0.00785934,0.0107109,0.0161121,0.00202205,0.000434705,-0.00678257,-0.000725944,-0.000568192,0.00160009,-0.000672164,-0.00092169,-0.00228338,-0.00493007,-0.00581628,-0.00567262,0.00105584,0.00216618,0.00507605,0.00139496,0.00109839,-0.000706789,0.843911,1.00439,1.24965,-0.0183687,-0.0183515,0.00558878,-0.0152403,-0.0118985,0.0142102,0.0130239,0.0139848,0.00408916,-0.0034798,-0.003684,-0.000315891,0.00785565,0.00774166,-0.00379478,-0.000352473,-0.00141873,-0.00283869,-0.00677915,-0.00748528,-0.00329615,-0.00480062,-0.00537276,-0.00339563,0.852841,1.01233,1.24641,-0.0264056,-0.0263544,0.00387284,-0.0197419,-0.0156979,0.0194964,0.0114507,0.010327,0.00178917,-0.00143251,-0.00112429,0.000778913,0.0124405,0.0122783,-0.00281562,-0.00197066,-0.00309463,-0.00651318,-0.00572927,-0.00506873,-0.000807209,-0.00269449,-0.00375147,-0.0017072,0.874577,1.03941,1.26327,-0.0325084,-0.0333818,0.00064094,-0.0398334,-0.0405511,0.00217184,0.00274608,0.00327342,0.00105107,0.000406786,0.000480608,0.000648513,0.0164093,0.0168524,-0.000306747,0.00445917,0.00460486,0.0000413202,-0.0020067,-0.00228327,-0.000563725,-0.000667477,-0.000846152,-0.000391871,0.869768,1.03177,1.26212,-0.0313999,-0.0315437,0.000892968,-0.0379374,-0.0357326,0.00316304,-0.00216279,-0.00245905,0.00154517,0.0013098,0.00154246,0.00057937,0.0161707,0.0160648,-0.000475241,0.00559957,0.00459021,-0.000243869,-0.000147916,0.000211862,-0.000649378,-0.00267856,-0.00296836,-0.000571903,0.853795,1.01508,1.25014,-0.0261434,-0.0259843,0.00364318,-0.0240655,-0.0214373,0.0143257,-0.00243453,-0.000620762,0.00961967,0.00227813,0.0021308,-0.000739363,0.013027,0.012749,-0.00239403,0.00222124,0.00131327,-0.00345444,-0.000598897,-0.00180147,-0.00603848,-0.00443581,-0.00491752,-0.00212404,0.838033,0.999997,1.26024,-0.0101768,-0.0100567,0.000936371,-0.0129772,-0.0113075,0.00479285,-0.012537,-0.0111184,0.00413118,0.00519865,0.00520458,0.000132104,0.00496179,0.00484423,-0.000540306,0.00124197,0.000887458,-0.000584475,0.00568812,0.0047965,-0.00231197,0.00116137,0.00072168,-0.00116317,0.820469,0.978945,1.24432,-0.0016855,0.00066462,0.0111177,0.00619637,0.00980119,0.0188103,0.00606272,0.0021273,-0.0111612,-0.00223358,-0.00103753,0.00459664,-0.00211631,-0.00335605,-0.00694526,-0.0051947,-0.00532686,-0.00389688,0.000613983,0.00229206,0.00680323,0.00208786,0.00130318,-0.000098963,0.83757,1.00024,1.25477,-0.0177246,-0.0173569,0.00463927,-0.00395606,-0.00269984,0.00982579,0.0081924,0.00806226,-0.0058976,-0.00377324,-0.00380644,0.00220778,0.00401236,0.0036467,-0.00283273,-0.00550532,-0.00585873,-0.00190116,-0.00132715,-0.00107073,0.00378845,-0.00318142,-0.00330779,-0.000846823,0.839561,1.00076,1.24302,-0.0236914,-0.0228606,0.0104212,-0.00295522,-0.00029805,0.0211843,0.00442387,0.00461433,-0.00471544,-0.00216637,-0.00225843,0.0018644,0.00558478,0.00483929,-0.00686066,-0.00760687,-0.00842428,-0.00576592,-0.000935011,-0.000820289,0.00348115,-0.00645198,-0.0067804,-0.000339207,0.861709,1.02405,1.25505,-0.035159,-0.0351073,0.00597083,-0.0205295,-0.0188644,0.0102107,0.00332966,0.00464806,-0.000127532,-0.000928812,-0.0011581,0.000504224,0.0117868,0.0114727,-0.00397977,-0.00467175,-0.00527835,-0.00294366,-0.00127745,-0.00186381,0.000745779,-0.00597333,-0.00639188,0.000702291,0.852572,1.01568,1.25367,-0.0290686,-0.0289274,0.00813355,-0.0145372,-0.0137047,0.0101402,-0.00339669,-0.00280285,0.00292402,0.00223345,0.00217236,-0.000460369,0.00892498,0.00861999,-0.00488301,-0.00412785,-0.0043686,-0.00165847,-0.000739074,-0.00101328,-0.00133629,-0.00575255,-0.00589985,0.00141387,0.855966,1.02022,1.26351,-0.0307185,-0.0314151,0.000743589,-0.0203397,-0.0206418,0.00119803,-0.0108887,-0.010574,0.00215213,0.00642433,0.00653688,0.0000938885,0.0117135,0.0120067,-0.0000929077,-0.00115087,-0.00105104,0.000622448,0.00304225,0.00294917,-0.000609442,-0.00670686,-0.00711566,-0.000703166,0.847208,1.01177,1.26515,-0.0211259,-0.02171,0.000315514,-0.0144676,-0.0148026,0.000761611,-0.0160918,-0.0165403,0.000206725,0.00846546,0.00876853,0.000495732,0.00773951,0.00795638,-0.0000744562,-0.00175135,-0.00178838,0.000152853,0.00533853,0.00548701,-0.0000580548,-0.0020546,-0.00211383,0.0000091859]
+}
diff --git a/examples/physics-3d/assets/scenes/main_probes_50.esprobes.meta b/examples/physics-3d/assets/scenes/main_probes_50.esprobes.meta
new file mode 100644
index 000000000..ce7c6fe8e
--- /dev/null
+++ b/examples/physics-3d/assets/scenes/main_probes_50.esprobes.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "23105ef9-d948-48f2-808c-266c136c0b46",
+ "version": "2.0",
+ "type": "probeVolume",
+ "importer": {}
+}
diff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjs
index 6b6b33cdf..e1a07a62a 100644
--- a/pipeline/bin/estella.mjs
+++ b/pipeline/bin/estella.mjs
@@ -118,7 +118,11 @@ const HOST_DESKTOP_OS = process.platform === 'darwin' ? 'macos'
const BAKE_IDENTITY_Q = { x: 0, y: 0, z: 0, w: 1 };
const BAKE_ONE = { x: 1, y: 1, z: 1 };
const BAKE_ZERO = { x: 0, y: 0, z: 0 };
-const BAKE_LIGHT_KIND = { 0: 'point', 1: 'directional', 2: 'spot' };
+// LightType's own order. 2 is AMBIENT, which occupies no slot and no direction:
+// it is light from everywhere, and a bake takes it as its ambient term rather
+// than as a fourth kind of lamp.
+const BAKE_LIGHT_KIND = { 0: 'point', 1: 'directional', 3: 'spot' };
+const BAKE_LIGHT_AMBIENT = 2;
const bakeComponent = (entity, type) => entity.components?.find((c) => c.type === type);
const bakeVec = (v, fallback) => ({ ...fallback, ...(v ?? {}) });
@@ -164,26 +168,50 @@ async function bakeScene(baker, sceneFile, check) {
const surfaces = [];
const lights = [];
+ const volumes = [];
+ const ambient = [0, 0, 0];
for (const entity of scene.entities ?? []) {
const tf = bakeComponent(entity, 'Transform')?.data ?? {};
const mesh = bakeComponent(entity, 'MeshRenderer');
const light = bakeComponent(entity, 'Light');
+ const volume = bakeComponent(entity, 'LightProbeVolume');
+ if (volume && volume.data?.enabled !== false) {
+ const p = bakeVec(tf.position, BAKE_ZERO);
+ const h = bakeVec(volume.data?.halfExtents, { x: 100, y: 100, z: 100 });
+ volumes.push({
+ entity: entity.id, label: entity.name ?? String(entity.id),
+ center: [p.x, p.y, p.z], halfExtents: [h.x, h.y, h.z],
+ spacing: volume.data?.spacing ?? 100,
+ });
+ }
if (mesh && mesh.data?.enabled !== false) {
const ref = typeof mesh.data?.mesh === 'string' ? mesh.data.mesh : '';
const builtin = ref.startsWith('builtin:') ? ref : undefined;
const file = builtin ? '' : path.resolve(sceneDir, ref);
if (builtin || (ref && existsSync(file))) {
const c = mesh.data?.color;
+ const body = bakeComponent(entity, 'RigidBody3D');
surfaces.push({
entity: entity.id, label: entity.name ?? String(entity.id),
meshFile: file, builtinRef: builtin, transform: bakeTransformOf(entity),
baseColor: c ? [c.r ?? 1, c.g ?? 1, c.b ?? 1] : undefined,
+ holdsStill: baker.bakeHoldsStill({
+ characterController: !!bakeComponent(entity, 'CharacterController3D'),
+ bodyType: body ? (body.data?.bodyType ?? 2) : undefined,
+ }),
});
}
}
if (light && light.data?.enabled !== false) {
const d = light.data ?? {};
const p = bakeVec(tf.position, BAKE_ZERO);
+ if ((d.type ?? 0) === BAKE_LIGHT_AMBIENT) {
+ const i = d.intensity ?? 1;
+ ambient[0] += (d.color?.r ?? 1) * i;
+ ambient[1] += (d.color?.g ?? 1) * i;
+ ambient[2] += (d.color?.b ?? 1) * i;
+ continue;
+ }
const kind = BAKE_LIGHT_KIND[d.type ?? 0] ?? 'point';
const cos = (deg) => Math.cos(((deg ?? 45) * Math.PI) / 180 / 2);
lights.push({
@@ -197,13 +225,28 @@ async function bakeScene(baker, sceneFile, check) {
}
}
- const result = baker.bakeSceneLightmap({ surfaces, lights });
+ const result = baker.bakeSceneLightmap({
+ surfaces, lights, probeVolumes: volumes, options: { ambient },
+ });
for (const w of result.warnings) console.warn(` ! ${w}`);
const stem = path.basename(sceneFile).replace(/\.esscene$/i, '');
const atlasName = `${stem}_lightmap.png`;
const atlasFile = path.join(sceneDir, atlasName);
+ // One file per volume, named for the entity that holds it: adding a second
+ // volume must not rename the first one's grid.
+ const grids = new Map();
+ result.probes.forEach((doc, i) => {
+ if (!doc) return;
+ grids.set(volumes[i].entity, {
+ name: `${stem}_probes_${volumes[i].entity}.esprobes`,
+ text: `{\n "version": ${doc.version},\n`
+ + ` "resolution": ${JSON.stringify(doc.resolution)},\n`
+ + ` "irradiance": ${JSON.stringify(doc.irradiance)}\n}\n`,
+ });
+ });
+
const placed = new Map();
result.scaleOffset.forEach((rect, i) => { if (rect) placed.set(surfaces[i].entity, rect); });
for (const entity of scene.entities ?? []) {
@@ -218,26 +261,57 @@ async function bakeScene(baker, sceneFile, check) {
if (at >= 0) entity.components[at] = { type: 'MeshLightmap', data };
else entity.components.push({ type: 'MeshLightmap', data });
}
+ for (const entity of scene.entities ?? []) {
+ const at = entity.components.findIndex((c) => c.type === 'LightProbeVolume');
+ if (at < 0) continue;
+ // A refused volume loses its ref rather than keeping the last grid: a box
+ // the author has since resized is not described by what fitted the old one.
+ const grid = grids.get(entity.id);
+ entity.components[at] = {
+ type: 'LightProbeVolume',
+ data: { ...entity.components[at].data, probes: grid ? grid.name : '' },
+ };
+ }
const document = `${JSON.stringify(scene, null, 2)}\n`;
+ // A product with no `.meta` has no identity, so the cook carries neither it nor
+ // the light in it. Checked here rather than written: a uuid is the stable name
+ // refs resolve through, and minting one is the importer's to do.
+ const products = [atlasFile, ...[...grids.values()].map((g) => path.join(sceneDir, g.name))];
+ const unnamed = products.filter((f) => existsSync(f) && !existsSync(`${f}.meta`));
+ if (check && unnamed.length > 0) {
+ for (const f of unnamed) console.error(`bake-scene: ${path.relative(REPO, f)} has no .meta`);
+ console.error('A package carries what has an identity. Give them one:'
+ + ` node tools/asset-meta.js ${path.relative(REPO, sceneDir)}`);
+ return 1;
+ }
+
if (check) {
const staleAtlas = !existsSync(atlasFile)
|| Buffer.compare(readFileSync(atlasFile), Buffer.from(result.atlasBytes)) !== 0;
const staleScene = readFileSync(sceneFile, 'utf8') !== document;
- if (staleAtlas || staleScene) {
- const what = [staleAtlas && 'the atlas', staleScene && 'the scene'].filter(Boolean).join(' and ');
+ const staleGrids = [...grids.values()].some((g) => {
+ const file = path.join(sceneDir, g.name);
+ return !existsSync(file) || readFileSync(file, 'utf8') !== g.text;
+ });
+ if (staleAtlas || staleScene || staleGrids) {
+ const what = [staleAtlas && 'the atlas', staleScene && 'the scene',
+ staleGrids && 'a probe grid'].filter(Boolean).join(' and ');
console.error(`bake-scene: ${rel} is not what a bake of it produces (${what} differ).`);
console.error(`Rebake: node pipeline/bin/estella.mjs bake-scene ${rel}`);
return 1;
}
console.log(`bake-scene: ${rel} matches a fresh bake`
- + ` (${result.lumels} lumel(s) over ${placed.size} object(s)).`);
+ + ` (${result.lumels} lumel(s) over ${placed.size} object(s)`
+ + `${grids.size ? `, ${grids.size} probe grid(s)` : ''}).`);
return 0;
}
writeFileSync(atlasFile, result.atlasBytes);
+ for (const g of grids.values()) writeFileSync(path.join(sceneDir, g.name), g.text);
writeFileSync(sceneFile, document);
console.log(`bake-scene: ${result.lumels} lumel(s) over ${placed.size} object(s)`
+ + `${grids.size ? `, ${grids.size} probe grid(s)` : ''}`
+ ` -> ${path.relative(REPO, atlasFile)}`);
return 0;
}
diff --git a/pipeline/src/assets/environmentImport.ts b/pipeline/src/assets/environmentImport.ts
index e7b524679..d78038a64 100644
--- a/pipeline/src/assets/environmentImport.ts
+++ b/pipeline/src/assets/environmentImport.ts
@@ -11,6 +11,7 @@
* at all — and the specular half one ordinary RGBA8 image, so nothing
* downstream learns a cube map or a float format.
*/
+import { shBasis, convolveCosine, evalIrradianceSH } from 'esengine';
import { encodeRgbaPng } from './png';
/** A panorama in linear light: equirectangular, row 0 = up (+Y). */
@@ -220,30 +221,10 @@ export function octEncode(dx: number, dy: number, dz: number): [number, number]
// Diffuse: nine coefficients
// =============================================================================
-const SH_BASIS_SCALE = [
- 0.282095,
- 0.488603, 0.488603, 0.488603,
- 1.092548, 1.092548, 0.315392, 1.092548, 0.546274,
-];
-
-/** The nine real SH basis functions at `d`, in the usual l/m order. */
-export function shBasis(dx: number, dy: number, dz: number, out: Float32Array): void {
- out[0] = SH_BASIS_SCALE[0]!;
- out[1] = SH_BASIS_SCALE[1]! * dy;
- out[2] = SH_BASIS_SCALE[2]! * dz;
- out[3] = SH_BASIS_SCALE[3]! * dx;
- out[4] = SH_BASIS_SCALE[4]! * dx * dy;
- out[5] = SH_BASIS_SCALE[5]! * dy * dz;
- out[6] = SH_BASIS_SCALE[6]! * (3 * dz * dz - 1);
- out[7] = SH_BASIS_SCALE[7]! * dx * dz;
- out[8] = SH_BASIS_SCALE[8]! * (dx * dx - dy * dy);
-}
-
/**
* Project the panorama onto nine RGB coefficients, convolved with the clamped
- * cosine lobe and divided by π. That division is what makes a constant
- * environment come back as itself — a uniform radiance c integrates to πc — so
- * these land where the flat ambient term already sits.
+ * cosine lobe and divided by π — the same nine a probe solve produces, through
+ * the same basis, because one expression in the shader reads them both.
*/
export function projectIrradianceSH(env: Panorama): Float32Array {
const coefficients = new Float32Array(27);
@@ -268,26 +249,11 @@ export function projectIrradianceSH(env: Panorama): Float32Array {
}
}
- // Ramamoorthi & Hanrahan's cosine-lobe convolution, over π.
- const band = [1.0, 2 / 3, 2 / 3, 2 / 3, 0.25, 0.25, 0.25, 0.25, 0.25];
- for (let i = 0; i < 9; i++) {
- for (let c = 0; c < 3; c++) coefficients[i * 3 + c] *= band[i]!;
- }
+ convolveCosine(coefficients);
return coefficients;
}
-/** Evaluate {@link projectIrradianceSH}'s output at `d` — the shader's own
- * reconstruction, in TypeScript, so a test can state what a pixel should be. */
-export function evalIrradianceSH(coefficients: ArrayLike<number>,
- dx: number, dy: number, dz: number): [number, number, number] {
- const basis = new Float32Array(9);
- shBasis(dx, dy, dz, basis);
- const out: [number, number, number] = [0, 0, 0];
- for (let i = 0; i < 9; i++) {
- for (let c = 0; c < 3; c++) out[c] += coefficients[i * 3 + c]! * basis[i]!;
- }
- return out;
-}
+export { shBasis, evalIrradianceSH };
// =============================================================================
// Specular: one prefiltered octahedral atlas
diff --git a/pipeline/src/assets/lightmapBake.ts b/pipeline/src/assets/lightmapBake.ts
index 7f2a27639..8232b02f0 100644
--- a/pipeline/src/assets/lightmapBake.ts
+++ b/pipeline/src/assets/lightmapBake.ts
@@ -11,9 +11,14 @@
import { readFileSync } from 'node:fs';
import { PNG } from 'pngjs';
import { bakeLightmap, decodeMesh, unwrapLightmapUV, builtinMeshTemplate, MeshChannel,
- type MeshData, type BakeSurface, type BakeLight, type BakeOptions } from 'esengine';
+ type MeshData, type BakeSurface, type BakeLight, type BakeOptions,
+ type ProbeGrid } from 'esengine';
import { encodeRgbaPng } from './png';
+// The rule a collector needs before it can fill in `holdsStill`, re-exported so
+// the CLI reaches it through the one module it loads.
+export { bakeHoldsStill, type BakeMobility } from 'esengine';
+
/** One placed object, as the editor's world describes it. */
export interface SceneBakeSurface {
/** Absolute path of the `.esmesh` this object draws, or '' when
@@ -35,14 +40,57 @@ export interface SceneBakeSurface {
* albedo. A bounce off a red wall has to arrive red, and the colour is in
* the texture as often as it is in the factor. */
baseColorTexture?: string;
+ /** False where the simulation moves this object — see `bakeHoldsStill`. It
+ * takes a probe volume's light instead of an atlas patch, because a bake
+ * writes light into a place and this one will not be there. Absent = yes. */
+ holdsStill?: boolean;
+}
+
+/** One box of probes to solve, as the editor's world describes it. */
+export interface SceneProbeVolume {
+ /** How it is named where a warning has to be readable. */
+ label: string;
+ /** The entity's world position; the box is axis-aligned around it. */
+ center: [number, number, number];
+ halfExtents: [number, number, number];
+ /** World units between probes the author asked for. */
+ spacing: number;
+}
+
+/** A solved grid, as an `.esprobes` document. */
+export interface ProbeVolumeDocument {
+ version: number;
+ resolution: [number, number, number];
+ irradiance: number[];
}
export interface SceneBakeInput {
surfaces: SceneBakeSurface[];
lights: BakeLight[];
+ probeVolumes?: SceneProbeVolume[];
options?: BakeOptions;
}
+/**
+ * Probes one volume may carry. A grid is written as text, and past this a volume
+ * is megabytes of it. The answer is a coarser spacing or a smaller box, and only
+ * the author can choose between them — so one that does not fit is REFUSED and
+ * named, not quietly thinned.
+ */
+export const MAX_PROBES_PER_VOLUME = 4096;
+
+/**
+ * Probes along one axis, for a half-extent and a spacing.
+ *
+ * Probes sit on the CORNERS (see `probeAt`), so a span of exactly one spacing is
+ * two probes, and a box thinner than half a spacing is one — a constant along
+ * that axis, which is what a flat volume means.
+ */
+export function probeCountFor(half: number, spacing: number): number {
+ if (!(half > 0) || !(spacing > 0)) return 1;
+ return Math.max(1, Math.round((2 * half) / spacing) + 1);
+}
+
export interface SceneBakeResult {
atlasBytes: Uint8Array;
/** Atlas rectangle per surface, in the order they were given — `null` for one
@@ -51,9 +99,16 @@ export interface SceneBakeResult {
/** Texels the bake actually solved. Zero means nothing was lit. */
lumels: number;
size: number;
+ /** The `.esprobes` document per requested volume, in order — `null` for one
+ * that was refused, so a caller can line results up with what it sent. */
+ probes: Array<ProbeVolumeDocument | null>;
warnings: string[];
}
+/** Six significant figures: a grid is hundreds of numbers, and the digits past
+ * these say nothing a bake of it would reproduce anyway. */
+const round6 = (v: number): number => Number(v.toPrecision(6));
+
/** Stock geometry with a lightmap UV set, unwrapped once per bake. */
function builtinGeometry(ref: string, cache: Map<string, MeshData | null>): MeshData | null {
if (!cache.has(ref)) {
@@ -126,6 +181,7 @@ export function bakeSceneLightmap(input: SceneBakeInput): SceneBakeResult {
const warnings: string[] = [];
const surfaces: BakeSurface[] = [];
const slot: number[] = [];
+ let moving = 0;
// One decode per texture however many objects share it: a bake reads these
// once and a scene reuses the same few across most of its surfaces.
const averages = new Map<string, [number, number, number] | null>();
@@ -148,6 +204,10 @@ export function bakeSceneLightmap(input: SceneBakeInput): SceneBakeResult {
warnings.push(`${s.label}: "${s.builtinRef}" is not stock geometry this build has`);
continue;
}
+ if (s.holdsStill === false) {
+ moving++;
+ continue;
+ }
if (!mesh.channels.some((c) => c.semantic === MeshChannel.TexCoord1)) {
warnings.push(`${s.label}: no second UV set, so it receives no baked light —`
+ ' turn on Generate Lightmap UVs in its model\'s import settings and reimport');
@@ -157,25 +217,68 @@ export function bakeSceneLightmap(input: SceneBakeInput): SceneBakeResult {
surfaces.push({ mesh, transform: s.transform, albedo: albedoOf(s, averages, warnings) });
}
+ // The volumes, turned from what an author asked for into the grids a solve
+ // takes. Refused ones keep their place, so a caller lines results up by index.
+ const requested = input.probeVolumes ?? [];
+ const grids: ProbeGrid[] = [];
+ const gridSlot: number[] = [];
+ for (let i = 0; i < requested.length; i++) {
+ const v = requested[i];
+ const counts = v.halfExtents.map((h) => probeCountFor(h, v.spacing)) as
+ [number, number, number];
+ const total = counts[0] * counts[1] * counts[2];
+ if (total > MAX_PROBES_PER_VOLUME) {
+ warnings.push(`${v.label}: ${counts.join('x')} probes is past the ${MAX_PROBES_PER_VOLUME}`
+ + ' one volume may carry — raise its spacing or shrink its box');
+ continue;
+ }
+ gridSlot.push(i);
+ grids.push({
+ min: [v.center[0] - v.halfExtents[0], v.center[1] - v.halfExtents[1],
+ v.center[2] - v.halfExtents[2]],
+ max: [v.center[0] + v.halfExtents[0], v.center[1] + v.halfExtents[1],
+ v.center[2] + v.halfExtents[2]],
+ resolution: counts,
+ });
+ }
+ if (moving > 0 && grids.length === 0) {
+ warnings.push(`${moving} object(s) move, and no probe volume lights them — they take`
+ + ' only real-time light. Add a LightProbeVolume covering where they go.');
+ }
+ const probes: Array<ProbeVolumeDocument | null> = requested.map(() => null);
+ const asDocument = (grid: ProbeGrid, sh: Float32Array): ProbeVolumeDocument => ({
+ version: 1,
+ resolution: [grid.resolution[0], grid.resolution[1], grid.resolution[2]],
+ irradiance: Array.from(sh, round6),
+ });
+
if (surfaces.length === 0) {
warnings.push('nothing in this scene can receive baked light');
+ // The volumes are still solved: a scene whose only light is ambient has
+ // nothing to bake into an atlas and still has somewhere to stand.
+ const empty = bakeLightmap([], input.lights,
+ { ...input.options, probeGrids: grids });
+ gridSlot.forEach((at, k) => { probes[at] = asDocument(grids[k], empty.probes[k]); });
return {
atlasBytes: encodeRgbaPng(1, 1, new Uint8Array([0, 0, 0, 255])),
scaleOffset: input.surfaces.map(() => null),
- lumels: 0, size: 1, warnings,
+ lumels: 0, size: 1, probes, warnings,
};
}
- const result = bakeLightmap(surfaces, input.lights, input.options);
+ const result = bakeLightmap(surfaces, input.lights,
+ { ...input.options, probeGrids: grids });
const scaleOffset: Array<[number, number, number, number] | null> =
input.surfaces.map(() => null);
slot.forEach((at, k) => { scaleOffset[at] = result.scaleOffset[k]; });
+ gridSlot.forEach((at, k) => { probes[at] = asDocument(grids[k], result.probes[k]); });
return {
atlasBytes: encodeRgbaPng(result.size, result.size, result.pixels),
scaleOffset,
lumels: result.lumels,
size: result.size,
+ probes,
warnings,
};
}
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 2715dd9b6..248c4b00e 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,11 +1,11 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 94 beta · 1731 experimental · 3 deprecated
+Symbols: 114 public · 94 beta · 1739 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"cccf3c7425936b84"
+"bfed6926d0e50843"
```
## ANCHOR_AXES — const @experimental
@@ -1344,12 +1344,20 @@ position: readonly [number, number, number] | undefined
radius: number | undefined
```
+## BakeMobility — interface @experimental
+```
+bodyType: BodyType | undefined
+characterController: boolean | undefined
+```
+
## BakeOptions — interface @experimental
```
ambient: readonly [number, number, number] | undefined
atlasSize: number | undefined
bounces: number | undefined
dilate: number | undefined
+probeGrids: readonly ProbeGrid[] | undefined
+probeSamples: number | undefined
samples: number | undefined
texelsPerUnit: number | undefined
```
@@ -1358,6 +1366,7 @@ texelsPerUnit: number | undefined
```
lumels: number
pixels: Uint8Array<ArrayBufferLike>
+probes: Float32Array<ArrayBufferLike>[]
scaleOffset: [number, number, number, number][]
size: number
```
@@ -4601,6 +4610,7 @@ BuiltinComponentDef<LightProbeVolumeData>
enabled: boolean
halfExtents: Vec3
probes: number
+spacing: number
```
## LightStatus — interface @experimental
@@ -6786,6 +6796,13 @@ query: (view: InterestProviderQueryView) => ReadonlySet<Entity> | "all"
ResourceDef<CameraViewAPI>
```
+## ProbeGrid — interface @experimental
+```
+max: readonly [number, number, number]
+min: readonly [number, number, number]
+resolution: readonly [number, number, number]
+```
+
## ProbedRegistrations — interface @experimental
```
fingerprint: string
@@ -7490,6 +7507,16 @@ ComponentDef<{}>
-1
```
+## SH_BASIS_SCALE — const @experimental
+```
+readonly [0.282095, 0.488603, 0.488603, 0.488603, 1.092548, 1.092548, 0.315392, 1.092548, 0.546274]
+```
+
+## SH_COSINE_BAND — const @experimental
+```
+readonly [1, number, number, number, 0.25, 0.25, 0.25, 0.25, 0.25]
+```
+
## SIDE_MODULES — const @experimental
```
Record<BuiltinSideModuleId, SideModuleDescriptor>
@@ -11014,6 +11041,11 @@ AudioPlugin
(world: Pick<World, "tryGet">, avatar: AnimatorAvatar | null): JointResolver
```
+## bakeHoldsStill — function @experimental
+```
+(mobility: BakeMobility): boolean
+```
+
## bakeLightmap — function @experimental
```
(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): BakeResult
@@ -11404,6 +11436,11 @@ BtPlugin
(name: string, pages: string[], current?: string): ControllerState
```
+## convolveCosine — function @experimental
+```
+(coefficients: Float32Array, at?: number): void
+```
+
## corePlugin — const @experimental
```
Plugin
@@ -11884,6 +11921,11 @@ DragPlugin
(bb: Blackboard, guards: BlackboardGuard | BlackboardGuard[]): boolean
```
+## evalIrradianceSH — function @experimental
+```
+(coefficients: ArrayLike<number>, dx: number, dy: number, dz: number, at?: number): [number, number, number]
+```
+
## evaluateAnimatorPath — function @experimental
```
(def: AnimatorScope, currentPath: string, params: AnimatorParamValues, triggers: ReadonlySet<string>, clipFinished?: boolean): AnimatorPathEvalResult
@@ -13709,6 +13751,11 @@ ServicesPlugin
(handler: WasmErrorHandler | null): void
```
+## shBasis — function @experimental
+```
+(dx: number, dy: number, dz: number, out: Float32Array): void
+```
+
## shakeCamera — function @experimental
```
(host: CameraDirectorHost, opts?: { amplitude?: number; rotation?: number; frequency?: number; duration?: number; }): void
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index 6c0e932ee..d84bd6bdc 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -1,11 +1,11 @@
# API surface — esengine/index.native
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 99 beta · 1750 experimental · 3 deprecated
+Symbols: 114 public · 99 beta · 1758 experimental · 3 deprecated
## ABI_LAYOUT_HASH — const @experimental
```
-"cccf3c7425936b84"
+"bfed6926d0e50843"
```
## ANCHOR_AXES — const @experimental
@@ -1344,12 +1344,20 @@ position: readonly [number, number, number] | undefined
radius: number | undefined
```
+## BakeMobility — interface @experimental
+```
+bodyType: BodyType | undefined
+characterController: boolean | undefined
+```
+
## BakeOptions — interface @experimental
```
ambient: readonly [number, number, number] | undefined
atlasSize: number | undefined
bounces: number | undefined
dilate: number | undefined
+probeGrids: readonly ProbeGrid[] | undefined
+probeSamples: number | undefined
samples: number | undefined
texelsPerUnit: number | undefined
```
@@ -1358,6 +1366,7 @@ texelsPerUnit: number | undefined
```
lumels: number
pixels: Uint8Array<ArrayBufferLike>
+probes: Float32Array<ArrayBufferLike>[]
scaleOffset: [number, number, number, number][]
size: number
```
@@ -4609,6 +4618,7 @@ BuiltinComponentDef<LightProbeVolumeData>
enabled: boolean
halfExtents: Vec3
probes: number
+spacing: number
```
## LightStatus — interface @experimental
@@ -6969,6 +6979,13 @@ query: (view: InterestProviderQueryView) => ReadonlySet<Entity> | "all"
ResourceDef<CameraViewAPI>
```
+## ProbeGrid — interface @experimental
+```
+max: readonly [number, number, number]
+min: readonly [number, number, number]
+resolution: readonly [number, number, number]
+```
+
## ProbedRegistrations — interface @experimental
```
fingerprint: string
@@ -7683,6 +7700,16 @@ ComponentDef<{}>
-1
```
+## SH_BASIS_SCALE — const @experimental
+```
+readonly [0.282095, 0.488603, 0.488603, 0.488603, 1.092548, 1.092548, 0.315392, 1.092548, 0.546274]
+```
+
+## SH_COSINE_BAND — const @experimental
+```
+readonly [1, number, number, number, 0.25, 0.25, 0.25, 0.25, 0.25]
+```
+
## SIDE_MODULES — const @experimental
```
Record<BuiltinSideModuleId, SideModuleDescriptor>
@@ -11222,6 +11249,11 @@ AudioPlugin
(world: Pick<World, "tryGet">, avatar: AnimatorAvatar | null): JointResolver
```
+## bakeHoldsStill — function @experimental
+```
+(mobility: BakeMobility): boolean
+```
+
## bakeLightmap — function @experimental
```
(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): BakeResult
@@ -11612,6 +11644,11 @@ BtPlugin
(name: string, pages: string[], current?: string): ControllerState
```
+## convolveCosine — function @experimental
+```
+(coefficients: Float32Array, at?: number): void
+```
+
## corePlugin — const @experimental
```
Plugin
@@ -12117,6 +12154,11 @@ DragPlugin
(bb: Blackboard, guards: BlackboardGuard | BlackboardGuard[]): boolean
```
+## evalIrradianceSH — function @experimental
+```
+(coefficients: ArrayLike<number>, dx: number, dy: number, dz: number, at?: number): [number, number, number]
+```
+
## evaluateAnimatorPath — function @experimental
```
(def: AnimatorScope, currentPath: string, params: AnimatorParamValues, triggers: ReadonlySet<string>, clipFinished?: boolean): AnimatorPathEvalResult
@@ -13952,6 +13994,11 @@ ServicesPlugin
(handler: WasmErrorHandler | null): void
```
+## shBasis — function @experimental
+```
+(dx: number, dy: number, dz: number, out: Float32Array): void
+```
+
## shakeCamera — function @experimental
```
(host: CameraDirectorHost, opts?: { amplitude?: number; rotation?: number; frequency?: number; duration?: number; }): void
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index e64d74330..df42adea8 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 96 beta · 1730 experimental · 3 deprecated
+Symbols: 114 public · 96 beta · 1738 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -1339,12 +1339,20 @@ position: readonly [number, number, number] | undefined
radius: number | undefined
```
+## BakeMobility — interface @experimental
+```
+bodyType: BodyType | undefined
+characterController: boolean | undefined
+```
+
## BakeOptions — interface @experimental
```
ambient: readonly [number, number, number] | undefined
atlasSize: number | undefined
bounces: number | undefined
dilate: number | undefined
+probeGrids: readonly ProbeGrid[] | undefined
+probeSamples: number | undefined
samples: number | undefined
texelsPerUnit: number | undefined
```
@@ -1353,6 +1361,7 @@ texelsPerUnit: number | undefined
```
lumels: number
pixels: Uint8Array<ArrayBufferLike>
+probes: Float32Array<ArrayBufferLike>[]
scaleOffset: [number, number, number, number][]
size: number
```
@@ -4596,6 +4605,7 @@ BuiltinComponentDef<LightProbeVolumeData>
enabled: boolean
halfExtents: Vec3
probes: number
+spacing: number
```
## LightStatus — interface @experimental
@@ -6781,6 +6791,13 @@ query: (view: InterestProviderQueryView) => ReadonlySet<Entity> | "all"
ResourceDef<CameraViewAPI>
```
+## ProbeGrid — interface @experimental
+```
+max: readonly [number, number, number]
+min: readonly [number, number, number]
+resolution: readonly [number, number, number]
+```
+
## ProbedRegistrations — interface @experimental
```
fingerprint: string
@@ -7485,6 +7502,16 @@ ComponentDef<{}>
-1
```
+## SH_BASIS_SCALE — const @experimental
+```
+readonly [0.282095, 0.488603, 0.488603, 0.488603, 1.092548, 1.092548, 0.315392, 1.092548, 0.546274]
+```
+
+## SH_COSINE_BAND — const @experimental
+```
+readonly [1, number, number, number, 0.25, 0.25, 0.25, 0.25, 0.25]
+```
+
## SIDE_MODULES — const @experimental
```
Record<BuiltinSideModuleId, SideModuleDescriptor>
@@ -11009,6 +11036,11 @@ AudioPlugin
(world: Pick<World, "tryGet">, avatar: AnimatorAvatar | null): JointResolver
```
+## bakeHoldsStill — function @experimental
+```
+(mobility: BakeMobility): boolean
+```
+
## bakeLightmap — function @experimental
```
(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): BakeResult
@@ -11399,6 +11431,11 @@ BtPlugin
(name: string, pages: string[], current?: string): ControllerState
```
+## convolveCosine — function @experimental
+```
+(coefficients: Float32Array, at?: number): void
+```
+
## corePlugin — const @experimental
```
Plugin
@@ -11879,6 +11916,11 @@ DragPlugin
(bb: Blackboard, guards: BlackboardGuard | BlackboardGuard[]): boolean
```
+## evalIrradianceSH — function @experimental
+```
+(coefficients: ArrayLike<number>, dx: number, dy: number, dz: number, at?: number): [number, number, number]
+```
+
## evaluateAnimatorPath — function @experimental
```
(def: AnimatorScope, currentPath: string, params: AnimatorParamValues, triggers: ReadonlySet<string>, clipFinished?: boolean): AnimatorPathEvalResult
@@ -13714,6 +13756,11 @@ ServicesPlugin
(handler: WasmErrorHandler | null): void
```
+## shBasis — function @experimental
+```
+(dx: number, dy: number, dz: number, out: Float32Array): void
+```
+
## shakeCamera — function @experimental
```
(host: CameraDirectorHost, opts?: { amplitude?: number; rotation?: number; frequency?: number; duration?: number; }): void
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index e3665e953..258cddc79 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/minigame
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 94 beta · 1752 experimental · 3 deprecated
+Symbols: 114 public · 94 beta · 1760 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -1339,12 +1339,20 @@ position: readonly [number, number, number] | undefined
radius: number | undefined
```
+## BakeMobility — interface @experimental
+```
+bodyType: BodyType | undefined
+characterController: boolean | undefined
+```
+
## BakeOptions — interface @experimental
```
ambient: readonly [number, number, number] | undefined
atlasSize: number | undefined
bounces: number | undefined
dilate: number | undefined
+probeGrids: readonly ProbeGrid[] | undefined
+probeSamples: number | undefined
samples: number | undefined
texelsPerUnit: number | undefined
```
@@ -1353,6 +1361,7 @@ texelsPerUnit: number | undefined
```
lumels: number
pixels: Uint8Array<ArrayBufferLike>
+probes: Float32Array<ArrayBufferLike>[]
scaleOffset: [number, number, number, number][]
size: number
```
@@ -4596,6 +4605,7 @@ BuiltinComponentDef<LightProbeVolumeData>
enabled: boolean
halfExtents: Vec3
probes: number
+spacing: number
```
## LightStatus — interface @experimental
@@ -7029,6 +7039,13 @@ query: (view: InterestProviderQueryView) => ReadonlySet<Entity> | "all"
ResourceDef<CameraViewAPI>
```
+## ProbeGrid — interface @experimental
+```
+max: readonly [number, number, number]
+min: readonly [number, number, number]
+resolution: readonly [number, number, number]
+```
+
## ProbedRegistrations — interface @experimental
```
fingerprint: string
@@ -7733,6 +7750,16 @@ ComponentDef<{}>
-1
```
+## SH_BASIS_SCALE — const @experimental
+```
+readonly [0.282095, 0.488603, 0.488603, 0.488603, 1.092548, 1.092548, 0.315392, 1.092548, 0.546274]
+```
+
+## SH_COSINE_BAND — const @experimental
+```
+readonly [1, number, number, number, 0.25, 0.25, 0.25, 0.25, 0.25]
+```
+
## SIDE_MODULES — const @experimental
```
Record<BuiltinSideModuleId, SideModuleDescriptor>
@@ -11263,6 +11290,11 @@ AudioPlugin
(world: Pick<World, "tryGet">, avatar: AnimatorAvatar | null): JointResolver
```
+## bakeHoldsStill — function @experimental
+```
+(mobility: BakeMobility): boolean
+```
+
## bakeLightmap — function @experimental
```
(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): BakeResult
@@ -11653,6 +11685,11 @@ BtPlugin
(name: string, pages: string[], current?: string): ControllerState
```
+## convolveCosine — function @experimental
+```
+(coefficients: Float32Array, at?: number): void
+```
+
## corePlugin — const @experimental
```
Plugin
@@ -12138,6 +12175,11 @@ DragPlugin
(bb: Blackboard, guards: BlackboardGuard | BlackboardGuard[]): boolean
```
+## evalIrradianceSH — function @experimental
+```
+(coefficients: ArrayLike<number>, dx: number, dy: number, dz: number, at?: number): [number, number, number]
+```
+
## evaluateAnimatorPath — function @experimental
```
(def: AnimatorScope, currentPath: string, params: AnimatorParamValues, triggers: ReadonlySet<string>, clipFinished?: boolean): AnimatorPathEvalResult
@@ -13973,6 +14015,11 @@ ServicesPlugin
(handler: WasmErrorHandler | null): void
```
+## shBasis — function @experimental
+```
+(dx: number, dy: number, dz: number, out: Float32Array): void
+```
+
## shakeCamera — function @experimental
```
(host: CameraDirectorHost, opts?: { amplitude?: number; rotation?: number; frequency?: number; duration?: number; }): void
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 007f55151..88cb663ed 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/wechat
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 114 public · 94 beta · 1742 experimental · 3 deprecated
+Symbols: 114 public · 94 beta · 1750 experimental · 3 deprecated
## ANCHOR_AXES — const @experimental
```
@@ -1339,12 +1339,20 @@ position: readonly [number, number, number] | undefined
radius: number | undefined
```
+## BakeMobility — interface @experimental
+```
+bodyType: BodyType | undefined
+characterController: boolean | undefined
+```
+
## BakeOptions — interface @experimental
```
ambient: readonly [number, number, number] | undefined
atlasSize: number | undefined
bounces: number | undefined
dilate: number | undefined
+probeGrids: readonly ProbeGrid[] | undefined
+probeSamples: number | undefined
samples: number | undefined
texelsPerUnit: number | undefined
```
@@ -1353,6 +1361,7 @@ texelsPerUnit: number | undefined
```
lumels: number
pixels: Uint8Array<ArrayBufferLike>
+probes: Float32Array<ArrayBufferLike>[]
scaleOffset: [number, number, number, number][]
size: number
```
@@ -4603,6 +4612,7 @@ BuiltinComponentDef<LightProbeVolumeData>
enabled: boolean
halfExtents: Vec3
probes: number
+spacing: number
```
## LightStatus — interface @experimental
@@ -6788,6 +6798,13 @@ query: (view: InterestProviderQueryView) => ReadonlySet<Entity> | "all"
ResourceDef<CameraViewAPI>
```
+## ProbeGrid — interface @experimental
+```
+max: readonly [number, number, number]
+min: readonly [number, number, number]
+resolution: readonly [number, number, number]
+```
+
## ProbedRegistrations — interface @experimental
```
fingerprint: string
@@ -7492,6 +7509,16 @@ ComponentDef<{}>
-1
```
+## SH_BASIS_SCALE — const @experimental
+```
+readonly [0.282095, 0.488603, 0.488603, 0.488603, 1.092548, 1.092548, 0.315392, 1.092548, 0.546274]
+```
+
+## SH_COSINE_BAND — const @experimental
+```
+readonly [1, number, number, number, 0.25, 0.25, 0.25, 0.25, 0.25]
+```
+
## SIDE_MODULES — const @experimental
```
Record<BuiltinSideModuleId, SideModuleDescriptor>
@@ -11037,6 +11064,11 @@ AudioPlugin
(world: Pick<World, "tryGet">, avatar: AnimatorAvatar | null): JointResolver
```
+## bakeHoldsStill — function @experimental
+```
+(mobility: BakeMobility): boolean
+```
+
## bakeLightmap — function @experimental
```
(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): BakeResult
@@ -11427,6 +11459,11 @@ BtPlugin
(name: string, pages: string[], current?: string): ControllerState
```
+## convolveCosine — function @experimental
+```
+(coefficients: Float32Array, at?: number): void
+```
+
## corePlugin — const @experimental
```
Plugin
@@ -11907,6 +11944,11 @@ DragPlugin
(bb: Blackboard, guards: BlackboardGuard | BlackboardGuard[]): boolean
```
+## evalIrradianceSH — function @experimental
+```
+(coefficients: ArrayLike<number>, dx: number, dy: number, dz: number, at?: number): [number, number, number]
+```
+
## evaluateAnimatorPath — function @experimental
```
(def: AnimatorScope, currentPath: string, params: AnimatorParamValues, triggers: ReadonlySet<string>, clipFinished?: boolean): AnimatorPathEvalResult
@@ -13737,6 +13779,11 @@ ServicesPlugin
(handler: WasmErrorHandler | null): void
```
+## shBasis — function @experimental
+```
+(dx: number, dy: number, dz: number, out: Float32Array): void
+```
+
## shakeCamera — function @experimental
```
(host: CameraDirectorHost, opts?: { amplitude?: number; rotation?: number; frequency?: number; duration?: number; }): void
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index 8ec221633..2aafb88e7 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -152,6 +152,16 @@ export {
*/
export {
bakeLightmap, type BakeOptions, type BakeResult, type BakeSurface, type BakeLight,
+ type ProbeGrid, bakeHoldsStill, type BakeMobility,
+} from './lightmap';
+/**
+ * Nine coefficients, as the shader reads them. A panorama import and a probe
+ * solve both produce these, and this is the one basis both go through.
+ *
+ * @experimental Pre-1.0: exported for the importers that write coefficients.
+ */
+export {
+ shBasis, convolveCosine, evalIrradianceSH, SH_BASIS_SCALE, SH_COSINE_BAND,
} from './lightmap';
/**
* Stock geometry a `builtin:<id>` mesh ref names. Public because the editor's
diff --git a/sdk/src/ecs/bridge/ptrAccessors.generated.ts b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
index 26d67a31d..02ed88f70 100644
--- a/sdk/src/ecs/bridge/ptrAccessors.generated.ts
+++ b/sdk/src/ecs/bridge/ptrAccessors.generated.ts
@@ -900,6 +900,7 @@ export function createLightData(): LightPtrData {
export interface LightProbeVolumePtrData {
probes: number;
halfExtents: Vec3;
+ spacing: number;
enabled: boolean;
}
@@ -909,7 +910,8 @@ export function fillLightProbeVolume(
): void {
out.probes = u32[ptr >> 2];
const halfExtents_ = out.halfExtents; halfExtents_.x = f32[(ptr + 4) >> 2]; halfExtents_.y = f32[((ptr + 4) >> 2) + 1]; halfExtents_.z = f32[((ptr + 4) >> 2) + 2];
- out.enabled = u8[ptr + 16] !== 0;
+ out.spacing = f32[(ptr + 16) >> 2];
+ out.enabled = u8[ptr + 20] !== 0;
}
export function writeLightProbeVolume(
@@ -918,13 +920,15 @@ export function writeLightProbeVolume(
): void {
u32[ptr >> 2] = data.probes;
f32[(ptr + 4) >> 2] = data.halfExtents.x; f32[((ptr + 4) >> 2) + 1] = data.halfExtents.y; f32[((ptr + 4) >> 2) + 2] = data.halfExtents.z;
- u8[ptr + 16] = data.enabled ? 1 : 0;
+ f32[(ptr + 16) >> 2] = data.spacing;
+ u8[ptr + 20] = data.enabled ? 1 : 0;
}
export function createLightProbeVolumeData(): LightProbeVolumePtrData {
return {
probes: 0,
halfExtents: { x: 0, y: 0, z: 0 },
+ spacing: 0,
enabled: false,
};
}
diff --git a/sdk/src/ecs/component.generated.ts b/sdk/src/ecs/component.generated.ts
index fba5cf96a..be03f9bf8 100644
--- a/sdk/src/ecs/component.generated.ts
+++ b/sdk/src/ecs/component.generated.ts
@@ -15,7 +15,7 @@ import type { AlignContent, AlignItems, AlignSelf, BodyType, CanvasScaleMode, Cl
* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to
* run on mismatch, because mismatched offsets read the wrong heap bytes.
*/
-export const ABI_LAYOUT_HASH = 'cccf3c7425936b84';
+export const ABI_LAYOUT_HASH = 'bfed6926d0e50843';
/**
* One asset-valued field of a component: which field, and what kind of
@@ -510,6 +510,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
defaults: {
probes: 0,
halfExtents: { x: 100, y: 100, z: 100 },
+ spacing: 100,
enabled: true,
},
assetFields: [{ field: 'probes', type: 'probeVolume' as AssetFieldType }],
@@ -519,6 +520,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
fields: {
probes: { tooltip: "Baked probe grid (.esprobes) filling this box." },
halfExtents: { min: 0, tooltip: "Half the box this volume covers, from the entity's position." },
+ spacing: { min: 1, tooltip: "World units between probes the next bake lays down." },
},
},
MeshCollider3D: {
@@ -1422,6 +1424,7 @@ export interface LightData {
export interface LightProbeVolumeData {
probes: number;
halfExtents: Vec3;
+ spacing: number;
enabled: boolean;
}
diff --git a/sdk/src/lightmap/bake.ts b/sdk/src/lightmap/bake.ts
index e8f49437a..e202dd6f4 100644
--- a/sdk/src/lightmap/bake.ts
+++ b/sdk/src/lightmap/bake.ts
@@ -13,6 +13,7 @@ import { MeshChannel, MeshChannelType, type MeshData, type MeshChannelDesc } fro
import { Bvh, type TriangleSoup } from './bvh';
import { layoutAtlas, rasterizeLumels, type BakeSurface, type SurfacePatch } from './atlas';
import { solveDirect, solveBounce, type BakeLight, type HitLookup } from './solve';
+import { solveProbes, type ProbeGrid } from './probes';
export interface BakeOptions {
/** Side of the square atlas, in texels. */
@@ -32,6 +33,13 @@ export interface BakeOptions {
/** Texels the solved edges are smeared outwards, so a bilinear tap near a
* chart's border does not read the empty atlas beside it. */
dilate?: number;
+ /** Grids of probes to solve in the same light field — what lights the things
+ * a bake cannot hold still. Solved after the surfaces, because a probe
+ * gathers what they ended up giving off. */
+ probeGrids?: readonly ProbeGrid[];
+ /** Directions each probe gathers. Over the whole sphere, so this buys less
+ * per ray than a lumel's hemisphere does. */
+ probeSamples?: number;
}
export interface BakeResult {
@@ -42,6 +50,9 @@ export interface BakeResult {
scaleOffset: Array<[number, number, number, number]>;
/** Texels the surfaces actually cover, out of the atlas. */
lumels: number;
+ /** Nine RGB coefficients per probe, one array per requested grid, in grid
+ * order with x varying fastest — what a `.esprobes` carries. */
+ probes: Float32Array[];
}
const DEFAULTS = {
@@ -51,6 +62,8 @@ const DEFAULTS = {
samples: 64,
ambient: [0, 0, 0] as readonly [number, number, number],
dilate: 2,
+ probeGrids: [] as readonly ProbeGrid[],
+ probeSamples: 128,
};
const chan = (m: MeshData, s: number): MeshChannelDesc | undefined =>
@@ -66,6 +79,7 @@ function collect(surfaces: readonly BakeSurface[], patches: readonly SurfacePatc
const triSurface = new Int32Array(total);
const patch = new Float32Array(surfaces.length * 4);
const albedo = new Float32Array(surfaces.length * 3);
+ const triNormal = new Float32Array(total * 3);
let at = 0;
for (let s = 0; s < surfaces.length; s++) {
@@ -80,6 +94,7 @@ function collect(surfaces: readonly BakeSurface[], patches: readonly SurfacePatc
const pos = chan(mesh, MeshChannel.Position);
const uv1 = chan(mesh, MeshChannel.TexCoord1);
+ const nrm = chan(mesh, MeshChannel.Normal);
const view = new DataView(mesh.vertices.buffer, mesh.vertices.byteOffset, mesh.vertices.byteLength);
const idx = mesh.indices;
for (let i = 0; i + 2 < idx.length; i += 3, at++) {
@@ -100,10 +115,36 @@ function collect(surfaces: readonly BakeSurface[], patches: readonly SurfacePatc
triUV[at * 6 + k * 2] = view.getFloat32(b, true);
triUV[at * 6 + k * 2 + 1] = view.getFloat32(b + 4, true);
}
+ if (nrm && nrm.type === MeshChannelType.Float32) {
+ const b = v * mesh.vertexStride + nrm.offset;
+ const x = view.getFloat32(b, true);
+ const y = view.getFloat32(b + 4, true);
+ const z = view.getFloat32(b + 8, true);
+ // The transform's rotation, which is its upper 3x3 — a
+ // non-uniform scale would want the inverse transpose, and
+ // only the SIGN of this is read.
+ triNormal[at * 3] += m[0] * x + m[4] * y + m[8] * z;
+ triNormal[at * 3 + 1] += m[1] * x + m[5] * y + m[9] * z;
+ triNormal[at * 3 + 2] += m[2] * x + m[6] * y + m[10] * z;
+ }
}
}
}
- return { soup: { positions, count: total }, lookup: { triUV, triSurface, patch, albedo } };
+ // Geometry with no declared normal gets the winding's: something has to say
+ // which side is lit, and a zero vector would call every arrival a back.
+ for (let t = 0; t < total; t++) {
+ const at = t * 3;
+ if (triNormal[at] !== 0 || triNormal[at + 1] !== 0 || triNormal[at + 2] !== 0) continue;
+ const p = t * 9;
+ const e1 = [positions[p + 3] - positions[p], positions[p + 4] - positions[p + 1],
+ positions[p + 5] - positions[p + 2]];
+ const e2 = [positions[p + 6] - positions[p], positions[p + 7] - positions[p + 1],
+ positions[p + 8] - positions[p + 2]];
+ triNormal[at] = e1[1] * e2[2] - e1[2] * e2[1];
+ triNormal[at + 1] = e1[2] * e2[0] - e1[0] * e2[2];
+ triNormal[at + 2] = e1[0] * e2[1] - e1[1] * e2[0];
+ }
+ return { soup: { positions, count: total }, lookup: { triUV, triSurface, patch, albedo, triNormal } };
}
/** Smears solved texels outwards so a bilinear tap near an edge reads light
@@ -198,10 +239,16 @@ export function bakeLightmap(surfaces: readonly BakeSurface[], lights: readonly
pixels[i * 4 + 3] = 255;
}
+ // The probes read the atlas as a bounce does — after it holds everything the
+ // surfaces ended up giving off, and before it is quantised to eight bits.
+ const probes = opts.probeGrids.map((grid) =>
+ solveProbes(grid, bvh, lookup, radiance, size, opts.probeSamples, opts.ambient));
+
return {
pixels,
size,
scaleOffset: patches.map((p) => p.scaleOffset),
lumels: lumels.count,
+ probes,
};
}
diff --git a/sdk/src/lightmap/index.ts b/sdk/src/lightmap/index.ts
index c9d2cd604..7b59b751e 100644
--- a/sdk/src/lightmap/index.ts
+++ b/sdk/src/lightmap/index.ts
@@ -4,3 +4,6 @@ export { unwrapLightmapUV, type UnwrapOptions, type UnwrapResult } from './unwra
export { bakeLightmap, type BakeOptions, type BakeResult } from './bake';
export type { BakeSurface } from './atlas';
export type { BakeLight } from './solve';
+export { solveProbes, probeAt, type ProbeGrid } from './probes';
+export { bakeHoldsStill, type BakeMobility } from './mobility';
+export { shBasis, convolveCosine, evalIrradianceSH, SH_BASIS_SCALE, SH_COSINE_BAND } from './sh';
diff --git a/sdk/src/lightmap/mobility.ts b/sdk/src/lightmap/mobility.ts
new file mode 100644
index 000000000..823865f33
--- /dev/null
+++ b/sdk/src/lightmap/mobility.ts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file mobility.ts
+ * @brief Whether a bake can hold an object still.
+ *
+ * @details A bake writes light into a PLACE, so an object the simulation moves
+ * wears the light of where it started. Which things move is the physics
+ * components' to say; a second declaration of it would be a second
+ * answer free to disagree. Two collectors read the same rule from here,
+ * each having got the facts from the shape it reads (a document, or a
+ * world).
+ */
+
+import { BodyType } from '../wasm/wasm.generated';
+
+/** What an entity's physics components say about whether it stays put. */
+export interface BakeMobility {
+ /** It carries a CharacterController3D, which exists to walk. */
+ characterController?: boolean;
+ /** Its RigidBody3D's `bodyType`, when it has one. */
+ bodyType?: BodyType;
+}
+
+/**
+ * True where a bake may light this object and false where a probe volume must.
+ *
+ * Nothing said is a yes: a scene's walls and floors carry no physics at all.
+ */
+export function bakeHoldsStill(mobility: BakeMobility): boolean {
+ if (mobility.characterController) return false;
+ return mobility.bodyType === undefined || mobility.bodyType === BodyType.Static;
+}
diff --git a/sdk/src/lightmap/probes.ts b/sdk/src/lightmap/probes.ts
new file mode 100644
index 000000000..c0f2a0f6e
--- /dev/null
+++ b/sdk/src/lightmap/probes.ts
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file probes.ts
+ * @brief What light arrives at a point in the air, as nine coefficients.
+ *
+ * @details The bounce's gather, aimed from a point rather than from a surface:
+ * the whole sphere instead of a hemisphere, and no normal to weight by.
+ * It is the same light field the atlas holds, sampled where a thing that
+ * moves can be — which is the one place a lightmap cannot answer.
+ */
+
+import type { Bvh } from './bvh';
+import { texelOf, facesRay, type HitLookup } from './solve';
+import { shBasis, convolveCosine } from './sh';
+
+/** Where one grid of probes sits, and how many. */
+export interface ProbeGrid {
+ /** The world box the probes fill, corner to corner. */
+ min: readonly [number, number, number];
+ max: readonly [number, number, number];
+ /** Probes along each axis. */
+ resolution: readonly [number, number, number];
+}
+
+/**
+ * Directions over the whole sphere, as a fixed low-discrepancy set (Fibonacci).
+ * Fixed and not random, for the reason the hemisphere's set is: a bake that
+ * answers differently twice cannot be told from one that answers wrongly once.
+ */
+function sphere(samples: number): Float32Array {
+ const out = new Float32Array(samples * 3);
+ const golden = Math.PI * (3 - Math.sqrt(5));
+ for (let i = 0; i < samples; i++) {
+ const y = 1 - (2 * i + 1) / samples;
+ const r = Math.sqrt(Math.max(0, 1 - y * y));
+ const phi = i * golden;
+ out[i * 3] = Math.cos(phi) * r;
+ out[i * 3 + 1] = y;
+ out[i * 3 + 2] = Math.sin(phi) * r;
+ }
+ return out;
+}
+
+/**
+ * Where probe `i` of `n` sits along one axis.
+ *
+ * On the CORNERS — the rule ProbeStore's trilinear read assumes, so a volume's
+ * own bounds are covered by its own probes. One probe sits at the middle, which
+ * is the value that read takes for the whole axis.
+ */
+export function probeAt(min: number, max: number, i: number, n: number): number {
+ if (n <= 1) return (min + max) * 0.5;
+ return min + (max - min) * (i / (n - 1));
+}
+
+/**
+ * Nine RGB coefficients per probe, in grid order with x varying fastest.
+ *
+ * `atlas` is the solved light field indexed by texel — what a surface gives off,
+ * before its own albedo. A ray that hits geometry with no place in the atlas
+ * returns black rather than the ambient: something is there, and it is unlit.
+ */
+export function solveProbes(grid: ProbeGrid, bvh: Bvh, lookup: HitLookup,
+ atlas: Float32Array, atlasSize: number, samples: number,
+ ambient: readonly [number, number, number]): Float32Array {
+ const [nx, ny, nz] = grid.resolution;
+ const count = Math.max(0, nx) * Math.max(0, ny) * Math.max(0, nz);
+ const out = new Float32Array(count * 27);
+ if (count === 0) return out;
+
+ const dirs = sphere(samples);
+ const basis = new Float32Array(9);
+ const far = 1e7;
+ // The Monte-Carlo weight of one direction over the sphere, folded in once.
+ const weight = (4 * Math.PI) / samples;
+
+ for (let z = 0; z < nz; z++) {
+ const pz = probeAt(grid.min[2], grid.max[2], z, nz);
+ for (let y = 0; y < ny; y++) {
+ const py = probeAt(grid.min[1], grid.max[1], y, ny);
+ for (let x = 0; x < nx; x++) {
+ const px = probeAt(grid.min[0], grid.max[0], x, nx);
+ const at = (x + y * nx + z * nx * ny) * 27;
+ for (let s = 0; s < samples; s++) {
+ const dx = dirs[s * 3]!, dy = dirs[s * 3 + 1]!, dz = dirs[s * 3 + 2]!;
+ let r = ambient[0], g = ambient[1], b = ambient[2];
+ const tri = bvh.hit(px, py, pz, dx, dy, dz, far, 0);
+ if (tri >= 0) {
+ r = 0; g = 0; b = 0;
+ const texel = facesRay(lookup, tri, dx, dy, dz)
+ ? texelOf(lookup, tri, bvh.hitU, bvh.hitV, atlasSize) : -1;
+ if (texel >= 0) {
+ const surface = lookup.triSurface[tri]!;
+ r = atlas[texel * 3]! * lookup.albedo[surface * 3]!;
+ g = atlas[texel * 3 + 1]! * lookup.albedo[surface * 3 + 1]!;
+ b = atlas[texel * 3 + 2]! * lookup.albedo[surface * 3 + 2]!;
+ }
+ }
+ shBasis(dx, dy, dz, basis);
+ for (let i = 0; i < 9; i++) {
+ const w = basis[i]! * weight;
+ out[at + i * 3]! += r * w;
+ out[at + i * 3 + 1]! += g * w;
+ out[at + i * 3 + 2]! += b * w;
+ }
+ }
+ convolveCosine(out, at);
+ }
+ }
+ }
+ return out;
+}
diff --git a/sdk/src/lightmap/sh.ts b/sdk/src/lightmap/sh.ts
new file mode 100644
index 000000000..84ea7599e
--- /dev/null
+++ b/sdk/src/lightmap/sh.ts
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file sh.ts
+ * @brief Nine coefficients: the shader's `shIrradiance` and its inverse.
+ *
+ * @details Two things produce these — a panorama import and a probe solve — and
+ * one expression reads them back. The scales here are the shader's own,
+ * so what a bake writes is what a fragment reconstructs.
+ */
+
+/** The nine real SH basis scales, in the usual l/m order. */
+export const SH_BASIS_SCALE = [
+ 0.282095,
+ 0.488603, 0.488603, 0.488603,
+ 1.092548, 1.092548, 0.315392, 1.092548, 0.546274,
+] as const;
+
+/**
+ * Ramamoorthi & Hanrahan's cosine-lobe convolution, over π.
+ *
+ * The division is what makes a constant field come back as itself — a uniform
+ * radiance c integrates to πc — so these land where the flat ambient term sits,
+ * as the value that multiplies albedo.
+ */
+export const SH_COSINE_BAND = [1, 2 / 3, 2 / 3, 2 / 3, 0.25, 0.25, 0.25, 0.25, 0.25] as const;
+
+/** The nine basis functions at `d`, which must be a unit direction. */
+export function shBasis(dx: number, dy: number, dz: number, out: Float32Array): void {
+ out[0] = SH_BASIS_SCALE[0];
+ out[1] = SH_BASIS_SCALE[1] * dy;
+ out[2] = SH_BASIS_SCALE[2] * dz;
+ out[3] = SH_BASIS_SCALE[3] * dx;
+ out[4] = SH_BASIS_SCALE[4] * dx * dy;
+ out[5] = SH_BASIS_SCALE[5] * dy * dz;
+ out[6] = SH_BASIS_SCALE[6] * (3 * dz * dz - 1);
+ out[7] = SH_BASIS_SCALE[7] * dx * dz;
+ out[8] = SH_BASIS_SCALE[8] * (dx * dx - dy * dy);
+}
+
+/** Convolves radiance coefficients into irradiance ones, in place. */
+export function convolveCosine(coefficients: Float32Array, at = 0): void {
+ for (let i = 0; i < 9; i++) {
+ for (let c = 0; c < 3; c++) coefficients[at + i * 3 + c]! *= SH_COSINE_BAND[i];
+ }
+}
+
+/** Evaluate nine RGB coefficients at `d` — the shader's reconstruction, in
+ * TypeScript, so a test can state what a pixel should be. */
+export function evalIrradianceSH(coefficients: ArrayLike<number>,
+ dx: number, dy: number, dz: number,
+ at = 0): [number, number, number] {
+ const basis = new Float32Array(9);
+ shBasis(dx, dy, dz, basis);
+ const out: [number, number, number] = [0, 0, 0];
+ for (let i = 0; i < 9; i++) {
+ for (let c = 0; c < 3; c++) out[c] += coefficients[at + i * 3 + c]! * basis[i]!;
+ }
+ return out;
+}
diff --git a/sdk/src/lightmap/solve.ts b/sdk/src/lightmap/solve.ts
index bf633cc65..2fbadbcdb 100644
--- a/sdk/src/lightmap/solve.ts
+++ b/sdk/src/lightmap/solve.ts
@@ -39,9 +39,20 @@ export interface HitLookup {
patch: Float32Array;
/** Albedo per surface, three floats each. */
albedo: Float32Array;
+ /** Which way each triangle FACES, three floats each. A surface gives off
+ * light on one side; a ray arriving at the other finds an unlit back. */
+ triNormal: Float32Array;
}
-const SHADOW_EPSILON = 1e-3;
+/** Whether a ray travelling `d` arrived at triangle `tri`'s lit side. */
+export function facesRay(lookup: HitLookup, tri: number,
+ dx: number, dy: number, dz: number): boolean {
+ const at = tri * 3;
+ return lookup.triNormal[at] * dx + lookup.triNormal[at + 1] * dy
+ + lookup.triNormal[at + 2] * dz < 0;
+}
+
+export const SHADOW_EPSILON = 1e-3;
/** Cosine-weighted directions over a hemisphere, as a fixed low-discrepancy set.
* Fixed and not random: a bake that answers differently twice cannot be told
@@ -156,7 +167,7 @@ export function solveBounce(lumels: LumelField, bvh: Bvh, lookup: HitLookup,
const dz = basis[2] * a + basis[5] * c + nz * d;
const tri = bvh.hit(px + nx * SHADOW_EPSILON, py + ny * SHADOW_EPSILON, pz + nz * SHADOW_EPSILON,
dx, dy, dz, far, SHADOW_EPSILON);
- if (tri < 0) continue;
+ if (tri < 0 || !facesRay(lookup, tri, dx, dy, dz)) continue;
const texel = texelOf(lookup, tri, bvh.hitU, bvh.hitV, atlasSize);
if (texel < 0) continue;
const surface = lookup.triSurface[tri];
@@ -173,7 +184,7 @@ export function solveBounce(lumels: LumelField, bvh: Bvh, lookup: HitLookup,
}
/** Where on the atlas a hit lands, or -1 when it falls outside it. */
-function texelOf(lookup: HitLookup, tri: number, u: number, v: number, size: number): number {
+export function texelOf(lookup: HitLookup, tri: number, u: number, v: number, size: number): number {
const at = tri * 6;
const w0 = 1 - u - v;
const uu = w0 * lookup.triUV[at] + u * lookup.triUV[at + 2] + v * lookup.triUV[at + 4];
diff --git a/sdk/src/wasm/ptrLayouts.generated.ts b/sdk/src/wasm/ptrLayouts.generated.ts
index e02d67129..9e46ea124 100644
--- a/sdk/src/wasm/ptrLayouts.generated.ts
+++ b/sdk/src/wasm/ptrLayouts.generated.ts
@@ -254,7 +254,8 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {
fields: [
{ name: 'probes', type: 'u32', offset: 0 },
{ name: 'halfExtents', type: 'vec3', offset: 4 },
- { name: 'enabled', type: 'bool', offset: 16 },
+ { name: 'spacing', type: 'f32', offset: 16 },
+ { name: 'enabled', type: 'bool', offset: 20 },
],
},
MeshCollider3D: {
diff --git a/sdk/src/wasm/wasm.generated.ts b/sdk/src/wasm/wasm.generated.ts
index 6611914b8..fe8281fc4 100644
--- a/sdk/src/wasm/wasm.generated.ts
+++ b/sdk/src/wasm/wasm.generated.ts
@@ -574,6 +574,7 @@ export interface Light {
export interface LightProbeVolume {
probes: number;
halfExtents: Vec3;
+ spacing: number;
enabled: boolean;
}
diff --git a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
index 63a523011..1ab36fcdf 100644
--- a/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
+++ b/sdk/tests/__snapshots__/component-fieldmeta-golden.test.ts.snap
@@ -430,6 +430,10 @@ exports[`builtin FieldMeta (RC9-1 equivalence gate) > matches the golden snapsho
"probes": {
"tooltip": "Baked probe grid (.esprobes) filling this box.",
},
+ "spacing": {
+ "min": 1,
+ "tooltip": "World units between probes the next bake lays down.",
+ },
},
"Marker": {
"properties": {
diff --git a/sdk/tests/lightmap-probes.test.ts b/sdk/tests/lightmap-probes.test.ts
new file mode 100644
index 000000000..d30cefefd
--- /dev/null
+++ b/sdk/tests/lightmap-probes.test.ts
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * What a probe answers where a lightmap cannot: a point in the air. The cases
+ * here are the ones a pixel gate cannot state — whether the nine coefficients
+ * mean what an `.esenv`'s do, whether they carry a direction, and where in its
+ * box a probe actually sits.
+ */
+import { describe, it, expect } from 'vitest';
+import { bakeLightmap, evalIrradianceSH, probeAt, type BakeSurface, type BakeLight, type ProbeGrid }
+ from '../src/lightmap';
+import { MeshChannel, MeshChannelType, type MeshData } from '../src/asset/meshFormat';
+import { unwrapLightmapUV } from '../src/lightmap';
+
+const IDENTITY = Float32Array.from([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
+
+function translated(x: number, y: number, z: number): Float32Array {
+ const m = IDENTITY.slice();
+ m[12] = x; m[13] = y; m[14] = z;
+ return m;
+}
+
+/** A quad on the YZ plane facing -X, so it looks back at the origin from +X. */
+function facingBack(half: number): MeshData {
+ const p = [[0, -half, -half], [0, -half, half], [0, half, half], [0, half, -half]];
+ const stride = 24;
+ const vertices = new Uint8Array(p.length * stride);
+ const view = new DataView(vertices.buffer);
+ p.forEach((q, i) => {
+ for (let k = 0; k < 3; k++) view.setFloat32(i * stride + k * 4, q[k]!, true);
+ view.setFloat32(i * stride + 12, -1, true);
+ view.setFloat32(i * stride + 16, 0, true);
+ view.setFloat32(i * stride + 20, 0, true);
+ });
+ return {
+ channels: [
+ { semantic: MeshChannel.Position, components: 3, type: MeshChannelType.Float32, offset: 0 },
+ { semantic: MeshChannel.Normal, components: 3, type: MeshChannelType.Float32, offset: 12 },
+ ],
+ vertexStride: stride,
+ vertexCount: 4,
+ vertices,
+ indices: Uint32Array.from([0, 1, 2, 0, 2, 3]),
+ aabbMin: [0, -half, -half],
+ aabbMax: [0, half, half],
+ };
+}
+
+const baked = (mesh: MeshData): MeshData => unwrapLightmapUV(mesh).mesh;
+
+/** One probe at the centre of a box that holds nothing. */
+const ONE: ProbeGrid = { min: [-50, -50, -50], max: [50, 50, 50], resolution: [1, 1, 1] };
+
+describe('a probe grid', () => {
+ it('reads back an ambient field as itself', () => {
+ // The whole SH convention in one claim: project, convolve, over pi. A
+ // uniform radiance c must come back as c at every normal — which is what
+ // makes an `.esenv` and a volume interchangeable to a shader.
+ const result = bakeLightmap([], [], {
+ ambient: [0.25, 0.5, 0.75], probeGrids: [ONE], probeSamples: 256,
+ });
+ const sh = result.probes[0]!;
+ for (const d of [[0, 1, 0], [1, 0, 0], [0, 0, -1], [-0.577, 0.577, 0.577]]) {
+ const [r, g, b] = evalIrradianceSH(sh, d[0]!, d[1]!, d[2]!);
+ expect(r).toBeCloseTo(0.25, 1);
+ expect(g).toBeCloseTo(0.5, 1);
+ expect(b).toBeCloseTo(0.75, 1);
+ }
+ });
+
+ it('carries WHERE the light came from, not only how much', () => {
+ // A red wall off to +X, lit head-on. Coefficients collapsed to their
+ // constant term would answer the same in both directions, and a
+ // character would not darken as it turned away from the wall.
+ const surface: BakeSurface = {
+ mesh: baked(facingBack(200)),
+ transform: translated(100, 0, 0),
+ albedo: [1, 0, 0],
+ };
+ const light: BakeLight = {
+ kind: 'directional', direction: [1, 0, 0], color: [1, 1, 1], intensity: 1,
+ };
+ const result = bakeLightmap([surface], [light], {
+ atlasSize: 128, texelsPerUnit: 0.1, bounces: 0,
+ probeGrids: [ONE], probeSamples: 512,
+ });
+ const sh = result.probes[0]!;
+ const towards = evalIrradianceSH(sh, 1, 0, 0);
+ const away = evalIrradianceSH(sh, -1, 0, 0);
+ expect(towards[0]).toBeGreaterThan(away[0] + 0.05);
+ // And it is the wall's colour that arrived, not a grey of the same size.
+ expect(towards[0]).toBeGreaterThan(towards[2] + 0.05);
+ });
+
+ it('puts its probes on the corners, and a lone one at the centre', () => {
+ // The contract ProbeStore's trilinear read assumes: probe 0 at min, the
+ // last at max, so a volume's own bounds are covered by its own probes.
+ // An axis of one is a constant along it, which is the middle.
+ expect(probeAt(-10, 30, 0, 3)).toBeCloseTo(-10);
+ expect(probeAt(-10, 30, 1, 3)).toBeCloseTo(10);
+ expect(probeAt(-10, 30, 2, 3)).toBeCloseTo(30);
+ expect(probeAt(-10, 30, 0, 1)).toBeCloseTo(10);
+ });
+
+ it('is darker where something stands between it and the light', () => {
+ // Two probes either side of a lit wall. Occlusion is the reason a grid
+ // beats one environment at all: without it both would read alike, and a
+ // character behind a wall would be lit by what the wall is hiding.
+ const surface: BakeSurface = {
+ mesh: baked(facingBack(200)),
+ transform: translated(0, 0, 0),
+ albedo: [1, 1, 1],
+ };
+ const light: BakeLight = {
+ kind: 'directional', direction: [1, 0, 0], color: [1, 1, 1], intensity: 1,
+ };
+ const grid: ProbeGrid = { min: [-60, 0, 0], max: [60, 0, 0], resolution: [2, 1, 1] };
+ const result = bakeLightmap([surface], [light], {
+ atlasSize: 128, texelsPerUnit: 0.1, bounces: 0,
+ ambient: [0.1, 0.1, 0.1], probeGrids: [grid], probeSamples: 512,
+ });
+ const sh = result.probes[0]!;
+ const lit = evalIrradianceSH(sh, 1, 0, 0, 0)[0];
+ const behind = evalIrradianceSH(sh, -1, 0, 0, 27)[0];
+ expect(lit).toBeGreaterThan(behind + 0.05);
+ });
+
+ it('answers the same twice', () => {
+ // The gate that keeps a baked corpus from rotting compares committed
+ // bytes to a fresh bake, which only a deterministic solve can support.
+ const opts = { ambient: [0.3, 0.2, 0.1] as [number, number, number], probeGrids: [ONE] };
+ const a = bakeLightmap([], [], opts).probes[0]!;
+ const b = bakeLightmap([], [], opts).probes[0]!;
+ expect(Array.from(a)).toEqual(Array.from(b));
+ });
+});
diff --git a/src/esengine/aot/EngineDigest.generated.h b/src/esengine/aot/EngineDigest.generated.h
index 9c9e3d3af..f9e4e1ed8 100644
--- a/src/esengine/aot/EngineDigest.generated.h
+++ b/src/esengine/aot/EngineDigest.generated.h
@@ -6,7 +6,7 @@
/* One per address width, because the width is IN the digest: a host that
took the other one would refuse every module built for it. */
-#define ES_ENGINE_ABI_DIGEST_32 0x9bb0ddbb653544d3ULL
-#define ES_ENGINE_ABI_DIGEST_64 0x30739b8914679e3fULL
+#define ES_ENGINE_ABI_DIGEST_32 0xf60a34c3f99ea969ULL
+#define ES_ENGINE_ABI_DIGEST_64 0x665de4cd0099166dULL
#define ES_ENGINE_ABI_DIGEST \
(sizeof(es_addr_t) == 8 ? ES_ENGINE_ABI_DIGEST_64 : ES_ENGINE_ABI_DIGEST_32)
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index e75fb0202..89b6b99a5 100644
--- a/src/esengine/bindings/EditorAPI.generated.cpp
+++ b/src/esengine/bindings/EditorAPI.generated.cpp
@@ -2,10 +2,10 @@
* @file EditorAPI.generated.cpp
* @brief Auto-generated editor API with string-dispatched component access
* @details Generated by EHT - DO NOT EDIT
- * @schema_hash 5ad35780ad9d857a
+ * @schema_hash b834e9c6d6843ea7
*/
-#define ES_EDITOR_API_SCHEMA_HASH "5ad35780ad9d857a"
+#define ES_EDITOR_API_SCHEMA_HASH "b834e9c6d6843ea7"
#include <emscripten/bind.h>
#include <string>
@@ -356,6 +356,7 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"halfExtents.x","type":"float","group":"LightProbeVolume"},
{"key":"halfExtents.y","type":"float","group":"LightProbeVolume"},
{"key":"halfExtents.z","type":"float","group":"LightProbeVolume"},
+ {"key":"spacing","type":"float","group":"LightProbeVolume"},
{"key":"enabled","type":"bool","group":"LightProbeVolume"}
])JSON";
} else if (name == "MeshCollider3D") {
@@ -1315,6 +1316,7 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s
if (field == "halfExtents.x") { c.halfExtents.x = value; }
else if (field == "halfExtents.y") { c.halfExtents.y = value; }
else if (field == "halfExtents.z") { c.halfExtents.z = value; }
+ else if (field == "spacing") { c.spacing = value; }
else { return false; }
return true;
} else if (comp == "MeshCollider3D") {
@@ -1816,6 +1818,7 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::st
if (field == "halfExtents.x") { return c.halfExtents.x; }
else if (field == "halfExtents.y") { return c.halfExtents.y; }
else if (field == "halfExtents.z") { return c.halfExtents.z; }
+ else if (field == "spacing") { return c.spacing; }
} else if (comp == "MeshCollider3D") {
if (!reg.has<esengine::ecs::MeshCollider3D>(entity)) return 0.0f;
const auto& c = reg.get<esengine::ecs::MeshCollider3D>(entity);
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index 657bace48..0f1e6d134 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -655,12 +655,14 @@ LightJS lightToJS(const esengine::ecs::Light& c) {
struct LightProbeVolumeJS {
u32 probes;
glm::vec3 halfExtents;
+ f32 spacing;
bool enabled;
};
void lightprobevolumeApplyJS(esengine::ecs::LightProbeVolume& c, const LightProbeVolumeJS& js) {
c.probes = resource::ProbeVolumeHandle(js.probes);
c.halfExtents = js.halfExtents;
+ c.spacing = js.spacing;
c.enabled = js.enabled;
}
@@ -674,6 +676,7 @@ LightProbeVolumeJS lightprobevolumeToJS(const esengine::ecs::LightProbeVolume& c
LightProbeVolumeJS js;
js.probes = c.probes.id();
js.halfExtents = c.halfExtents;
+ js.spacing = c.spacing;
js.enabled = c.enabled;
return js;
}
@@ -1687,6 +1690,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {
value_object<LightProbeVolumeJS>("LightProbeVolume")
.field("probes", &LightProbeVolumeJS::probes)
.field("halfExtents", &LightProbeVolumeJS::halfExtents)
+ .field("spacing", &LightProbeVolumeJS::spacing)
.field("enabled", &LightProbeVolumeJS::enabled);
value_object<MeshCollider3DJS>("MeshCollider3D")
@@ -3247,7 +3251,8 @@ static_assert(offsetof(esengine::ecs::Light, drawEnvironment) == 88, "ABI offset
static_assert(offsetof(esengine::ecs::Light, enabled) == 89, "ABI offset drift: esengine::ecs::Light.enabled (EHT expected 89)");
static_assert(offsetof(esengine::ecs::LightProbeVolume, probes) == 0, "ABI offset drift: esengine::ecs::LightProbeVolume.probes (EHT expected 0)");
static_assert(offsetof(esengine::ecs::LightProbeVolume, halfExtents) == 4, "ABI offset drift: esengine::ecs::LightProbeVolume.halfExtents (EHT expected 4)");
-static_assert(offsetof(esengine::ecs::LightProbeVolume, enabled) == 16, "ABI offset drift: esengine::ecs::LightProbeVolume.enabled (EHT expected 16)");
+static_assert(offsetof(esengine::ecs::LightProbeVolume, spacing) == 16, "ABI offset drift: esengine::ecs::LightProbeVolume.spacing (EHT expected 16)");
+static_assert(offsetof(esengine::ecs::LightProbeVolume, enabled) == 20, "ABI offset drift: esengine::ecs::LightProbeVolume.enabled (EHT expected 20)");
static_assert(offsetof(esengine::ecs::MeshCollider3D, mesh) == 0, "ABI offset drift: esengine::ecs::MeshCollider3D.mesh (EHT expected 0)");
static_assert(offsetof(esengine::ecs::MeshCollider3D, friction) == 4, "ABI offset drift: esengine::ecs::MeshCollider3D.friction (EHT expected 4)");
static_assert(offsetof(esengine::ecs::MeshCollider3D, restitution) == 8, "ABI offset drift: esengine::ecs::MeshCollider3D.restitution (EHT expected 8)");
@@ -3492,7 +3497,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "cccf3c7425936b84";
+static const char* kEsAbiLayoutHash = "bfed6926d0e50843";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/ecs/components/Light.hpp b/src/esengine/ecs/components/Light.hpp
index 521c53e48..57daf4f42 100644
--- a/src/esengine/ecs/components/Light.hpp
+++ b/src/esengine/ecs/components/Light.hpp
@@ -208,6 +208,12 @@ struct LightProbeVolume {
ES_PROPERTY(min=0, tooltip="Half the box this volume covers, from the entity's position.")
glm::vec3 halfExtents{100.0f, 100.0f, 100.0f};
+ /** @brief World units a bake puts between probes. What the BAKE reads — the
+ * grid it produced carries its own resolution, so changing this
+ * changes nothing until the next one. */
+ ES_PROPERTY(min=1, tooltip="World units between probes the next bake lays down.")
+ f32 spacing{100.0f};
+
/** @brief Disabled volumes are skipped during collection. */
ES_PROPERTY()
bool enabled{true};
diff --git a/tests/aot/generated/conformance/handshake.h b/tests/aot/generated/conformance/handshake.h
index 0d77274ee..3c41163de 100644
--- a/tests/aot/generated/conformance/handshake.h
+++ b/tests/aot/generated/conformance/handshake.h
@@ -1,5 +1,5 @@
/* GENERATED by sdk/tests/aot-conformance.test.ts — do not edit. */
/* The contract half of the handshake. The width half is the harness. */
-#define ES_CONF_EXPECTED_CONTRACT_HASH 0x30739b8914679e3fULL
+#define ES_CONF_EXPECTED_CONTRACT_HASH 0x665de4cd0099166dULL
/* And which BUILD the artifact beside this one is. */
#define ES_CONF_EXPECTED_MODULE_CONTRACT 0xc3d0e057d5701a2eULL
diff --git a/tests/aot/generated/conformance/systems_decl.c b/tests/aot/generated/conformance/systems_decl.c
index b40eb6ef4..02a3a844d 100644
--- a/tests/aot/generated/conformance/systems_decl.c
+++ b/tests/aot/generated/conformance/systems_decl.c
@@ -10,7 +10,7 @@
answer, it is a read of a different field. The address width belongs
to the MACHINE, so it mixes in here rather than in the compiler and a
32-bit artifact cannot load into a 64-bit host. */
-#define ES_ABI_ENGINE_DIGEST 0x30739b8914679e3fULL
+#define ES_ABI_ENGINE_DIGEST 0x665de4cd0099166dULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/aot/generated/move_system_decl.c b/tests/aot/generated/move_system_decl.c
index 17e3325a3..0eb96f783 100644
--- a/tests/aot/generated/move_system_decl.c
+++ b/tests/aot/generated/move_system_decl.c
@@ -10,7 +10,7 @@
answer, it is a read of a different field. The address width belongs
to the MACHINE, so it mixes in here rather than in the compiler and a
32-bit artifact cannot load into a 64-bit host. */
-#define ES_ABI_ENGINE_DIGEST 0x30739b8914679e3fULL
+#define ES_ABI_ENGINE_DIGEST 0x665de4cd0099166dULL
ES_EXPORT const uint64_t es_abi_hash =
ES_ABI_ENGINE_DIGEST ^ (0x9e3779b97f4a7c15ULL * (uint64_t)sizeof(es_addr_t));
diff --git a/tests/aot/generated/move_system_hash.h b/tests/aot/generated/move_system_hash.h
index f6e674722..e01c12816 100644
--- a/tests/aot/generated/move_system_hash.h
+++ b/tests/aot/generated/move_system_hash.h
@@ -1,6 +1,6 @@
/* GENERATED by @estella/compiler — do not edit. */
/* The contract half of the handshake. The width half is the harness. */
-#define ES_EXPECTED_CONTRACT_HASH 0x30739b8914679e3fULL
+#define ES_EXPECTED_CONTRACT_HASH 0x665de4cd0099166dULL
/* And which BUILD the artifact beside this one is, which the sidecar
written with it has to carry too. */
#define ES_EXPECTED_MODULE_CONTRACT 0x10bf77bb714ea1e3ULL
diff --git a/tools/assetMetaTable.js b/tools/assetMetaTable.js
index 09fd6331a..2ae9d4a67 100644
--- a/tools/assetMetaTable.js
+++ b/tools/assetMetaTable.js
@@ -79,6 +79,7 @@ export const EXT_TO_TYPE = Object.freeze({
'.aseprite': 'animated',
'.ase': 'animated',
'.esenv': 'environment',
+ '.esprobes': 'probeVolume',
'.esmesh': 'mesh',
'.esanim': 'animclip',
'.esanimclip': 'animclip',
diff --git a/tools/check-corpus-authoring.mjs b/tools/check-corpus-authoring.mjs
index 22122d476..7afd76361 100644
--- a/tools/check-corpus-authoring.mjs
+++ b/tools/check-corpus-authoring.mjs
@@ -68,6 +68,7 @@ const NOT_INSTANCE_FORMATS = {
'.esmaterial': 'a material: shader + uniform values',
'.esshader': 'shader source',
'.esenv': 'an environment: sky, ambient and the HDR behind them',
+ '.esprobes': 'a bake\'s answer at a grid of points: nine coefficients each',
'.estileset': 'a tileset: tiles, collision shapes and terrain rules',
'.eslocale': 'translated strings',
'.esbt': 'a behaviour tree',
@@ -119,7 +120,6 @@ const DISPOSITION = {
// — owed: a creator-facing component nothing in the shipped corpus authors.
// Each reason names where the coverage belongs. —
- LightProbeVolume: ['owed', 'the reading side is in and a grid written by hand falsifies it, but nothing SOLVES one yet; a corpus scene can carry a volume once a bake can fill it'],
};
diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjs
index 7892b5a84..98ed5c52d 100644
--- a/tools/goldenProjects.mjs
+++ b/tools/goldenProjects.mjs
@@ -70,6 +70,7 @@ export const NOT_EVIDENCE_FORMATS = {
'.hdr': 'an environment map; the .esenv referencing it is the claim',
'.gltf': 'an imported model; the .esmesh and prefab it produced are the claim',
'.esmesh': 'the import result, not an authored file — regenerated from the .gltf',
+ '.esprobes': 'a bake result; the LightProbeVolume naming it is the claim',
'.atlas': 'a Spine atlas, written by Spine',
'.skel': 'a Spine skeleton, written by Spine',
'.mp4': 'video content',
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 48bbc0b6d..283fef5ee 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,11 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'feat(render): a bake solves the probes in the light field it already has':
+ { note: 'A bake now solves the probes too, and refuses to light what moves.' },
+ 'feat(lighting): Bake Lighting solves the probes, and refuses to light what moves':
+ { note: 'A bake now solves the probes too, and refuses to light what moves.' },
+
'feat(render): a thing that moves takes the light of the room it is in':
{ note: 'Light probes: what lights a thing a bake cannot hold still.' },
'feat(lighting): a probe volume is a box a creator can see and place':