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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
perf(bake): the rays of a bake run in a C++ kernel on every core
esenginedbd918e69319
diff --git a/.gitignore b/.gitignoreindex 2c010e1ca..5c0f7e555 100644--- a/.gitignore+++ b/.gitignore@@ -88,6 +88,8 @@ pipeline/.hotupdate-verify/# emsdk and no FBX SDK. Source: tools/ufbx-wasm (third_party/ufbx);# provenance: build-tools/ufbx/README.md.!build-tools/ufbx/ufbx-load.wasm+# The lightmap bake kernel: a bake needs no emsdk. Source: tools/lightmap-wasm.+!build-tools/lightmap/lightmap-kernel.wasm# emsdk discovery cache (per-machine path written by build-tools auto-discovery).emsdk-pathdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex b28eb4249..5d5dde4e2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,7 +17,7 @@ published separately; it ships inside the editor.### Added- **Baked light is a lit surface's indirect light.** A lit renderer — every imported model's is — reads its patch of the atlas in place of the environment's diffuse light and a probe volume's, and keeps its lamps, shadows and reflections live. The bake holds the sky as it reaches each point past whatever stands in the way, plus what the surfaces around give off, over as many bounces as asked: under ORCA Bistro's awnings and in its side streets the sky is now mostly hidden, where before every point got all of it. Before, a model's material never read the atlas at all, and a mesh drawn without one added it on top of the sky and the lamps and was lit twice. The sky a bake gathers is the environment's own irradiance, turned and tinted as the frame reads it, so an open floor bakes to exactly what the frame would light it with. An atlas holds light up to eight times a flat ambient of one, where eight plain bits stopped at one. A cutout lets the share of rays that meets its holes through, both faces of a two-sided surface give off light, and a layer lying closer above a surface than half a lumel — a decal, a wet sheen — no longer walls it off from the sky. A scene baked before reads as stale: its atlas is in the old encoding and must be baked again.-- **A bake uses every core.** Each pass is split across a pool of worker threads, one per core but one, sharing the scene in shared memory; every lumel is solved on its own, so the atlas is byte for byte what one thread writes. ORCA Bistro — 1.2 million lumels, 2.8 million triangles — bakes in about five minutes on a 20-thread machine, where it took twenty-five to fifty-five. The editor and `bake-scene` both use it.+- **A bake uses every core, in C++.** The ray casting runs in a compiled kernel (`build-tools/lightmap`, built from `tools/lightmap-wasm`) on every core, with a tree built for tracing rather than for building quickly. Its rules are the TypeScript solve's, rounding included, and a gate holds the two to the same atlas bytes; any thread count writes the same bytes. ORCA Bistro — 1.2 million lumels, 2.8 million triangles — bakes in 81 s on a 20-thread machine, where a pool of worker threads took 312 s and one thread twenty-five to fifty-five minutes; the solve itself is 36 s of that. The editor and `bake-scene` both use it. Two triangles a ray meets at the same distance now go to the lower-numbered one, so the answer no longer depends on how a tree is built; physics-3d's committed bake moved by one step in two texels.- **A model whose second UV set cannot be baked into gets a lightmap UV in its place.** One that covers under 5% of its square pays for the empty rest — ORCA Bistro's road, 3533 m² in 0.5% of it, asked for more atlas than the rest of the town together — and one that lies on itself gives every copy the same texel's light: Bistro's curbs share one strip eighty layers deep, and a building's facades a hundred. Import unwraps either instead and says why; `import-model --lightmap-uv` turns generation on from the command line. A bake names a surface whose UVs overlap, and one that does not fit names the three surfaces taking the most room and how much of their square their UVs cover.### Fixeddiff --git a/build-tools/lightmap/README.md b/build-tools/lightmap/README.mdnew file mode 100644index 000000000..be5e1541d--- /dev/null+++ b/build-tools/lightmap/README.md@@ -0,0 +1,19 @@+# Lightmap bake kernel++`lightmap-kernel.{mjs,wasm}` — the ray casting a lightmap bake spends its time+in, as an emscripten build of `tools/lightmap-wasm/kernel.cpp` with threads.+Committed so baking needs **no emsdk**, the same pattern as `build-tools/ufbx/`.++`kernel.mjs` is what callers use (`pipeline/src/assets/lightmapKernel.ts` wraps+it as a `BakeExecutor`): it takes a scene's triangles and lumels once, then runs+the direct and gather passes over every lumel on every core.++The rules are `sdk/src/lightmap/solve.ts`'s, term for term, and+`pipeline/tests/lightmap-kernel.test.ts` holds the two to the same atlas bytes.+A change to the solve is a change to both.++## Rebuild++```+node tools/lightmap-wasm/build.mjs+```diff --git a/build-tools/lightmap/kernel.d.mts b/build-tools/lightmap/kernel.d.mtsnew file mode 100644index 000000000..5c7596147--- /dev/null+++ b/build-tools/lightmap/kernel.d.mts@@ -0,0 +1,16 @@+type F32 = Float32Array<ArrayBufferLike>;+export interface KernelScene {+ positions: F32; triCount: number;+ triUV: F32; triSurface: Int32Array<ArrayBufferLike>; patch: F32; albedo: F32;+ triNormal: F32; twoSided: Uint8Array<ArrayBufferLike>; coverage: F32; backReach: number;+ lumelPosition: F32; lumelNormal: F32; lumelCount: number;+}+export interface BakeKernel {+ /** Threads a pass runs on; any count gives the same answer. */+ threads: number;+ scene(s: KernelScene): void;+ direct(lights: Float64Array, lightCount: number, out: F32): void;+ gather(atlas: F32, atlasSize: number, samples: number, sky: Float64Array, out: F32): void;+ release(): void;+}+export function loadBakeKernel(): Promise<BakeKernel>;diff --git a/build-tools/lightmap/kernel.mjs b/build-tools/lightmap/kernel.mjsnew file mode 100644index 000000000..e6e6dd6c8--- /dev/null+++ b/build-tools/lightmap/kernel.mjs@@ -0,0 +1,77 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The lightmap bake kernel (lightmap-kernel.{mjs,wasm}, built by+ * tools/lightmap-wasm/build.mjs): uploads a scene once, then runs each+ * pass over every lumel on the kernel's own threads.+ */++let modulePromise = null;++export function loadBakeKernel() {+ modulePromise ??= import('./lightmap-kernel.mjs')+ .then(({ default: createModule }) => createModule())+ .then((m) => new BakeKernel(m));+ return modulePromise;+}++class BakeKernel {+ constructor(m) {+ this.m = m;+ this.held = [];+ this.lumels = null;+ /** Threads a pass runs on; any count gives the same answer. */+ this.threads = (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) || 8;+ }++ put(array) {+ const at = this.m._malloc(Math.max(4, array.byteLength));+ if (!at) throw new Error('lightmap kernel: out of memory');+ new Uint8Array(this.m.HEAPU8.buffer, at, array.byteLength)+ .set(new Uint8Array(array.buffer, array.byteOffset, array.byteLength));+ return at;+ }++ release() {+ for (const at of this.held) this.m._free(at);+ this.held = [];+ this.lumels = null;+ }++ /** Replaces the scene: triangles, their lookup, and the lumels every pass solves. */+ scene(s) {+ this.release();+ const hold = (a) => { const at = this.put(a); this.held.push(at); return at; };+ const pos = hold(s.positions), uv = hold(s.triUV), surf = hold(s.triSurface);+ const patch = hold(s.patch), albedo = hold(s.albedo), normal = hold(s.triNormal);+ const twoSided = hold(s.twoSided), coverage = hold(s.coverage);+ this.m._lm_scene(pos, s.triCount, uv, surf, patch, albedo, normal, twoSided, coverage,+ s.coverage.length, s.backReach);+ this.lumels = { position: hold(s.lumelPosition), normal: hold(s.lumelNormal), count: s.lumelCount };+ }++ pass(write, out) {+ const at = this.m._malloc(Math.max(4, out.byteLength));+ try {+ write(at);+ out.set(new Float32Array(this.m.HEAPU8.buffer, at, out.length));+ } finally {+ this.m._free(at);+ }+ }++ direct(lights, lightCount, out) {+ const L = this.lumels, lp = this.put(lights);+ try {+ this.pass((at) => this.m._lm_direct(L.position, L.normal, L.count, lp, lightCount, at, this.threads), out);+ } finally { this.m._free(lp); }+ }++ gather(atlas, atlasSize, samples, sky, out) {+ const L = this.lumels, ap = this.put(atlas), sp = this.put(sky);+ try {+ this.pass((at) => this.m._lm_gather(L.position, L.normal, L.count, ap, atlasSize, samples, sp, at,+ this.threads), out);+ } finally { this.m._free(ap); this.m._free(sp); }+ }+}diff --git a/build-tools/lightmap/lightmap-kernel.mjs b/build-tools/lightmap/lightmap-kernel.mjsnew file mode 100644index 000000000..a9977cf53--- /dev/null+++ b/build-tools/lightmap/lightmap-kernel.mjs@@ -0,0 +1,2 @@+async function Module(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&globalThis.name=="em-pthread";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url);var worker_threads=require("node:worker_threads");globalThis.Worker=worker_threads.Worker;ENVIRONMENT_IS_WORKER=!worker_threads.isMainThread;ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&worker_threads.workerData=="em-pthread"}var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}if(!ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var defaultPrint=console.log.bind(console);var defaultPrintErr=console.error.bind(console);if(ENVIRONMENT_IS_NODE){var utils=require("node:util");var stringify=a=>typeof a=="object"?utils.inspect(a):a;defaultPrint=(...args)=>fs.writeSync(1,args.map(stringify).join(" ")+"\n");defaultPrintErr=(...args)=>fs.writeSync(2,args.map(stringify).join(" ")+"\n")}var out=defaultPrint;var err=defaultPrintErr;var wasmBinary;var wasmModule;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");class EmscriptenEH{}class EmscriptenSjLj extends EmscriptenEH{}function growMemViews(){if(wasmMemory.buffer!=HEAP8.buffer){updateMemoryViews()}}var readyPromiseResolve,readyPromiseReject;if(ENVIRONMENT_IS_NODE&&ENVIRONMENT_IS_PTHREAD){globalThis.self=globalThis;var parentPort=worker_threads.parentPort;if(!globalThis.postMessage){parentPort.on("message",msg=>globalThis.onmessage?.({data:msg}));globalThis.postMessage=msg=>parentPort.postMessage(msg)}process.on("uncaughtException",err=>{postMessage({cmd:"uncaughtException",error:err});process.exit(1)})}var startWorker;if(ENVIRONMENT_IS_PTHREAD){var initializedJS=false;self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{var msgData=e["data"];var cmd=msgData.cmd;if(cmd==="load"){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);startWorker=()=>{postMessage({cmd:"loaded"});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};for(const handler of msgData.handlers){if(!Module[handler]||Module[handler].proxy){Module[handler]=(...args)=>{postMessage({cmd:"callHandler",handler,args})};if(handler=="print")out=Module[handler];if(handler=="printErr")err=Module[handler]}}wasmMemory=msgData.wasmMemory;updateMemoryViews();wasmModule=msgData.wasmModule;createWasm();run()}else if(cmd==="run"){establishStackSpace(msgData.pthread_ptr);__emscripten_thread_init(msgData.pthread_ptr,0,0,1,0,0);PThread.threadInitTLS();__emscripten_thread_mailbox_await(msgData.pthread_ptr);if(!initializedJS){initializedJS=true}try{invokeEntryPoint(msgData.start_routine,msgData.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(msgData.target==="setimmediate"){}else if(cmd==="checkMailbox"){if(initializedJS){checkMailbox()}}else if(cmd){err(`worker: received unknown command ${cmd}`);err(msgData)}}catch(ex){__emscripten_thread_crashed();throw ex}}self.onmessage=handleMessage}var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function initMemory(){if(ENVIRONMENT_IS_PTHREAD){return}if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:65536,shared:true})}updateMemoryViews()}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(ENVIRONMENT_IS_PTHREAD)return startWorker();wasmExports["p"]()}function postRun(){if(ENVIRONMENT_IS_PTHREAD){return}if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("lightmap-kernel.wasm")}return new URL("lightmap-kernel.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){assignWasmImports();var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;wasmExports=applySignatureConversions(wasmExports);registerTLSInit(wasmExports["u"]);assignWasmExports(wasmExports);wasmModule=module;return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"],result["module"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}if(ENVIRONMENT_IS_PTHREAD){var instance=new WebAssembly.Instance(wasmModule,getWasmImports());return receiveInstance(instance,wasmModule)}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var HEAP16;var HEAP32;var HEAP64;var HEAP8;var HEAPF32;var HEAPF64;var HEAPU16;var HEAPU32;var HEAPU64;var HEAPU8;var terminateWorker=worker=>{worker.terminate();worker.onmessage=e=>{}};var cleanupThread=pthread_ptr=>{var worker=PThread.pthreads[pthread_ptr];PThread.returnWorkerToPool(worker)};var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var runDependencies=0;var dependenciesFulfilled=null;var removeRunDependency=id=>{runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}};var addRunDependency=id=>{runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)};var spawnThread=threadParams=>{var worker=PThread.getNewWorker();if(!worker){return 6}PThread.runningWorkers.push(worker);PThread.pthreads[threadParams.pthread_ptr]=worker;worker.pthread_ptr=threadParams.pthread_ptr;var msg={cmd:"run",start_routine:threadParams.startRoutine,arg:threadParams.arg,pthread_ptr:threadParams.pthread_ptr};if(ENVIRONMENT_IS_NODE){worker.unref()}worker.postMessage(msg,threadParams.transferList);return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var stackSave=()=>_emscripten_stack_get_current();var stackRestore=val=>__emscripten_stack_restore(val);var stackAlloc=sz=>__emscripten_stack_alloc(sz);var proxyToMainThread=(funcIndex,emAsmAddr,proxyMode,...callArgs)=>{var bufSize=8*callArgs.length*2;var sp=stackSave();var args=stackAlloc(bufSize);var b=args>>>3;for(var arg of callArgs){if(typeof arg=="bigint"){(growMemViews(),HEAP64)[b++>>>0]=1n;(growMemViews(),HEAP64)[b++>>>0]=arg}else{(growMemViews(),HEAP64)[b++>>>0]=0n;(growMemViews(),HEAPF64)[b++>>>0]=arg}}var rtn=__emscripten_run_js_on_main_thread(funcIndex,emAsmAddr,bufSize,args,proxyMode);stackRestore(sp);return rtn};function _proc_exit(code){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(0,0,1,code);EXITSTATUS=code;if(!keepRuntimeAlive()){PThread.terminateAllThreads();Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))}function exitOnMainThread(returnCode){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(1,0,0,returnCode);_exit(returnCode)}var exitJS=(status,implicit)=>{EXITSTATUS=status;if(ENVIRONMENT_IS_PTHREAD){exitOnMainThread(status);throw"unwind"}_proc_exit(status)};var _exit=exitJS;var PThread={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){if(!ENVIRONMENT_IS_PTHREAD){PThread.initMainThread()}},initMainThread(){var pthreadPoolSize=typeof navigator!=="undefined"&&navigator.hardwareConcurrency||8;while(pthreadPoolSize--){PThread.allocateUnusedWorker()}addOnPreRun(async()=>{var pthreadPoolReady=PThread.loadWasmModuleToAllWorkers();addRunDependency("loading-workers");await pthreadPoolReady;removeRunDependency("loading-workers")})},terminateAllThreads:()=>{for(var worker of PThread.runningWorkers){terminateWorker(worker)}for(var worker of PThread.unusedWorkers){terminateWorker(worker)}PThread.unusedWorkers=[];PThread.runningWorkers=[];PThread.pthreads={}},returnWorkerToPool:worker=>{var pthread_ptr=worker.pthread_ptr;delete PThread.pthreads[pthread_ptr];PThread.unusedWorkers.push(worker);PThread.runningWorkers.splice(PThread.runningWorkers.indexOf(worker),1);worker.pthread_ptr=0;__emscripten_thread_free_data(pthread_ptr)},threadInitTLS(){PThread.tlsInitFunctions.forEach(f=>f())},loadWasmModuleToWorker:worker=>new Promise(onFinishedLoading=>{worker.onmessage=e=>{var d=e["data"];var cmd=d.cmd;if(d.targetThread&&d.targetThread!=_pthread_self()){var targetWorker=PThread.pthreads[d.targetThread];if(targetWorker){targetWorker.postMessage(d,d.transferList)}else{err(`Internal error! Worker sent a message "${cmd}" to target pthread ${d.targetThread}, but that thread no longer exists!`)}return}if(cmd==="checkMailbox"){checkMailbox()}else if(cmd==="spawnThread"){spawnThread(d)}else if(cmd==="cleanupThread"){callUserCallback(()=>cleanupThread(d.thread))}else if(cmd==="loaded"){worker.loaded=true;if(ENVIRONMENT_IS_NODE&&!worker.pthread_ptr){worker.unref()}onFinishedLoading(worker)}else if(d.target==="setimmediate"){worker.postMessage(d)}else if(cmd==="uncaughtException"){worker.onerror(d.error)}else if(cmd==="callHandler"){Module[d.handler](...d.args)}else if(cmd){err(`worker sent an unknown command ${cmd}`)}};worker.onerror=e=>{var message="worker sent an error!";err(`${message} ${e.filename}:${e.lineno}: ${e.message}`);throw e};if(ENVIRONMENT_IS_NODE){worker.on("message",data=>worker.onmessage({data}));worker.on("error",e=>worker.onerror(e))}var handlers=[];var knownHandlers=["onExit","onAbort","print","printErr"];for(var handler of knownHandlers){if(Module.propertyIsEnumerable(handler)){handlers.push(handler)}}worker.postMessage({cmd:"load",handlers,wasmMemory,wasmModule})}),async loadWasmModuleToAllWorkers(){if(ENVIRONMENT_IS_PTHREAD){return}let pthreadPoolReady=Promise.all(PThread.unusedWorkers.map(PThread.loadWasmModuleToWorker));return pthreadPoolReady},allocateUnusedWorker(){var worker;if(Module["mainScriptUrlOrBlob"]){var pthreadMainJs=Module["mainScriptUrlOrBlob"];if(typeof pthreadMainJs!="string"){pthreadMainJs=URL.createObjectURL(pthreadMainJs)}worker=new Worker(pthreadMainJs,{type:"module",workerData:"em-pthread",name:"em-pthread"})}else worker=new Worker(new URL("lightmap-kernel.mjs",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});PThread.unusedWorkers.push(worker)},getNewWorker(){if(PThread.unusedWorkers.length==0){PThread.allocateUnusedWorker();PThread.loadWasmModuleToWorker(PThread.unusedWorkers[0])}return PThread.unusedWorkers.pop()}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);function establishStackSpace(pthread_ptr){var stackHigh=(growMemViews(),HEAPU32)[pthread_ptr+48>>>2>>>0];var stackSize=(growMemViews(),HEAPU32)[pthread_ptr+52>>>2>>>0];var stackLow=stackHigh-stackSize;_emscripten_stack_set_limits(stackHigh,stackLow);stackRestore(stackHigh)}var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var invokeEntryPoint=(ptr,arg)=>{runtimeKeepaliveCounter=0;noExitRuntime=0;var result=getWasmTableEntry(ptr)(arg);function finish(result){if(keepRuntimeAlive()){EXITSTATUS=result;return}__emscripten_thread_exit(result)}finish(result)};var noExitRuntime=true;var registerTLSInit=tlsInitFunc=>PThread.tlsInitFunctions.push(tlsInitFunc);var wasmMemory;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){(growMemViews(),HEAPU32)[this.ptr+4>>>2>>>0]=type}get_type(){return(growMemViews(),HEAPU32)[this.ptr+4>>>2>>>0]}set_destructor(destructor){(growMemViews(),HEAPU32)[this.ptr+8>>>2>>>0]=destructor}get_destructor(){return(growMemViews(),HEAPU32)[this.ptr+8>>>2>>>0]}set_caught(caught){caught=caught?1:0;(growMemViews(),HEAP8)[this.ptr+12>>>0]=caught}get_caught(){return(growMemViews(),HEAP8)[this.ptr+12>>>0]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;(growMemViews(),HEAP8)[this.ptr+13>>>0]=rethrown}get_rethrown(){return(growMemViews(),HEAP8)[this.ptr+13>>>0]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){(growMemViews(),HEAPU32)[this.ptr+16>>>2>>>0]=adjustedPtr}get_adjusted_ptr(){return(growMemViews(),HEAPU32)[this.ptr+16>>>2>>>0]}}var uncaughtExceptionCount=0;function ___cxa_throw(ptr,type,destructor){ptr>>>=0;type>>>=0;destructor>>>=0;var info=new ExceptionInfo(ptr);info.init(type,destructor);uncaughtExceptionCount++;abort()}function pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(2,0,1,pthread_ptr,attr,startRoutine,arg);return ___pthread_create_js(pthread_ptr,attr,startRoutine,arg)}var _emscripten_has_threading_support=()=>!!globalThis.SharedArrayBuffer;function ___pthread_create_js(pthread_ptr,attr,startRoutine,arg){pthread_ptr>>>=0;attr>>>=0;startRoutine>>>=0;arg>>>=0;if(!_emscripten_has_threading_support()){return 6}var transferList=[];var error=0;if(ENVIRONMENT_IS_PTHREAD&&(transferList.length===0||error)){return pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg)}if(error)return error;var threadParams={startRoutine,pthread_ptr,arg,transferList};if(ENVIRONMENT_IS_PTHREAD){threadParams.cmd="spawnThread";postMessage(threadParams,transferList);return 0}return spawnThread(threadParams)}var __abort_js=()=>abort("");function __emscripten_init_main_thread_js(tb){tb>>>=0;__emscripten_thread_init(tb,!ENVIRONMENT_IS_WORKER,1,!ENVIRONMENT_IS_WEB,1048576,false);PThread.threadInitTLS()}var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var maybeExit=()=>{if(!keepRuntimeAlive()){try{if(ENVIRONMENT_IS_PTHREAD){if(_pthread_self())__emscripten_thread_exit(EXITSTATUS);return}_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};var waitAsyncPolyfilled=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function __emscripten_thread_mailbox_await(pthread_ptr){pthread_ptr>>>=0;if(!waitAsyncPolyfilled){var wait=Atomics.waitAsync((growMemViews(),HEAP32),pthread_ptr>>>2,pthread_ptr);wait.value.then(checkMailbox);var waitingAsync=pthread_ptr+120;Atomics.store((growMemViews(),HEAP32),waitingAsync>>>2,1)}}var checkMailbox=()=>callUserCallback(()=>{var pthread_ptr=_pthread_self();if(pthread_ptr){__emscripten_thread_mailbox_await(pthread_ptr);__emscripten_check_mailbox()}});function __emscripten_notify_mailbox_postmessage(targetThread,currThreadId){targetThread>>>=0;currThreadId>>>=0;if(targetThread==currThreadId){setTimeout(checkMailbox)}else if(ENVIRONMENT_IS_PTHREAD){postMessage({targetThread,cmd:"checkMailbox"})}else{var worker=PThread.pthreads[targetThread];if(!worker){return}worker.postMessage({cmd:"checkMailbox"})}}var proxiedJSCallArgs=[];function __emscripten_receive_on_main_thread_js(funcIndex,emAsmAddr,callingThread,bufSize,args,ctx,ctxArgs){emAsmAddr>>>=0;callingThread>>>=0;args>>>=0;ctx>>>=0;ctxArgs>>>=0;proxiedJSCallArgs.length=0;var b=args>>>3;var end=args+bufSize>>>3;while(b<end){var arg;if((growMemViews(),HEAP64)[b++>>>0]){arg=(growMemViews(),HEAP64)[b++>>>0]}else{arg=(growMemViews(),HEAPF64)[b++>>>0]}proxiedJSCallArgs.push(arg)}var func=proxiedFunctionTable[funcIndex];PThread.currentProxiedOperationCallerThread=callingThread;var rtn=func(...proxiedJSCallArgs);PThread.currentProxiedOperationCallerThread=0;if(ctx){rtn.then(rtn=>__emscripten_run_js_on_main_thread_done(ctx,ctxArgs,rtn));return}return rtn}function __emscripten_thread_cleanup(thread){thread>>>=0;if(!ENVIRONMENT_IS_PTHREAD)cleanupThread(thread);else postMessage({cmd:"cleanupThread",thread})}function __emscripten_thread_set_strongref(thread){thread>>>=0;if(ENVIRONMENT_IS_NODE){PThread.pthreads[thread].ref()}}var _emscripten_get_now=()=>performance.timeOrigin+performance.now();var _emscripten_check_blocking_allowed=()=>{};var runtimeKeepalivePush=()=>{runtimeKeepaliveCounter+=1};var _emscripten_exit_with_live_runtime=()=>{runtimeKeepalivePush();throw"unwind"};var getHeapMax=()=>4294901760;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};function _emscripten_resize_heap(requestedSize){requestedSize>>>=0;var oldSize=(growMemViews(),HEAPU8).length;if(requestedSize<=oldSize){return false}var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false}PThread.init();{initMemory();if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}var proxiedFunctionTable=[_proc_exit,exitOnMainThread,pthreadCreateProxied];var _lm_scene,_lm_direct,_lm_gather,__emscripten_tls_init,_pthread_self,__emscripten_thread_init,__emscripten_thread_crashed,__emscripten_run_js_on_main_thread_done,__emscripten_run_js_on_main_thread,__emscripten_thread_free_data,__emscripten_thread_exit,_malloc,_free,__emscripten_check_mailbox,_emscripten_stack_set_limits,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,__indirect_function_table,wasmTable;function assignWasmExports(wasmExports){_lm_scene=Module["_lm_scene"]=wasmExports["q"];_lm_direct=Module["_lm_direct"]=wasmExports["r"];_lm_gather=Module["_lm_gather"]=wasmExports["s"];__emscripten_tls_init=wasmExports["u"];_pthread_self=wasmExports["v"];__emscripten_thread_init=wasmExports["w"];__emscripten_thread_crashed=wasmExports["x"];__emscripten_run_js_on_main_thread_done=wasmExports["y"];__emscripten_run_js_on_main_thread=wasmExports["z"];__emscripten_thread_free_data=wasmExports["A"];__emscripten_thread_exit=wasmExports["B"];_malloc=Module["_malloc"]=wasmExports["C"];_free=Module["_free"]=wasmExports["D"];__emscripten_check_mailbox=wasmExports["E"];_emscripten_stack_set_limits=wasmExports["F"];__emscripten_stack_restore=wasmExports["G"];__emscripten_stack_alloc=wasmExports["H"];_emscripten_stack_get_current=wasmExports["I"];__indirect_function_table=wasmTable=wasmExports["t"]}var wasmImports;function assignWasmImports(){wasmImports={f:___cxa_throw,g:___pthread_create_js,l:__abort_js,k:__emscripten_init_main_thread_js,n:__emscripten_notify_mailbox_postmessage,c:__emscripten_receive_on_main_thread_js,b:__emscripten_thread_cleanup,j:__emscripten_thread_mailbox_await,i:__emscripten_thread_set_strongref,d:_emscripten_check_blocking_allowed,h:_emscripten_exit_with_live_runtime,e:_emscripten_get_now,m:_emscripten_resize_heap,o:_exit,a:wasmMemory}}function applySignatureConversions(wasmExports){wasmExports=Object.assign({},wasmExports);var makeWrapper_p=f=>()=>f()>>>0;var makeWrapper_pp=f=>a0=>f(a0)>>>0;wasmExports["v"]=makeWrapper_p(wasmExports["v"]);wasmExports["C"]=makeWrapper_pp(wasmExports["C"]);wasmExports["H"]=makeWrapper_pp(wasmExports["H"]);wasmExports["I"]=makeWrapper_p(wasmExports["I"]);return wasmExports}function run(){if(runDependencies>0){dependenciesFulfilled=run;return}if(ENVIRONMENT_IS_PTHREAD){readyPromiseResolve?.(Module);initRuntime();return}preRun();if(runDependencies>0){dependenciesFulfilled=run;return}function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;if(!ENVIRONMENT_IS_PTHREAD){wasmExports=await (createWasm());run()}if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}+;return moduleRtn}export default Module;var isPthread=globalThis.name=="em-pthread";var isNode=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(isNode)isPthread=(await import("node:worker_threads")).workerData==="em-pthread";isPthread&&Module();diff --git a/build-tools/lightmap/lightmap-kernel.wasm b/build-tools/lightmap/lightmap-kernel.wasmnew file mode 100755index 000000000..252d5c33fBinary files /dev/null and b/build-tools/lightmap/lightmap-kernel.wasm differdiff --git a/desktop b/desktopindex b7907bf2c..268f92b08 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit b7907bf2c6255bfa516e3e01bee8b86b775b564b+Subproject commit 268f92b0879c71b318c90c8b2f3fba9410c99019diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.jsonindex 8debc7474..bc8258117 100644--- a/docs/astro/src/data/apiStability.generated.json+++ b/docs/astro/src/data/apiStability.generated.json@@ -3,10 +3,10 @@"counts": {"public": 115,"beta": 103,- "experimental": 2138,+ "experimental": 2137,"deprecated": 3},- "total": 2356,+ "total": 2355,"subsystems": [{"id": "ecs",diff --git a/examples/physics-3d/assets/scenes/main_lightmap.png b/examples/physics-3d/assets/scenes/main_lightmap.pngindex bfda4bca8..a6015473e 100644Binary files a/examples/physics-3d/assets/scenes/main_lightmap.png and b/examples/physics-3d/assets/scenes/main_lightmap.png differdiff --git a/examples/physics-3d/assets/scenes/main_probes_50.esprobes b/examples/physics-3d/assets/scenes/main_probes_50.esprobesindex 44eceb732..f77bb4dbd 100644--- a/examples/physics-3d/assets/scenes/main_probes_50.esprobes+++ b/examples/physics-3d/assets/scenes/main_probes_50.esprobes@@ -1,5 +1,5 @@{"version": 1,"resolution": [7,3,5],- "irradiance": [0.787525,0.947183,1.21709,-0.0128871,-0.0145809,-0.0199165,-0.0216912,-0.024515,-0.0335227,-0.0226589,-0.0256378,-0.0350183,-0.00620364,-0.00699162,-0.00958744,-0.00623858,-0.00705768,-0.00964144,-0.00212922,-0.00240502,-0.00329061,-0.0105509,-0.0119378,-0.0163059,-0.00414027,-0.00468563,-0.00639859,0.738265,0.891448,1.14096,-0.0415297,-0.0469878,-0.0641822,-0.0613031,-0.0693331,-0.0947412,-0.00666444,-0.00754116,-0.0102996,-0.000164008,-0.000158209,-0.000253468,-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.729309,0.881314,1.12712,-0.0423377,-0.047902,-0.0654308,-0.0694891,-0.0785949,-0.107392,-0.00111113,-0.00125799,-0.00171721,0.000277233,0.000341024,0.000428451,-0.0223998,-0.0253429,-0.0346179,-0.012195,-0.0137937,-0.0188468,0.000610242,0.000690194,0.0009431,-0.00289992,-0.00328227,-0.00448168,0.730707,0.882808,1.12998,-0.0422219,-0.0477847,-0.0651816,-0.0681888,-0.0772125,-0.104719,-0.000105739,-0.000157315,0.00028999,0.000345285,0.000414414,0.000566514,-0.0223234,-0.0252667,-0.0344513,-0.0118302,-0.0134136,-0.0180826,0.00130522,0.00145183,0.00232894,-0.00266381,-0.0030229,-0.00401197,0.72871,0.880371,1.12656,-0.042488,-0.0481302,-0.0655913,-0.0700922,-0.0795621,-0.107909,-0.000917724,-0.00100318,-0.00141457,0.000312197,0.000387325,0.00048253,-0.0225097,-0.0255122,-0.034729,-0.0124137,-0.0141612,-0.0189932,0.000737173,0.000856444,0.00114404,-0.00293781,-0.0033316,-0.00454241,0.733278,0.885576,1.13353,-0.0419621,-0.047508,-0.0648129,-0.0656175,-0.0743816,-0.101206,0.00226046,0.00275908,0.0032482,0.00053198,0.000649137,0.000798054,-0.0221305,-0.0250547,-0.0341818,-0.0109466,-0.0123941,-0.016902,0.00285925,0.00334212,0.00428876,-0.00236481,-0.00274025,-0.00357782,0.790954,0.950547,1.22174,-0.00960914,-0.0109881,-0.0149956,-0.0201508,-0.0228443,-0.0312323,0.0199909,0.0231963,0.0316186,0.00565002,0.00651475,0.00885036,-0.00446563,-0.00506353,-0.0069162,-0.00271103,-0.00292566,-0.00401773,0.00975895,0.0111002,0.0151556,-0.00394222,-0.00468825,-0.00637588,0.800496,0.959563,1.21962,0.00644747,0.00821149,0.0191199,-0.0227969,-0.0271348,-0.0408284,-0.00119849,-0.00315642,-0.0193024,0.0000410554,0.000592982,0.00593914,0.00555783,0.0066437,0.011335,-0.0101426,-0.0114592,-0.0114748,-0.00493011,-0.00625899,-0.0121223,0.00339554,0.0034675,0.000937253,0.860872,1.01938,1.24144,-0.0272271,-0.0267536,0.00751207,0.0300581,0.0255765,-0.0176962,0.0249131,0.0250343,0.0119226,-0.00560587,-0.0056801,-0.00224833,-0.0138034,-0.0135731,0.00301913,0.00309019,0.00200364,-0.00302856,0.0108663,0.0109264,0.00605545,-0.00242788,-0.00338045,-0.00243578,0.862347,1.02182,1.23465,-0.032222,-0.0320372,0.00582751,0.0275115,0.0239823,-0.0242222,-0.00537432,-0.00596468,-0.00850571,0.00162083,0.00191538,0.00185963,-0.0150149,-0.0148549,0.00306737,0.00103919,0.000379351,-0.00421886,-0.00426092,-0.00476123,-0.00560804,-0.00292746,-0.00395755,-0.00509168,0.887573,1.04676,1.25702,-0.0338124,-0.0335401,0.00483102,0.0480382,0.0439146,-0.00574505,-0.0260572,-0.0260476,-0.0229879,0.00432752,0.00465832,0.00392746,-0.0157253,-0.0154292,0.00267342,0.00435309,0.00317731,-0.00130267,-0.0173181,-0.0175083,-0.0153057,0.00322475,0.00232248,0.00027055,0.860906,1.02005,1.24154,-0.0291718,-0.0285755,0.00781472,0.0279506,0.0234507,-0.0185362,0.00188072,0.00324124,0.00620576,0.000174752,0.000126676,-0.000234617,-0.0129673,-0.0123648,0.00479953,0.00152834,-0.000160204,-0.00367052,0.00047771,0.000930894,0.00146565,-0.00311592,-0.00372695,-0.00314301,0.852004,1.01337,1.24106,-0.028092,-0.0280754,0.00567179,0.0203721,0.0180982,-0.0200936,-0.00189919,-0.0004092,0.0121622,0.00259356,0.00257306,-0.000565682,-0.0127473,-0.0125429,0.00392074,-0.00138562,-0.00226723,-0.0055742,0.000623176,0.00136291,0.00549433,-0.00420041,-0.00468323,-0.00303971,0.837734,1.00022,1.25399,-0.010854,-0.0107294,0.00332394,0.0114334,0.0104304,-0.00919001,-0.012505,-0.0115858,0.00701943,0.00563716,0.00570465,-0.000606735,-0.0044717,-0.00430582,0.00227023,-0.000358693,-0.000615321,-0.00239543,-0.00414448,-0.00367089,0.00379254,0.00128062,0.000988999,-0.00141091,0.822954,0.98456,1.24419,-0.00418006,-0.00284488,0.0134422,-0.0037781,-0.00565253,-0.0174685,0.00797472,0.00737906,-0.00648878,-0.00309924,-0.00273474,0.0037775,0.00165075,0.00249459,0.0077429,-0.00530499,-0.00581176,-0.00421836,0.00191514,0.00155918,-0.00347616,0.0011147,0.00136022,0.00236154,0.854811,1.01673,1.25782,-0.0320514,-0.03118,0.00335539,0.0194942,0.0180646,-0.00380148,0.00193945,0.00160735,-0.00853064,-0.00106941,-0.00101542,0.00348796,-0.0111989,-0.0106035,0.00125953,-0.00180661,-0.00203874,0.000381528,0.000636795,0.000582873,-0.00366002,-0.00867818,-0.00885823,-0.00133129,0.854748,1.01285,1.24118,-0.0294058,-0.0267382,0.0158177,0.0187663,0.0150899,-0.016121,0.0037877,0.00201504,-0.0026555,0.00026282,0.00086454,0.00225308,-0.00986331,-0.00856418,0.00746947,-0.0021122,-0.00213927,-0.000844322,0.000703785,-0.0000406061,-0.00157516,-0.00617337,-0.00698879,0.00092101,0.850005,1.01014,1.24037,-0.0229792,-0.0207523,0.0206152,0.0138771,0.0111516,-0.0183881,-0.0118688,-0.0124227,-0.0110753,0.00446025,0.00486087,0.00406341,-0.00586924,-0.0045922,0.0106492,-0.00357584,-0.00387308,-0.00225576,-0.00634459,-0.00679376,-0.00606706,-0.00225405,-0.00214503,0.00526742,0.858125,1.017,1.24561,-0.0314373,-0.0289928,0.0131091,0.0220577,0.0184534,-0.0130407,-0.00115696,-0.00187198,0.0028731,0.0012198,0.00176116,0.0000877137,-0.0108612,-0.00939949,0.0066399,-0.00147662,-0.00191581,-0.000877415,-0.000365041,-0.00118455,0.0000259359,-0.00615863,-0.00655571,0.00113428,0.855363,1.01206,1.24357,-0.0289972,-0.0254601,0.0146203,0.0179333,0.0109861,-0.0171108,-0.011662,-0.0111853,0.00137112,0.00553361,0.00554909,0.000663614,-0.00865102,-0.00598065,0.00863058,-0.00282911,-0.00516589,-0.00314004,-0.0041978,-0.00399893,0.0000983545,-0.00523437,-0.00485754,0.00236351,0.835127,0.993163,1.24984,-0.0129033,-0.0100216,0.00941048,0.00532716,0.000906712,-0.0120507,-0.0109294,-0.0074001,0.00738052,0.00566315,0.00451564,-0.00230642,-0.00275675,-0.00105727,0.00556439,-0.00359931,-0.00425899,-0.00211841,-0.0026541,-0.000813324,0.0040823,-0.00100434,-0.0013968,0.000645681,0.729509,0.881399,1.12839,-0.0467424,-0.0530276,-0.0712735,-0.00356342,-0.00403267,-0.00531706,-0.0666252,-0.075459,-0.102446,-0.0236764,-0.0268164,-0.0362123,-0.000963635,-0.00110976,-0.00135106,0.00324216,0.00370843,0.00476489,-0.00185991,-0.00211556,-0.00279986,-0.00858882,-0.00968229,-0.0135223,0.563616,0.693843,0.871043,-0.163331,-0.184797,-0.252421,-0.00312799,-0.00351208,-0.00483417,-0.00570718,-0.00645809,-0.00882019,-0.000219454,-0.000220942,-0.000339157,-0.000316014,-0.000356715,-0.000488385,0.00451025,0.00510706,0.00697039,-0.00326112,-0.00368997,-0.00503991,0.00737592,0.0083441,0.0113992,0.558189,0.687495,0.862693,-0.164101,-0.185704,-0.253604,-0.00644702,-0.00727783,-0.00996171,-0.00282568,-0.00343343,-0.0043244,0.0000356534,0.0000384371,0.0000604703,-0.000642574,-0.000727317,-0.00099287,0.00451963,0.00517458,0.00697461,-0.00120126,-0.00136814,-0.00185493,0.00570266,0.00635639,0.00883024,0.556418,0.683723,0.864382,-0.167018,-0.190358,-0.256482,-0.00684113,-0.00744186,-0.0117001,0.00829701,0.00817313,0.0170444,0.000436146,-0.000050206,0.00175217,-0.000646604,-0.000608417,-0.00126299,0.00494531,0.00583923,0.00704142,-0.00328745,-0.00361991,-0.00571979,0.00743027,0.00840923,0.0127357,0.636202,0.773727,1.01852,-0.107938,-0.123673,-0.142421,-0.00873854,-0.00977028,-0.0150059,-0.000951478,-0.000963839,-0.00329603,-0.00020291,-0.000184486,-0.000601835,-0.00120158,-0.00134282,-0.00212771,0.00195993,0.00231153,0.00157805,-0.00225331,-0.00254749,-0.00354334,-0.000294205,-0.000213799,-0.00235455,0.564091,0.694089,0.872507,-0.163334,-0.18487,-0.25236,-0.0012593,-0.00141044,-0.00212137,0.0107621,0.0124973,0.0158129,0.00137096,0.00163216,0.0020655,-0.00027098,-0.000307812,-0.000428955,0.00526789,0.00603849,0.00796702,0.000554288,0.000638355,0.0009992,0.00712257,0.00793546,0.0113389,0.752697,0.907175,1.15645,-0.0276135,-0.0316344,-0.0483254,0.00192,0.00228869,0.00374418,0.0567952,0.0647225,0.0922712,0.0168116,0.0192403,0.0286925,0.0010311,0.00120527,0.00212307,0.00454369,0.00524966,0.0080726,-0.000970871,-0.0011425,-0.00170238,-0.0131332,-0.014885,-0.0196908,0.674555,0.815024,1.06506,0.0495696,0.0574047,0.0732287,-0.0217849,-0.0252712,-0.0300659,-0.109856,-0.127845,-0.149824,0.0207393,0.024107,0.0302933,0.00523577,0.00607406,0.00741895,0.00786213,0.00923883,0.0105487,-0.00607644,-0.00709569,-0.00812058,-0.017887,-0.0209324,-0.0222696,0.883645,1.02887,1.18098,-0.0687556,-0.0645631,0.0285511,-0.00472256,-0.0086901,-0.0175563,0.0315105,0.0440019,0.0323728,-0.00759729,-0.00888225,-0.000519995,0.00213982,0.00294328,0.00454949,-0.00197669,-0.000520843,0.00709915,-0.0013919,-0.00101487,-0.000851769,-0.0218369,-0.0258815,-0.0138033,0.907239,1.06138,1.19687,-0.0800625,-0.07853,0.0266419,0.0165289,0.0157453,0.00154129,-0.0129637,-0.013242,-0.0172969,0.00336094,0.00362366,0.0040498,-0.00483681,-0.00475794,-0.00076464,-0.000344163,0.00136025,0.0108934,0.0100496,0.0123107,0.0101821,-0.020391,-0.0238571,-0.0132019,0.907376,1.05137,1.17719,-0.0804518,-0.0781026,0.0239283,0.023123,0.0225669,0.00663528,0.0237665,0.0291194,0.0300844,-0.00309608,-0.00190891,0.00191971,-0.00595762,-0.0047675,0.00200444,-0.00408008,-0.00326378,0.00687755,-0.00984809,-0.0158576,-0.0181096,-0.015417,-0.0191261,-0.0114021,0.945701,1.09109,1.23362,-0.100326,-0.0909014,0.00615767,-0.00416688,-0.0180981,-0.0337721,-0.0276966,-0.0312386,-0.0254468,0.0131775,0.0139419,0.0141744,0.00464837,0.00932008,0.013409,-0.0127293,-0.0151936,-0.00774469,-0.00591713,-0.00906822,-0.0100239,-0.0155294,-0.0153867,-0.0090672,0.906879,1.05085,1.19708,-0.062004,-0.0531223,0.0456706,-0.0158392,-0.0346743,-0.0475549,-0.022752,-0.0204167,0.00330638,0.00812736,0.00758809,0.00169503,0.0150287,0.0212744,0.0228566,-0.00779971,-0.0128522,-0.00553231,-0.000440279,0.000438956,0.000803565,-0.00499292,-0.00493047,0.00686839,0.850225,1.009,1.23215,-0.0235832,-0.021935,0.0143697,-0.0109869,-0.015063,-0.0187087,-0.0204032,-0.016588,0.0267149,0.0106351,0.00983894,-0.00739616,0.0036441,0.00480044,0.00563833,-0.00439115,-0.0047902,0.000498097,0.00771721,0.00980612,0.0104849,-0.00122416,-0.00214435,-0.00552289,0.835614,0.990697,1.24577,0.00267216,0.00883513,0.026658,0.00970429,0.00788269,0.00289505,0.0315913,0.0258439,0.00453388,-0.0088642,-0.00647811,0.00221516,-0.00325456,-0.00244938,-0.000923271,-0.00473516,-0.00319338,0.00157928,0.00773767,0.0068118,0.0039396,0.0173337,0.0175205,0.0156406,0.897277,1.05733,1.27082,-0.0664869,-0.0632194,-0.00351023,0.0150228,0.0143071,-0.000950169,0.0152068,0.0176642,-0.00928711,-0.00605199,-0.00747242,0.0058794,-0.00718409,-0.00682732,0.000740639,-0.00991774,-0.00963938,-0.000363748,0.00371928,0.00398372,-0.000491779,-0.0122695,-0.011494,0.000741346,0.893818,1.04904,1.24355,-0.0623718,-0.0576028,0.0176422,0.0242595,0.0223354,-0.00073703,0.019934,0.0166169,0.00566039,-0.00684755,-0.00559846,-0.00158721,-0.0122168,-0.0117057,-0.000351845,-0.00883122,-0.00729283,0.00336766,0.00486114,0.00409776,0.00140844,-0.0111979,-0.0127808,0.00215107,0.89989,1.05486,1.2508,-0.0650871,-0.0589376,0.0149052,0.0274111,0.0256949,0.00152978,0.00134054,0.000273788,-0.00188826,-0.00101401,-0.000228786,0.00134506,-0.0127588,-0.0120977,0.0000316478,-0.0077634,-0.00597146,0.00376577,-0.00180545,-0.00291932,-0.00194784,-0.0102449,-0.0106832,0.00359494,0.891089,1.04077,1.23957,-0.0644468,-0.0539001,0.0179448,0.0191815,0.0113632,-0.0109827,-0.00604571,-0.00818229,0.000133488,0.00552859,0.00721193,0.00385779,-0.00827134,-0.00397203,0.00663589,-0.00693874,-0.0062848,0.00284972,-0.00143038,-0.00321433,-0.00155977,-0.0164026,-0.0150354,-0.000257323,0.897824,1.04435,1.24926,-0.0661393,-0.0514124,0.0156781,0.0252964,0.013644,-0.00541746,-0.0181562,-0.0168054,0.00339956,0.00818124,0.00739884,-0.00154772,-0.0126079,-0.00551676,0.00396355,-0.0067891,-0.00698848,0.00242829,-0.00281226,-0.00236104,0.000651695,-0.0132002,-0.00932617,0.00474064,0.864498,1.02013,1.25347,-0.0350887,-0.0293282,0.00977904,0.0141562,0.0101815,-0.00134962,-0.027682,-0.0221626,0.00624837,0.0149575,0.0124329,-0.00184987,-0.00643677,-0.00423086,0.00110793,-0.00483917,-0.0039824,0.00262238,-0.00559888,-0.00378335,0.000736385,-0.00317166,-0.00309039,0.00158832,0.72053,0.871234,1.11451,-0.0475521,-0.0539442,-0.072525,0.00408972,0.00462909,0.0065097,-0.0718517,-0.0813773,-0.110522,-0.0239441,-0.0271195,-0.0366261,-0.000412469,-0.000486045,-0.000499316,0.00119227,0.00138952,0.00159679,0.000590996,0.000659491,0.00098732,-0.0102455,-0.0115585,-0.0160822,0.554043,0.682762,0.856505,-0.164178,-0.185771,-0.253713,0.00486246,0.00567046,0.00736907,-0.0115287,-0.0132953,-0.0175601,-0.000514353,-0.000566084,-0.00078312,0.000250663,0.000290947,0.000380709,0.00250558,0.00285799,0.00385269,-0.000564506,-0.000535575,-0.000978515,0.00550317,0.00613435,0.00859816,0.549883,0.678136,0.850139,-0.164764,-0.186429,-0.254615,0.00141022,0.00171929,0.00199814,-0.00725001,-0.00837437,-0.0108846,-0.000110668,-0.000105685,-0.00015636,-0.0000790722,-0.0000841975,-0.000130516,0.00223036,0.00254053,0.00342256,0.00140334,0.00165797,0.00203674,0.00437827,0.00489055,0.00688251,0.545507,0.673312,0.843066,-0.16514,-0.186851,-0.255215,0.00259318,0.00300347,0.00399883,-0.00201245,-0.00229686,-0.00310629,0.000187179,0.000236477,0.00028981,0.00000358028,0.00000971133,0.00000454124,0.00320082,0.0036102,0.00494995,0.000395478,0.000459861,0.000608633,0.00243025,0.00274446,0.00375662,0.549686,0.677862,0.849849,-0.164907,-0.186611,-0.254816,0.000379343,0.000699523,0.000208761,0.0026304,0.00297089,0.00411154,0.000416818,0.0004999,0.000647846,-0.000073289,-0.0000576319,-0.000146185,0.00271013,0.00296216,0.00436443,-0.00154956,-0.0017457,-0.00243399,0.00405615,0.00458275,0.00627093,0.559088,0.68871,0.864048,-0.163703,-0.18522,-0.252995,0.00439774,0.00501152,0.00679482,0.0106475,0.0120547,0.0164536,0.0011909,0.00137585,0.00184028,0.000204575,0.000233385,0.00031595,0.00295751,0.00334878,0.00457098,0.000687408,0.000772403,0.00106334,0.00682936,0.00772332,0.0105549,0.751503,0.905845,1.15286,-0.0280399,-0.0321359,-0.049435,0.00376431,0.00446702,0.00848615,0.0565171,0.0642827,0.0922848,0.0168516,0.0192819,0.0288335,0.00140286,0.00164789,0.0030558,0.00351562,0.00399884,0.00566869,-0.00118207,-0.00137462,-0.00235897,-0.0128373,-0.0144879,-0.0192414,0.66063,0.79867,1.04636,0.0520614,0.0603918,0.0766293,0.000309106,0.000561037,-0.000549619,-0.118535,-0.138012,-0.161404,0.0214998,0.02502,0.0313314,0.0032567,0.00372724,0.00471288,0.00451941,0.0053238,0.00602131,0.00160138,0.00187596,0.00211849,-0.019328,-0.0226004,-0.0241777,0.901682,1.04255,1.18406,-0.0729347,-0.0679661,0.0281205,-0.0202856,-0.0190296,-0.024125,0.0699396,0.083158,0.0682688,-0.0164766,-0.0181859,-0.00828854,-0.00147166,-0.00247361,-0.00135847,-0.0041447,-0.00394999,0.00313747,-0.00896078,-0.00812438,-0.00698926,-0.0131327,-0.0172831,-0.00646912,0.990061,1.14265,1.25808,-0.111902,-0.111374,0.00290989,-0.0308005,-0.0284522,-0.0265959,0.00582065,0.00684885,0.000664505,0.000419867,0.00016726,0.00180014,0.00490472,0.00455237,0.00469164,0.000366145,0.00167465,0.0102863,0.0166698,0.0166131,0.0180572,-0.00823976,-0.0130583,-0.00495064,0.943573,1.09414,1.21643,-0.0947451,-0.0915653,0.0202458,0.0043863,0.00928277,0.00543029,-0.014825,-0.0220501,-0.0135414,0.00827789,0.0116342,0.00981804,-0.000973897,-0.00174748,0.0000374596,-0.00336134,-0.00187574,0.007284,-0.00421494,-0.00376261,-0.00375973,-0.0145979,-0.0189429,-0.0100142,0.972634,1.07035,1.19206,-0.124936,-0.0710252,0.0417408,0.007824,0.00780756,0.00503326,-0.0201057,-0.0377616,-0.0298938,0.00939806,0.0177267,0.0158437,-0.00233799,-0.001708,-0.000648919,-0.00822116,-0.0000422503,0.00904504,-0.00194945,-0.00304774,-0.00209683,-0.0257499,-0.0157093,-0.00658655,1.05129,1.10191,1.22323,-0.170331,-0.0868376,0.0273426,-0.00287092,-0.00350229,-0.00514177,-0.00809702,-0.00656597,0.00591739,0.0019855,0.00180736,-0.000180869,0.00073405,0.00088698,0.00121845,-0.0134095,-0.00808421,0.000651789,0.00182268,0.00184729,0.0022726,-0.018125,-0.00809017,0.00159568,0.862763,1.00886,1.22881,-0.024228,-0.0155968,0.0219945,0.00382506,0.00298547,0.000687828,-0.0294917,-0.0132699,0.0303524,0.0104741,0.0050025,-0.0123166,-0.000802806,-0.000633561,-0.0000459908,-0.00133061,0.00134647,0.00476874,-0.00184388,-0.0012597,-0.000186928,0.00233692,-0.00140631,-0.00428852,0.802521,0.958427,1.21189,0.0205159,0.027303,0.0472672,-0.00178062,-0.00166739,0.00197414,0.00595894,0.00277929,-0.0186006,0.000122737,0.00209146,0.0114092,-0.000538009,-0.000778108,-0.00251629,-0.00153099,-0.001043,0.00388987,-0.00259544,-0.00280476,-0.00117317,0.0128127,0.0145347,0.0134559,0.906121,1.06256,1.26429,-0.0711656,-0.0659347,0.00197067,-0.00304482,-0.00267679,-0.000916967,0.0144888,0.0139549,-0.0178877,-0.00584743,-0.00632783,0.00891249,-0.000840375,-0.001209,-0.00150472,-0.00798643,-0.00683063,0.00201908,-0.00154967,-0.00175663,-0.000424638,-0.0112418,-0.0111436,0.0019956,0.884456,1.04204,1.22441,-0.0625293,-0.0590826,0.0277547,-0.00185613,-0.00161064,-0.0000341217,0.0115326,0.0129746,0.00167224,-0.00583183,-0.00657611,-0.00132104,0.00142831,0.00138734,0.00076902,-0.00492418,-0.00364262,0.00746482,0.00144822,0.00171487,0.00245783,-0.0197727,-0.0211083,-0.00301472,0.914182,1.0612,1.23896,-0.0817305,-0.0702737,0.0194391,-0.00580651,-0.00663656,-0.00507419,0.0149053,0.00789325,-0.00027896,-0.0066067,-0.00221568,0.00138809,0.00397613,0.00438478,0.00392274,-0.0103475,-0.00623911,0.00646839,0.00414444,0.00409898,0.00484666,-0.0169186,-0.0184488,-0.00145611,0.917067,1.06043,1.23843,-0.0875737,-0.0686188,0.0215283,-0.00204304,0.000132502,0.0018192,-0.000783758,-0.00637015,0.00198096,0.00120953,0.00557808,0.00247258,0.00186261,0.000815349,0.000279357,-0.0122771,-0.0072431,0.00504682,-0.00190066,-0.00201501,-0.00208546,-0.0195898,-0.0154384,0.0024093,0.910365,1.04953,1.2478,-0.0873899,-0.0615893,0.0133217,0.00312886,0.00357486,-0.00111202,-0.0141456,-0.0111574,0.00910365,0.00926027,0.0075215,-0.00243689,-0.0017166,-0.00199289,0.000536269,-0.0123376,-0.00654627,0.00384822,0.00181522,0.00192011,0.00116866,-0.0249044,-0.0163138,0.000630049,0.864366,1.01498,1.24443,-0.0370838,-0.0260347,0.016537,0.00263942,0.00230974,0.00331259,-0.0276957,-0.0187866,0.0125181,0.0162517,0.0113767,-0.00445214,-0.00119605,-0.000814109,-0.00117436,-0.00625245,-0.00308726,0.00486233,-0.00186455,-0.00177291,-0.00147649,-0.00403675,-0.00280263,0.0019797,0.725074,0.876382,1.12152,-0.0470635,-0.0533894,-0.0717842,0.00832833,0.00942228,0.0130582,-0.0688837,-0.0780135,-0.105944,-0.0237157,-0.0268603,-0.0362788,-0.000101161,-0.000133728,-0.0000202226,0.00245645,0.00281908,0.00355428,0.00259516,0.00292515,0.00408413,-0.00957207,-0.0107951,-0.0150382,0.563616,0.693843,0.871043,-0.162846,-0.184249,-0.251671,0.0138529,0.0157006,0.0214091,-0.00780275,-0.00882908,-0.0120588,-0.000249881,-0.000255367,-0.000386179,0.00124164,0.00140566,0.0019189,0.00613283,0.00694291,0.00947802,0.00134433,0.00152077,0.0020776,0.00634808,0.00718118,0.00981068,0.559137,0.688776,0.864122,-0.163452,-0.184934,-0.252608,0.0105819,0.0119997,0.0163539,-0.00384389,-0.00434991,-0.00594055,0.000139135,0.000184776,0.000215026,0.000920217,0.00104199,0.00142215,0.00588196,0.00665907,0.00909031,0.0034442,0.00389662,0.00532286,0.00510713,0.00577713,0.00789285,0.554659,0.68371,0.857201,-0.163816,-0.185346,-0.25317,0.0117386,0.0133084,0.0181414,0.00118296,0.00133761,0.00182821,0.000435512,0.000520105,0.000673063,0.000988412,0.00111915,0.00152755,0.00694578,0.0078627,0.0107344,0.00250135,0.00282985,0.00386572,0.00306904,0.00347117,0.00474305,0.559137,0.688776,0.864122,-0.163533,-0.185026,-0.252733,0.0091934,0.0104287,0.014208,0.00567532,0.0064204,0.00877095,0.000641517,0.000753186,0.000991435,0.000871698,0.000987097,0.00134717,0.00660381,0.00747579,0.0102059,0.000647237,0.000732052,0.00100028,0.00469885,0.00531518,0.00726185,0.563616,0.693843,0.871043,-0.162846,-0.184249,-0.251671,0.00945511,0.0107248,0.0146124,0.0107938,0.0122116,0.0166814,0.00121155,0.00139813,0.00187239,0.000900844,0.00102007,0.00139221,0.00536173,0.00607046,0.00828631,0.000864462,0.000977826,0.00133599,0.00678481,0.00767531,0.0104856,0.751528,0.905878,1.15289,-0.0280379,-0.0321332,-0.049432,0.00375796,0.00445846,0.00847661,0.0564895,0.0642455,0.0922434,0.01685,0.0192797,0.0288311,0.00140249,0.00164738,0.00305523,0.00350978,0.00399097,0.00565992,-0.00117689,-0.00136764,-0.0023512,-0.0128261,-0.0144728,-0.0192246,0.695336,0.837426,1.08271,0.0308742,0.0368234,0.055224,0.033174,0.0375408,0.03591,-0.104026,-0.121797,-0.147061,0.0146549,0.0173656,0.0244975,-0.00727788,-0.00791685,-0.0056617,0.0120507,0.0138782,0.0153342,0.0123751,0.0140502,0.0137217,-0.0211581,-0.0245563,-0.0257718,0.877124,1.02161,1.16481,-0.0684846,-0.0650189,0.0251456,0.0096301,0.0138409,0.0262876,0.0485916,0.0610279,0.0370116,-0.0156082,-0.0177392,-0.00665419,-0.00264647,-0.00342661,-0.00611495,-0.00461286,-0.00314202,0.00624165,-0.00277253,-0.00332328,-0.00339605,-0.0155121,-0.0190861,-0.0101088,0.91486,1.06989,1.19793,-0.0851337,-0.0845644,0.02115,0.00901208,0.0133143,0.0266004,0.0243628,0.0268754,0.0128542,-0.00675792,-0.00750487,-0.00502111,-0.00406886,-0.00512902,-0.00839534,-0.00918973,-0.00858381,0.00302648,-0.00125849,-0.00137378,-0.00105449,-0.0148914,-0.0178989,-0.0092571,0.953136,1.11033,1.23406,-0.100694,-0.100172,0.0110752,-0.00527114,0.00022744,0.0167638,-0.00209644,-0.00622579,-0.0071255,0.00177008,0.00338115,0.00390325,0.00156287,0.000339934,-0.00361396,-0.0105916,-0.0105381,0.00081086,0.00647031,0.00883374,0.00597584,-0.0110174,-0.0137496,-0.00613509,0.988172,1.13728,1.26008,-0.10505,-0.0991978,0.0128321,-0.0331341,-0.0200358,0.00112783,-0.0304282,-0.036114,-0.0342535,0.00351721,0.00552477,0.00567639,0.00506319,0.000445131,-0.00444959,-0.00806675,-0.0101662,-0.000817681,0.0154816,0.0185283,0.0166877,-0.00251635,-0.00405367,0.00490305,0.944056,1.0922,1.23312,-0.0922936,-0.085015,0.0200408,-0.00899499,0.00706017,0.0239636,-0.0218138,-0.020836,-0.0000722143,0.00646877,0.00612676,0.000582521,0.000420311,-0.0051952,-0.00955475,-0.00840949,-0.012898,-0.00487024,0.00369612,0.00322544,0.000808726,-0.0113631,-0.0111548,0.00235255,0.863897,1.01873,1.2434,-0.0286589,-0.025542,0.00994951,-0.000115797,0.00755906,0.0158063,-0.0341589,-0.0281363,0.0146362,0.0148235,0.0134276,-0.00398204,-0.000603064,-0.00265636,-0.00475719,-0.00596523,-0.00733859,-0.00198121,0.000324777,-0.00308022,-0.00625096,0.00221806,0.000978004,-0.00230261,0.801064,0.957013,1.21371,0.0132136,0.0188958,0.0376622,0.0150169,0.0176719,0.0223798,-0.00692051,-0.0115019,-0.0294645,0.00280356,0.00492909,0.0129876,-0.00717696,-0.00834586,-0.0102222,0.000731553,0.00150048,0.00619813,0.00493368,0.00584414,0.00767243,0.0032895,0.00385793,0.00393073,0.912074,1.06857,1.28606,-0.0740565,-0.0690693,-0.0141793,-0.0413218,-0.0378098,-0.0217234,0.00544679,0.00495039,-0.0205431,-0.00240233,-0.00283428,0.00943565,0.0201095,0.0186916,0.0112198,0.000743638,0.00105727,0.0094167,0.000666506,0.00151681,0.00513208,-0.0151773,-0.0148513,-0.0043675,0.882884,1.03664,1.22645,-0.0514453,-0.0466198,0.0287866,-0.017649,-0.012954,0.0117156,0.0238189,0.0218652,0.00744775,-0.0111645,-0.0110208,-0.00535929,0.00724667,0.00571634,-0.00556024,-0.00638765,-0.00551473,0.00465982,-0.00572083,-0.00474701,-0.0031946,-0.00840912,-0.0101784,0.00221703,0.898186,1.05494,1.24645,-0.0676156,-0.0636747,0.0138878,-0.0196475,-0.0159528,0.00729721,0.0111818,0.010212,0.0084344,-0.00548298,-0.0045947,-0.0033445,0.0101634,0.00850275,-0.00293877,-0.00833373,-0.007559,0.00328909,-0.00347703,-0.00241568,-0.00224135,-0.0137342,-0.0147847,0.0000587122,0.907059,1.05847,1.25414,-0.0762591,-0.0665889,0.00853857,-0.0276272,-0.0183533,0.00593633,-0.00724954,-0.010019,0.00190714,0.00335538,0.00531336,0.000513299,0.0142605,0.00904357,-0.0027387,-0.00812971,-0.00883234,0.00100745,0.000631304,0.00193804,-0.000464372,-0.0170317,-0.0148846,0.00101726,0.899372,1.0509,1.25916,-0.0674725,-0.0572437,0.00680962,-0.0241002,-0.0154133,0.00027373,-0.0251604,-0.023038,-0.000284962,0.012646,0.0117727,0.0014574,0.011997,0.00680489,-0.000699143,-0.00670065,-0.00692882,0.0030167,0.00567654,0.00459235,0.00132002,-0.0140124,-0.0113872,0.0017522,0.870105,1.02548,1.2561,-0.0366427,-0.0309832,0.00887319,-0.0159666,-0.0109508,0.00201017,-0.0336542,-0.0283596,0.00338349,0.0163688,0.0140592,-0.00116871,0.00749481,0.00503139,-0.00104936,-0.00555684,-0.00525644,0.0019108,0.0065933,0.00451922,-0.0000765998,-0.00108742,-0.000951656,0.00253503,0.789868,0.949537,1.21631,-0.00911252,-0.0104758,-0.0165453,0.0241234,0.0274545,0.0392661,-0.0181919,-0.0208268,-0.0317287,-0.00366167,-0.00420053,-0.00692165,0.00528928,0.00604637,0.00908243,-0.00492692,-0.00552825,-0.00698758,0.0095642,0.0108941,0.0158683,-0.00355553,-0.00406198,-0.00605875,0.758728,0.913711,1.15937,-0.022514,-0.0260741,-0.0437304,0.0507225,0.0579777,0.0867384,-0.00370833,-0.00425517,-0.00660255,0.0000729396,0.000111922,0.000143064,0.013602,0.0156822,0.025356,-0.0112788,-0.0127476,-0.0172895,0.00181162,0.00204164,0.00268343,-0.00490572,-0.00552338,-0.00716079,0.758728,0.913711,1.15937,-0.022514,-0.0260741,-0.0437304,0.0507225,0.0579777,0.0867384,-0.00370833,-0.00425517,-0.00660255,0.0000729396,0.000111922,0.000143064,0.013602,0.0156822,0.025356,-0.0112788,-0.0127476,-0.0172895,0.00181162,0.00204164,0.00268343,-0.00490572,-0.00552338,-0.00716079,0.75425,0.908644,1.15245,-0.0228776,-0.0264855,-0.0442923,0.0518791,0.0592863,0.0885259,0.00131852,0.00143235,0.00116621,0.000369316,0.000447251,0.000601101,0.0136702,0.0157593,0.0254614,-0.010215,-0.011544,-0.0156455,0.000868765,0.000974867,0.0012263,-0.00694381,-0.00782933,-0.0103106,0.758728,0.913711,1.15937,-0.0225948,-0.0261656,-0.0438552,0.0493339,0.0564066,0.0845925,0.00581088,0.00651513,0.00810895,0.000575321,0.000680332,0.000919473,0.0135535,0.0156273,0.025281,-0.010557,-0.0119309,-0.016174,-0.000985346,-0.00112293,-0.00163915,-0.00531401,-0.00598533,-0.00779178,0.755849,0.91041,1.15562,-0.0226727,-0.0262549,-0.0439569,0.0523576,0.0598737,0.0885384,0.00719001,0.00809654,0.00990879,0.000602426,0.000711411,0.000954845,0.0136129,0.0156954,0.0253585,-0.0117495,-0.0132983,-0.0177302,-0.00203722,-0.00232907,-0.00301189,-0.00555313,-0.00625952,-0.00810385,0.796241,0.956665,1.22493,-0.0068611,-0.00796482,-0.0136065,0.0152788,0.0176076,0.027977,0.0179561,0.0205238,0.0308504,0.00392171,0.00455279,0.00737316,0.00355315,0.00412452,0.00703021,-0.000793993,-0.000942731,-0.00194683,-0.007531,-0.00862594,-0.0131979,-0.00471064,-0.00533534,-0.00734516,0.810671,0.9705,1.2309,0.00230774,0.0035619,0.0153705,0.0113564,0.0148536,0.0281815,0.0000261672,-0.00205918,-0.0186128,0.000173623,0.000707025,0.0068509,-0.00210021,-0.00274359,-0.00723294,-0.00570316,-0.00660273,-0.00598361,0.00188374,0.00311903,0.00969843,0.00160369,0.00147089,-0.000489016,0.851496,1.01076,1.23803,-0.0198486,-0.0187504,0.0171311,-0.0242301,-0.0203952,0.0170042,0.0033784,0.00334097,-0.00939571,-0.000553066,-0.000402888,0.00407701,0.00990815,0.00949257,-0.00634728,0.00348777,0.00259674,0.000215638,-0.00243173,-0.00272841,0.00258347,-0.00374276,-0.00400345,-0.000366706,0.86431,1.02369,1.24052,-0.0276295,-0.0268353,0.0135241,-0.0339443,-0.0306862,0.0153175,0.00921155,0.00821092,0.000581694,-0.0000475147,0.000412101,0.00328457,0.0148959,0.0146892,-0.00392417,0.00455744,0.00420803,0.000168181,-0.00557249,-0.00522193,-0.00288633,-0.00152255,-0.00242483,0.0000476273,0.86978,1.03018,1.24099,-0.0291664,-0.0285757,0.0132993,-0.0378841,-0.0352322,0.0148327,-0.00293681,-0.00419331,-0.00685286,0.00185436,0.00234016,0.00421894,0.0156146,0.0154856,-0.00380518,0.00512249,0.0046417,0.000163596,0.000904187,0.00149173,0.00189669,-0.000445809,-0.00102386,0.0000143418,0.875709,1.0358,1.2533,-0.0294543,-0.0285464,0.011731,-0.0469037,-0.0433947,0.00254374,-0.00681098,-0.00749945,-0.00432852,0.00260773,0.00309396,0.00391281,0.0163641,0.0159229,-0.00273635,0.0105257,0.00929809,0.00475459,0.00226914,0.00269874,0.000749171,-0.00157446,-0.00172881,0.00120342,0.86098,1.01799,1.24046,-0.0243427,-0.0226503,0.0146166,-0.0331145,-0.0262667,0.0167977,-0.0115728,-0.0113697,-0.00309225,0.00422961,0.00453422,0.00360396,0.0131573,0.0121329,-0.00502543,0.00613397,0.00346769,-0.00158971,0.00477561,0.00447611,-0.000173306,-0.00231652,-0.00242758,0.00131404,0.846173,1.0062,1.26434,-0.00969531,-0.00884849,0.00227676,-0.0166774,-0.0129655,0.00441221,-0.0224543,-0.0204405,-0.00307156,0.00536066,0.00518383,-0.0000022086,0.0044124,0.00375427,-0.00167365,-0.0004839,-0.00165263,-0.00300421,0.00981069,0.00845144,0.000377497,0.00506132,0.004663,0.00203809,0.821468,0.980117,1.24193,0.00298811,0.00602617,0.0196807,0.00225578,0.00518339,0.016166,0.0102584,0.00690256,-0.00745617,-0.00266511,-0.00151252,0.004697,-0.00296691,-0.00428599,-0.00911382,-0.00230023,-0.00194187,-0.000226552,-0.00271811,-0.00153836,0.00341521,0.00575563,0.00550131,0.00502971,0.862897,1.02408,1.26142,-0.0336285,-0.0325215,0.0021291,-0.0269994,-0.0254681,0.00132177,0.00978804,0.00880725,-0.00654088,-0.00408357,-0.0040218,0.00242431,0.0139969,0.0134724,-0.000268068,0.00034865,0.000525963,0.00160136,-0.00348023,-0.0033488,0.00262763,-0.00616212,-0.00670878,-0.000979832,0.870092,1.03275,1.26089,-0.0383655,-0.0381292,0.00428608,-0.0311363,-0.0302113,0.00244691,0.0047874,0.00629419,0.00122913,-0.00198377,-0.00244111,-0.000504493,0.015349,0.0151998,-0.00160393,0.000317928,0.000245612,0.00105968,-0.00143026,-0.00214413,0.00000493385,-0.0068378,-0.00721979,0.000273647,0.879958,1.03786,1.25926,-0.0446263,-0.0421809,0.00398593,-0.0362355,-0.0310928,0.00359163,0.00161115,0.000444121,0.00150944,-0.0000880058,0.000601692,0.0000878106,0.0176923,0.0160232,-0.00161248,-0.000228465,-0.00131053,0.00089924,-0.00173354,-0.000735432,0.000155206,-0.00618544,-0.00674788,-0.000655871,0.863949,1.02182,1.25183,-0.0358987,-0.0327076,0.00853402,-0.0245211,-0.0188141,0.011031,-0.00900985,-0.00911438,0.0017813,0.00452902,0.00479628,0.000362512,0.0133438,0.0110096,-0.00483938,-0.00179453,-0.00350896,-0.00150763,0.00261201,0.00285737,-0.000164386,-0.00652501,-0.00617361,0.000650005,0.859522,1.01651,1.25595,-0.0315602,-0.0278863,0.00589069,-0.0231244,-0.0167404,0.00749477,-0.013986,-0.0122725,0.0038006,0.0073597,0.00683745,-0.000605512,0.0122038,0.00961937,-0.00319946,-0.000699175,-0.00250754,-0.000714679,0.0045953,0.00366231,-0.00142353,-0.00565166,-0.00532555,0.00029033,0.846839,1.00918,1.2593,-0.0200197,-0.0192563,0.00376689,-0.0128674,-0.0113459,0.0053999,-0.0175228,-0.0169074,0.00323455,0.00842656,0.00827265,-0.000726324,0.00680173,0.00620661,-0.00207971,-0.00284099,-0.0032521,-0.000642953,0.00524263,0.00476047,-0.0016963,-0.000856329,-0.000812317,0.000127704]+ "irradiance": [0.787525,0.947183,1.21709,-0.0128871,-0.0145809,-0.0199165,-0.0216912,-0.024515,-0.0335227,-0.0226589,-0.0256378,-0.0350183,-0.00620364,-0.00699162,-0.00958744,-0.00623858,-0.00705768,-0.00964144,-0.00212922,-0.00240502,-0.00329061,-0.0105509,-0.0119378,-0.0163059,-0.00414027,-0.00468563,-0.00639859,0.738265,0.891448,1.14096,-0.0415297,-0.0469878,-0.0641822,-0.0613031,-0.0693331,-0.0947412,-0.00666444,-0.00754116,-0.0102996,-0.000164008,-0.000158209,-0.000253468,-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.729309,0.881314,1.12712,-0.0423377,-0.047902,-0.0654308,-0.0694891,-0.0785949,-0.107392,-0.00111113,-0.00125799,-0.00171721,0.000277233,0.000341024,0.000428451,-0.0223998,-0.0253429,-0.0346179,-0.012195,-0.0137937,-0.0188468,0.000610242,0.000690194,0.0009431,-0.00289992,-0.00328227,-0.00448168,0.730707,0.882808,1.12998,-0.0422219,-0.0477847,-0.0651816,-0.0681888,-0.0772125,-0.104719,-0.000105739,-0.000157315,0.00028999,0.000345285,0.000414414,0.000566514,-0.0223234,-0.0252667,-0.0344513,-0.0118302,-0.0134136,-0.0180826,0.00130522,0.00145183,0.00232894,-0.00266381,-0.0030229,-0.00401197,0.72871,0.880371,1.12656,-0.042488,-0.0481302,-0.0655913,-0.0700922,-0.0795621,-0.107909,-0.000917724,-0.00100318,-0.00141457,0.000312197,0.000387325,0.00048253,-0.0225097,-0.0255122,-0.034729,-0.0124137,-0.0141612,-0.0189932,0.000737173,0.000856444,0.00114404,-0.00293781,-0.0033316,-0.00454241,0.733278,0.885576,1.13353,-0.0419621,-0.047508,-0.0648129,-0.0656175,-0.0743816,-0.101206,0.00226046,0.00275908,0.0032482,0.00053198,0.000649137,0.000798054,-0.0221305,-0.0250547,-0.0341818,-0.0109466,-0.0123941,-0.016902,0.00285925,0.00334212,0.00428876,-0.00236481,-0.00274025,-0.00357782,0.790954,0.950547,1.22174,-0.00960914,-0.0109881,-0.0149956,-0.0201508,-0.0228443,-0.0312323,0.0199909,0.0231963,0.0316186,0.00565002,0.00651475,0.00885036,-0.00446563,-0.00506353,-0.0069162,-0.00271103,-0.00292566,-0.00401773,0.00975895,0.0111002,0.0151556,-0.00394222,-0.00468825,-0.00637588,0.800496,0.959563,1.21962,0.00644747,0.00821149,0.0191199,-0.0227969,-0.0271348,-0.0408284,-0.00119849,-0.00315642,-0.0193024,0.0000410554,0.000592982,0.00593914,0.00555783,0.0066437,0.011335,-0.0101426,-0.0114592,-0.0114748,-0.00493011,-0.00625899,-0.0121223,0.00339554,0.0034675,0.000937253,0.860872,1.01938,1.24144,-0.0272271,-0.0267536,0.00751207,0.0300581,0.0255765,-0.0176962,0.0249131,0.0250343,0.0119226,-0.00560587,-0.0056801,-0.00224833,-0.0138034,-0.0135731,0.00301913,0.00309019,0.00200364,-0.00302856,0.0108663,0.0109264,0.00605545,-0.00242788,-0.00338045,-0.00243578,0.862347,1.02182,1.23465,-0.032222,-0.0320372,0.00582751,0.0275115,0.0239823,-0.0242222,-0.00537432,-0.00596468,-0.00850571,0.00162083,0.00191538,0.00185963,-0.0150149,-0.0148549,0.00306737,0.00103919,0.000379351,-0.00421886,-0.00426092,-0.00476123,-0.00560804,-0.00292746,-0.00395755,-0.00509168,0.887573,1.04676,1.25702,-0.0338124,-0.0335401,0.00483102,0.0480382,0.0439146,-0.00574505,-0.0260572,-0.0260476,-0.0229879,0.00432752,0.00465832,0.00392746,-0.0157253,-0.0154292,0.00267342,0.00435309,0.00317731,-0.00130267,-0.0173181,-0.0175083,-0.0153057,0.00322475,0.00232248,0.00027055,0.860906,1.02005,1.24154,-0.0291718,-0.0285755,0.00781472,0.0279506,0.0234507,-0.0185362,0.00188072,0.00324124,0.00620576,0.000174752,0.000126676,-0.000234617,-0.0129673,-0.0123648,0.00479953,0.00152834,-0.000160204,-0.00367052,0.00047771,0.000930894,0.00146565,-0.00311592,-0.00372695,-0.00314301,0.852004,1.01337,1.24106,-0.028092,-0.0280754,0.00567179,0.0203721,0.0180982,-0.0200936,-0.00189919,-0.0004092,0.0121622,0.00259356,0.00257306,-0.000565682,-0.0127473,-0.0125429,0.00392074,-0.00138562,-0.00226723,-0.0055742,0.000623176,0.00136291,0.00549433,-0.00420041,-0.00468323,-0.00303971,0.837734,1.00022,1.25399,-0.010854,-0.0107294,0.00332394,0.0114334,0.0104304,-0.00919001,-0.012505,-0.0115858,0.00701943,0.00563716,0.00570465,-0.000606735,-0.0044717,-0.00430582,0.00227023,-0.000358693,-0.000615321,-0.00239543,-0.00414448,-0.00367089,0.00379254,0.00128062,0.000988999,-0.00141091,0.822954,0.98456,1.24419,-0.00418006,-0.00284488,0.0134422,-0.0037781,-0.00565253,-0.0174685,0.00797472,0.00737906,-0.00648878,-0.00309924,-0.00273474,0.0037775,0.00165075,0.00249459,0.0077429,-0.00530499,-0.00581176,-0.00421836,0.00191514,0.00155918,-0.00347616,0.0011147,0.00136022,0.00236154,0.854811,1.01673,1.25782,-0.0320514,-0.03118,0.00335539,0.0194942,0.0180646,-0.00380148,0.00193945,0.00160735,-0.00853064,-0.00106941,-0.00101542,0.00348796,-0.0111989,-0.0106035,0.00125953,-0.00180661,-0.00203874,0.000381528,0.000636795,0.000582873,-0.00366002,-0.00867818,-0.00885823,-0.00133129,0.854748,1.01285,1.24118,-0.0294058,-0.0267382,0.0158177,0.0187663,0.0150899,-0.016121,0.0037877,0.00201504,-0.0026555,0.00026282,0.00086454,0.00225308,-0.00986331,-0.00856418,0.00746947,-0.0021122,-0.00213927,-0.000844322,0.000703785,-0.0000406061,-0.00157516,-0.00617337,-0.00698879,0.00092101,0.850005,1.01014,1.24037,-0.0229792,-0.0207523,0.0206152,0.0138771,0.0111516,-0.0183881,-0.0118688,-0.0124227,-0.0110753,0.00446025,0.00486087,0.00406341,-0.00586924,-0.0045922,0.0106492,-0.00357584,-0.00387308,-0.00225576,-0.00634459,-0.00679376,-0.00606706,-0.00225405,-0.00214503,0.00526742,0.858125,1.017,1.24561,-0.0314373,-0.0289928,0.0131091,0.0220577,0.0184534,-0.0130407,-0.00115696,-0.00187198,0.0028731,0.0012198,0.00176116,0.0000877137,-0.0108612,-0.00939949,0.0066399,-0.00147662,-0.00191581,-0.000877415,-0.000365041,-0.00118455,0.0000259359,-0.00615863,-0.00655571,0.00113428,0.855363,1.01206,1.24357,-0.0289972,-0.0254601,0.0146203,0.0179333,0.0109861,-0.0171108,-0.011662,-0.0111853,0.00137112,0.00553361,0.00554909,0.000663614,-0.00865102,-0.00598065,0.00863058,-0.00282911,-0.00516589,-0.00314004,-0.0041978,-0.00399893,0.0000983545,-0.00523437,-0.00485754,0.00236351,0.835127,0.993163,1.24984,-0.0129033,-0.0100216,0.00941048,0.00532716,0.000906712,-0.0120507,-0.0109294,-0.0074001,0.00738052,0.00566315,0.00451564,-0.00230642,-0.00275675,-0.00105727,0.00556439,-0.00359931,-0.00425899,-0.00211841,-0.0026541,-0.000813324,0.0040823,-0.00100434,-0.0013968,0.000645681,0.729509,0.881399,1.12839,-0.0467424,-0.0530276,-0.0712735,-0.00356342,-0.00403267,-0.00531706,-0.0666252,-0.075459,-0.102446,-0.0236764,-0.0268164,-0.0362123,-0.000963635,-0.00110976,-0.00135106,0.00324216,0.00370843,0.00476489,-0.00185991,-0.00211556,-0.00279986,-0.00858882,-0.00968229,-0.0135223,0.563616,0.693843,0.871043,-0.163331,-0.184797,-0.252421,-0.00312799,-0.00351208,-0.00483417,-0.00570718,-0.00645809,-0.00882019,-0.000219454,-0.000220942,-0.000339157,-0.000316014,-0.000356715,-0.000488385,0.00451025,0.00510706,0.00697039,-0.00326112,-0.00368997,-0.00503991,0.00737592,0.0083441,0.0113992,0.558189,0.687495,0.862693,-0.164101,-0.185704,-0.253604,-0.00644702,-0.00727783,-0.00996171,-0.00282568,-0.00343343,-0.0043244,0.0000356534,0.0000384371,0.0000604703,-0.000642574,-0.000727317,-0.00099287,0.00451963,0.00517458,0.00697461,-0.00120126,-0.00136814,-0.00185493,0.00570266,0.00635639,0.00883024,0.556418,0.683723,0.864382,-0.167018,-0.190358,-0.256482,-0.00684113,-0.00744186,-0.0117001,0.00829701,0.00817313,0.0170444,0.000436146,-0.000050206,0.00175217,-0.000646604,-0.000608417,-0.00126299,0.00494531,0.00583923,0.00704142,-0.00328745,-0.00361991,-0.00571979,0.00743027,0.00840923,0.0127357,0.636202,0.773727,1.01852,-0.107938,-0.123673,-0.142421,-0.00873854,-0.00977028,-0.0150059,-0.000951478,-0.000963839,-0.00329603,-0.00020291,-0.000184486,-0.000601835,-0.00120158,-0.00134282,-0.00212771,0.00195993,0.00231153,0.00157805,-0.00225331,-0.00254749,-0.00354334,-0.000294205,-0.000213799,-0.00235455,0.564091,0.694089,0.872507,-0.163334,-0.18487,-0.25236,-0.0012593,-0.00141044,-0.00212137,0.0107621,0.0124973,0.0158129,0.00137096,0.00163216,0.0020655,-0.00027098,-0.000307812,-0.000428955,0.00526789,0.00603849,0.00796702,0.000554288,0.000638355,0.0009992,0.00712257,0.00793546,0.0113389,0.752697,0.907175,1.15645,-0.0276135,-0.0316344,-0.0483254,0.00192,0.00228869,0.00374418,0.0567952,0.0647225,0.0922712,0.0168116,0.0192403,0.0286925,0.0010311,0.00120527,0.00212307,0.00454369,0.00524966,0.0080726,-0.000970871,-0.0011425,-0.00170238,-0.0131332,-0.014885,-0.0196908,0.674555,0.815024,1.06506,0.0495696,0.0574047,0.0732287,-0.0217849,-0.0252712,-0.0300659,-0.109856,-0.127845,-0.149824,0.0207393,0.024107,0.0302933,0.00523577,0.00607406,0.00741895,0.00786213,0.00923883,0.0105487,-0.00607644,-0.00709569,-0.00812058,-0.017887,-0.0209324,-0.0222696,0.883645,1.02887,1.18098,-0.0687556,-0.0645631,0.0285511,-0.00472256,-0.0086901,-0.0175563,0.0315105,0.0440019,0.0323728,-0.00759729,-0.00888225,-0.000519995,0.00213982,0.00294328,0.00454949,-0.00197669,-0.000520843,0.00709915,-0.0013919,-0.00101487,-0.000851769,-0.0218369,-0.0258815,-0.0138033,0.907239,1.06138,1.19687,-0.0800625,-0.07853,0.0266419,0.0165289,0.0157453,0.00154129,-0.0129637,-0.013242,-0.0172969,0.00336094,0.00362366,0.0040498,-0.00483681,-0.00475794,-0.00076464,-0.000344163,0.00136025,0.0108934,0.0100496,0.0123107,0.0101821,-0.020391,-0.0238571,-0.0132019,0.907376,1.05137,1.17719,-0.0804518,-0.0781026,0.0239283,0.023123,0.0225669,0.00663528,0.0237665,0.0291194,0.0300844,-0.00309608,-0.00190891,0.00191971,-0.00595762,-0.0047675,0.00200444,-0.00408008,-0.00326378,0.00687755,-0.00984809,-0.0158576,-0.0181096,-0.015417,-0.0191261,-0.0114021,0.945702,1.09109,1.23362,-0.100327,-0.0909018,0.00615737,-0.00416698,-0.0180982,-0.0337722,-0.0276967,-0.0312387,-0.0254469,0.0131776,0.013942,0.0141744,0.00464845,0.00932017,0.013409,-0.0127294,-0.0151937,-0.00774476,-0.00591711,-0.0090682,-0.0100239,-0.0155296,-0.0153868,-0.0090673,0.906882,1.05086,1.19709,-0.0620062,-0.053125,0.0456678,-0.0158368,-0.0346713,-0.047552,-0.0227535,-0.0204186,0.00330449,0.00812814,0.00758905,0.001696,0.0150274,0.0212729,0.0228551,-0.0077994,-0.0128519,-0.00553197,-0.000441158,0.000437896,0.000802504,-0.0049932,-0.00493082,0.00686803,0.850225,1.009,1.23215,-0.0235832,-0.021935,0.0143697,-0.0109869,-0.015063,-0.0187087,-0.0204032,-0.016588,0.0267149,0.0106351,0.00983894,-0.00739616,0.0036441,0.00480044,0.00563833,-0.00439115,-0.0047902,0.000498097,0.00771721,0.00980612,0.0104849,-0.00122416,-0.00214435,-0.00552289,0.835614,0.990697,1.24577,0.00267216,0.00883513,0.026658,0.00970429,0.00788269,0.00289505,0.0315913,0.0258439,0.00453388,-0.0088642,-0.00647811,0.00221516,-0.00325456,-0.00244938,-0.000923271,-0.00473516,-0.00319338,0.00157928,0.00773767,0.0068118,0.0039396,0.0173337,0.0175205,0.0156406,0.897277,1.05733,1.27082,-0.0664869,-0.0632194,-0.00351023,0.0150228,0.0143071,-0.000950169,0.0152068,0.0176642,-0.00928711,-0.00605199,-0.00747242,0.0058794,-0.00718409,-0.00682732,0.000740639,-0.00991774,-0.00963938,-0.000363748,0.00371928,0.00398372,-0.000491779,-0.0122695,-0.011494,0.000741346,0.893818,1.04904,1.24355,-0.0623718,-0.0576028,0.0176422,0.0242595,0.0223354,-0.00073703,0.019934,0.0166169,0.00566039,-0.00684755,-0.00559846,-0.00158721,-0.0122168,-0.0117057,-0.000351845,-0.00883122,-0.00729283,0.00336766,0.00486114,0.00409776,0.00140844,-0.0111979,-0.0127808,0.00215107,0.89989,1.05486,1.2508,-0.0650871,-0.0589376,0.0149052,0.0274111,0.0256949,0.00152978,0.00134054,0.000273788,-0.00188826,-0.00101401,-0.000228786,0.00134506,-0.0127588,-0.0120977,0.0000316478,-0.0077634,-0.00597146,0.00376577,-0.00180545,-0.00291932,-0.00194784,-0.0102449,-0.0106832,0.00359494,0.891081,1.04076,1.23956,-0.0644396,-0.0538915,0.0179526,0.0191796,0.0113609,-0.0109848,-0.00604972,-0.00818703,0.00012916,0.00553146,0.00721532,0.00386088,-0.00826995,-0.00397038,0.0066374,-0.00693701,-0.00628275,0.00285159,-0.00143115,-0.00321524,-0.0015606,-0.0164008,-0.0150333,-0.000255386,0.897824,1.04435,1.24926,-0.0661389,-0.0514119,0.0156784,0.0252963,0.0136439,-0.00541754,-0.0181562,-0.0168053,0.00339963,0.00818116,0.00739875,-0.00154777,-0.0126078,-0.00551666,0.00396361,-0.00678901,-0.00698838,0.00242836,-0.00281224,-0.00236102,0.00065171,-0.0132,-0.00932599,0.00474075,0.864498,1.02013,1.25347,-0.0350887,-0.0293282,0.00977904,0.0141562,0.0101815,-0.00134962,-0.027682,-0.0221626,0.00624837,0.0149575,0.0124329,-0.00184987,-0.00643677,-0.00423086,0.00110793,-0.00483917,-0.0039824,0.00262238,-0.00559888,-0.00378335,0.000736385,-0.00317166,-0.00309039,0.00158832,0.72053,0.871234,1.11451,-0.0475521,-0.0539442,-0.072525,0.00408972,0.00462909,0.0065097,-0.0718517,-0.0813773,-0.110522,-0.0239441,-0.0271195,-0.0366261,-0.000412469,-0.000486045,-0.000499316,0.00119227,0.00138952,0.00159679,0.000590996,0.000659491,0.00098732,-0.0102455,-0.0115585,-0.0160822,0.554043,0.682762,0.856505,-0.164178,-0.185771,-0.253713,0.00486246,0.00567046,0.00736907,-0.0115287,-0.0132953,-0.0175601,-0.000514353,-0.000566084,-0.00078312,0.000250663,0.000290947,0.000380709,0.00250558,0.00285799,0.00385269,-0.000564506,-0.000535575,-0.000978515,0.00550317,0.00613435,0.00859816,0.549883,0.678136,0.850139,-0.164764,-0.186429,-0.254615,0.00141022,0.00171929,0.00199814,-0.00725001,-0.00837437,-0.0108846,-0.000110668,-0.000105685,-0.00015636,-0.0000790722,-0.0000841975,-0.000130516,0.00223036,0.00254053,0.00342256,0.00140334,0.00165797,0.00203674,0.00437827,0.00489055,0.00688251,0.545507,0.673312,0.843066,-0.16514,-0.186851,-0.255215,0.00259318,0.00300347,0.00399883,-0.00201245,-0.00229686,-0.00310629,0.000187179,0.000236477,0.00028981,0.00000358028,0.00000971133,0.00000454124,0.00320082,0.0036102,0.00494995,0.000395478,0.000459861,0.000608633,0.00243025,0.00274446,0.00375662,0.549686,0.677862,0.849849,-0.164907,-0.186611,-0.254816,0.000379343,0.000699523,0.000208761,0.0026304,0.00297089,0.00411154,0.000416818,0.0004999,0.000647846,-0.000073289,-0.0000576319,-0.000146185,0.00271013,0.00296216,0.00436443,-0.00154956,-0.0017457,-0.00243399,0.00405615,0.00458275,0.00627093,0.559088,0.68871,0.864048,-0.163703,-0.18522,-0.252995,0.00439774,0.00501152,0.00679482,0.0106475,0.0120547,0.0164536,0.0011909,0.00137585,0.00184028,0.000204575,0.000233385,0.00031595,0.00295751,0.00334878,0.00457098,0.000687408,0.000772403,0.00106334,0.00682936,0.00772332,0.0105549,0.751503,0.905845,1.15286,-0.0280399,-0.0321359,-0.049435,0.00376431,0.00446702,0.00848615,0.0565171,0.0642827,0.0922848,0.0168516,0.0192819,0.0288335,0.00140286,0.00164789,0.0030558,0.00351562,0.00399884,0.00566869,-0.00118207,-0.00137462,-0.00235897,-0.0128373,-0.0144879,-0.0192414,0.66063,0.79867,1.04636,0.0520614,0.0603918,0.0766293,0.000309106,0.000561037,-0.000549619,-0.118535,-0.138012,-0.161404,0.0214998,0.02502,0.0313314,0.0032567,0.00372724,0.00471288,0.00451941,0.0053238,0.00602131,0.00160138,0.00187596,0.00211849,-0.019328,-0.0226004,-0.0241777,0.901682,1.04255,1.18406,-0.0729347,-0.0679661,0.0281205,-0.0202856,-0.0190296,-0.024125,0.0699396,0.083158,0.0682688,-0.0164766,-0.0181859,-0.00828854,-0.00147166,-0.00247361,-0.00135847,-0.0041447,-0.00394999,0.00313747,-0.00896078,-0.00812438,-0.00698926,-0.0131327,-0.0172831,-0.00646912,0.990061,1.14265,1.25808,-0.111902,-0.111374,0.00290989,-0.0308005,-0.0284522,-0.0265959,0.00582065,0.00684885,0.000664505,0.000419867,0.00016726,0.00180014,0.00490472,0.00455237,0.00469164,0.000366145,0.00167465,0.0102863,0.0166698,0.0166131,0.0180572,-0.00823976,-0.0130583,-0.00495064,0.943573,1.09414,1.21643,-0.0947451,-0.0915653,0.0202458,0.0043863,0.00928277,0.00543029,-0.014825,-0.0220501,-0.0135414,0.00827789,0.0116342,0.00981804,-0.000973897,-0.00174748,0.0000374596,-0.00336134,-0.00187574,0.007284,-0.00421494,-0.00376261,-0.00375973,-0.0145979,-0.0189429,-0.0100142,0.972634,1.07035,1.19206,-0.124936,-0.0710252,0.0417408,0.007824,0.00780756,0.00503326,-0.0201057,-0.0377616,-0.0298938,0.00939806,0.0177267,0.0158437,-0.00233799,-0.001708,-0.000648919,-0.00822116,-0.0000422503,0.00904504,-0.00194945,-0.00304774,-0.00209683,-0.0257499,-0.0157093,-0.00658655,1.05129,1.10191,1.22323,-0.170331,-0.0868376,0.0273426,-0.00287092,-0.00350229,-0.00514177,-0.00809702,-0.00656597,0.00591739,0.0019855,0.00180736,-0.000180869,0.00073405,0.00088698,0.00121845,-0.0134095,-0.00808421,0.000651789,0.00182268,0.00184729,0.0022726,-0.018125,-0.00809017,0.00159568,0.862763,1.00886,1.22881,-0.024228,-0.0155968,0.0219945,0.00382506,0.00298547,0.000687828,-0.0294917,-0.0132699,0.0303524,0.0104741,0.0050025,-0.0123166,-0.000802806,-0.000633561,-0.0000459908,-0.00133061,0.00134647,0.00476874,-0.00184388,-0.0012597,-0.000186928,0.00233692,-0.00140631,-0.00428852,0.802521,0.958427,1.21189,0.0205159,0.027303,0.0472672,-0.00178062,-0.00166739,0.00197414,0.00595894,0.00277929,-0.0186006,0.000122737,0.00209146,0.0114092,-0.000538009,-0.000778108,-0.00251629,-0.00153099,-0.001043,0.00388987,-0.00259544,-0.00280476,-0.00117317,0.0128127,0.0145347,0.0134559,0.906121,1.06256,1.26429,-0.0711656,-0.0659347,0.00197067,-0.00304482,-0.00267679,-0.000916967,0.0144888,0.0139549,-0.0178877,-0.00584743,-0.00632783,0.00891249,-0.000840375,-0.001209,-0.00150472,-0.00798643,-0.00683063,0.00201908,-0.00154967,-0.00175663,-0.000424638,-0.0112418,-0.0111436,0.0019956,0.884456,1.04204,1.22441,-0.0625293,-0.0590826,0.0277547,-0.00185613,-0.00161064,-0.0000341217,0.0115326,0.0129746,0.00167224,-0.00583183,-0.00657611,-0.00132104,0.00142831,0.00138734,0.00076902,-0.00492418,-0.00364262,0.00746482,0.00144822,0.00171487,0.00245783,-0.0197727,-0.0211083,-0.00301472,0.914182,1.0612,1.23896,-0.0817305,-0.0702737,0.0194391,-0.00580651,-0.00663656,-0.00507419,0.0149053,0.00789325,-0.00027896,-0.0066067,-0.00221568,0.00138809,0.00397613,0.00438478,0.00392274,-0.0103475,-0.00623911,0.00646839,0.00414444,0.00409898,0.00484666,-0.0169186,-0.0184488,-0.00145611,0.917067,1.06043,1.23843,-0.0875737,-0.0686188,0.0215283,-0.00204304,0.000132502,0.0018192,-0.000783758,-0.00637015,0.00198096,0.00120953,0.00557808,0.00247258,0.00186261,0.000815349,0.000279357,-0.0122771,-0.0072431,0.00504682,-0.00190066,-0.00201501,-0.00208546,-0.0195898,-0.0154384,0.0024093,0.910365,1.04953,1.2478,-0.0873899,-0.0615893,0.0133217,0.00312886,0.00357486,-0.00111202,-0.0141456,-0.0111574,0.00910365,0.00926027,0.0075215,-0.00243689,-0.0017166,-0.00199289,0.000536269,-0.0123376,-0.00654627,0.00384822,0.00181522,0.00192011,0.00116866,-0.0249044,-0.0163138,0.000630049,0.864366,1.01498,1.24443,-0.0370838,-0.0260347,0.016537,0.00263942,0.00230974,0.00331259,-0.0276957,-0.0187866,0.0125181,0.0162517,0.0113767,-0.00445214,-0.00119605,-0.000814109,-0.00117436,-0.00625245,-0.00308726,0.00486233,-0.00186455,-0.00177291,-0.00147649,-0.00403675,-0.00280263,0.0019797,0.725074,0.876382,1.12152,-0.0470635,-0.0533894,-0.0717842,0.00832833,0.00942228,0.0130582,-0.0688837,-0.0780135,-0.105944,-0.0237157,-0.0268603,-0.0362788,-0.000101161,-0.000133728,-0.0000202226,0.00245645,0.00281908,0.00355428,0.00259516,0.00292515,0.00408413,-0.00957207,-0.0107951,-0.0150382,0.563616,0.693843,0.871043,-0.162846,-0.184249,-0.251671,0.0138529,0.0157006,0.0214091,-0.00780275,-0.00882908,-0.0120588,-0.000249881,-0.000255367,-0.000386179,0.00124164,0.00140566,0.0019189,0.00613283,0.00694291,0.00947802,0.00134433,0.00152077,0.0020776,0.00634808,0.00718118,0.00981068,0.559137,0.688776,0.864122,-0.163452,-0.184934,-0.252608,0.0105819,0.0119997,0.0163539,-0.00384389,-0.00434991,-0.00594055,0.000139135,0.000184776,0.000215026,0.000920217,0.00104199,0.00142215,0.00588196,0.00665907,0.00909031,0.0034442,0.00389662,0.00532286,0.00510713,0.00577713,0.00789285,0.554659,0.68371,0.857201,-0.163816,-0.185346,-0.25317,0.0117386,0.0133084,0.0181414,0.00118296,0.00133761,0.00182821,0.000435512,0.000520105,0.000673063,0.000988412,0.00111915,0.00152755,0.00694578,0.0078627,0.0107344,0.00250135,0.00282985,0.00386572,0.00306904,0.00347117,0.00474305,0.559137,0.688776,0.864122,-0.163533,-0.185026,-0.252733,0.0091934,0.0104287,0.014208,0.00567532,0.0064204,0.00877095,0.000641517,0.000753186,0.000991435,0.000871698,0.000987097,0.00134717,0.00660381,0.00747579,0.0102059,0.000647237,0.000732052,0.00100028,0.00469885,0.00531518,0.00726185,0.563616,0.693843,0.871043,-0.162846,-0.184249,-0.251671,0.00945511,0.0107248,0.0146124,0.0107938,0.0122116,0.0166814,0.00121155,0.00139813,0.00187239,0.000900844,0.00102007,0.00139221,0.00536173,0.00607046,0.00828631,0.000864462,0.000977826,0.00133599,0.00678481,0.00767531,0.0104856,0.751528,0.905878,1.15289,-0.0280379,-0.0321332,-0.049432,0.00375796,0.00445846,0.00847661,0.0564895,0.0642455,0.0922434,0.01685,0.0192797,0.0288311,0.00140249,0.00164738,0.00305523,0.00350978,0.00399097,0.00565992,-0.00117689,-0.00136764,-0.0023512,-0.0128261,-0.0144728,-0.0192246,0.695336,0.837426,1.08271,0.0308742,0.0368234,0.055224,0.033174,0.0375408,0.03591,-0.104026,-0.121797,-0.147061,0.0146549,0.0173656,0.0244975,-0.00727788,-0.00791685,-0.0056617,0.0120507,0.0138782,0.0153342,0.0123751,0.0140502,0.0137217,-0.0211581,-0.0245563,-0.0257718,0.877124,1.02161,1.16481,-0.0684846,-0.0650189,0.0251456,0.0096301,0.0138409,0.0262876,0.0485916,0.0610279,0.0370116,-0.0156082,-0.0177392,-0.00665419,-0.00264647,-0.00342661,-0.00611495,-0.00461286,-0.00314202,0.00624165,-0.00277253,-0.00332328,-0.00339605,-0.0155121,-0.0190861,-0.0101088,0.91486,1.06989,1.19793,-0.0851337,-0.0845644,0.02115,0.00901208,0.0133143,0.0266004,0.0243628,0.0268754,0.0128542,-0.00675792,-0.00750487,-0.00502111,-0.00406886,-0.00512902,-0.00839534,-0.00918973,-0.00858381,0.00302648,-0.00125849,-0.00137378,-0.00105449,-0.0148914,-0.0178989,-0.0092571,0.953136,1.11033,1.23406,-0.100694,-0.100172,0.0110752,-0.00527114,0.00022744,0.0167638,-0.00209644,-0.00622579,-0.0071255,0.00177008,0.00338115,0.00390325,0.00156287,0.000339934,-0.00361396,-0.0105916,-0.0105381,0.00081086,0.00647031,0.00883374,0.00597584,-0.0110174,-0.0137496,-0.00613509,0.988172,1.13728,1.26008,-0.10505,-0.0991978,0.0128321,-0.0331341,-0.0200358,0.00112783,-0.0304282,-0.036114,-0.0342535,0.00351721,0.00552477,0.00567639,0.00506319,0.000445131,-0.00444959,-0.00806675,-0.0101662,-0.000817681,0.0154816,0.0185283,0.0166877,-0.00251635,-0.00405367,0.00490305,0.944056,1.0922,1.23312,-0.0922936,-0.085015,0.0200408,-0.00899499,0.00706017,0.0239636,-0.0218138,-0.020836,-0.0000722143,0.00646877,0.00612676,0.000582521,0.000420311,-0.0051952,-0.00955475,-0.00840949,-0.012898,-0.00487024,0.00369612,0.00322544,0.000808726,-0.0113631,-0.0111548,0.00235255,0.863897,1.01873,1.2434,-0.0286589,-0.025542,0.00994951,-0.000115797,0.00755906,0.0158063,-0.0341589,-0.0281363,0.0146362,0.0148235,0.0134276,-0.00398204,-0.000603064,-0.00265636,-0.00475719,-0.00596523,-0.00733859,-0.00198121,0.000324777,-0.00308022,-0.00625096,0.00221806,0.000978004,-0.00230261,0.801064,0.957013,1.21371,0.0132136,0.0188958,0.0376622,0.0150169,0.0176719,0.0223798,-0.00692051,-0.0115019,-0.0294645,0.00280356,0.00492909,0.0129876,-0.00717696,-0.00834586,-0.0102222,0.000731553,0.00150048,0.00619813,0.00493368,0.00584414,0.00767243,0.0032895,0.00385793,0.00393073,0.912074,1.06857,1.28606,-0.0740565,-0.0690693,-0.0141793,-0.0413218,-0.0378098,-0.0217234,0.00544679,0.00495039,-0.0205431,-0.00240233,-0.00283428,0.00943565,0.0201095,0.0186916,0.0112198,0.000743638,0.00105727,0.0094167,0.000666506,0.00151681,0.00513208,-0.0151773,-0.0148513,-0.0043675,0.882884,1.03664,1.22645,-0.0514453,-0.0466198,0.0287866,-0.017649,-0.012954,0.0117156,0.0238189,0.0218652,0.00744775,-0.0111645,-0.0110208,-0.00535929,0.00724667,0.00571634,-0.00556024,-0.00638765,-0.00551473,0.00465982,-0.00572083,-0.00474701,-0.0031946,-0.00840912,-0.0101784,0.00221703,0.898186,1.05494,1.24645,-0.0676156,-0.0636747,0.0138878,-0.0196475,-0.0159528,0.00729721,0.0111818,0.010212,0.0084344,-0.00548298,-0.0045947,-0.0033445,0.0101634,0.00850275,-0.00293877,-0.00833373,-0.007559,0.00328909,-0.00347703,-0.00241568,-0.00224135,-0.0137342,-0.0147847,0.0000587122,0.907059,1.05847,1.25414,-0.0762591,-0.0665889,0.00853857,-0.0276272,-0.0183533,0.00593633,-0.00724954,-0.010019,0.00190714,0.00335538,0.00531336,0.000513299,0.0142605,0.00904357,-0.0027387,-0.00812971,-0.00883234,0.00100745,0.000631304,0.00193804,-0.000464372,-0.0170317,-0.0148846,0.00101726,0.899372,1.0509,1.25916,-0.0674725,-0.0572437,0.00680962,-0.0241002,-0.0154133,0.00027373,-0.0251604,-0.023038,-0.000284962,0.012646,0.0117727,0.0014574,0.011997,0.00680489,-0.000699143,-0.00670065,-0.00692882,0.0030167,0.00567654,0.00459235,0.00132002,-0.0140124,-0.0113872,0.0017522,0.870105,1.02548,1.2561,-0.0366427,-0.0309832,0.00887319,-0.0159666,-0.0109508,0.00201017,-0.0336542,-0.0283596,0.00338349,0.0163688,0.0140592,-0.00116871,0.00749481,0.00503139,-0.00104936,-0.00555684,-0.00525644,0.0019108,0.0065933,0.00451922,-0.0000765998,-0.00108742,-0.000951656,0.00253503,0.789868,0.949537,1.21631,-0.00911252,-0.0104758,-0.0165453,0.0241234,0.0274545,0.0392661,-0.0181919,-0.0208268,-0.0317287,-0.00366167,-0.00420053,-0.00692165,0.00528928,0.00604637,0.00908243,-0.00492692,-0.00552825,-0.00698758,0.0095642,0.0108941,0.0158683,-0.00355553,-0.00406198,-0.00605875,0.758728,0.913711,1.15937,-0.022514,-0.0260741,-0.0437304,0.0507225,0.0579777,0.0867384,-0.00370833,-0.00425517,-0.00660255,0.0000729396,0.000111922,0.000143064,0.013602,0.0156822,0.025356,-0.0112788,-0.0127476,-0.0172895,0.00181162,0.00204164,0.00268343,-0.00490572,-0.00552338,-0.00716079,0.758728,0.913711,1.15937,-0.022514,-0.0260741,-0.0437304,0.0507225,0.0579777,0.0867384,-0.00370833,-0.00425517,-0.00660255,0.0000729396,0.000111922,0.000143064,0.013602,0.0156822,0.025356,-0.0112788,-0.0127476,-0.0172895,0.00181162,0.00204164,0.00268343,-0.00490572,-0.00552338,-0.00716079,0.75425,0.908644,1.15245,-0.0228776,-0.0264855,-0.0442923,0.0518791,0.0592863,0.0885259,0.00131852,0.00143235,0.00116621,0.000369316,0.000447251,0.000601101,0.0136702,0.0157593,0.0254614,-0.010215,-0.011544,-0.0156455,0.000868765,0.000974867,0.0012263,-0.00694381,-0.00782933,-0.0103106,0.758728,0.913711,1.15937,-0.0225948,-0.0261656,-0.0438552,0.0493339,0.0564066,0.0845925,0.00581088,0.00651513,0.00810895,0.000575321,0.000680332,0.000919473,0.0135535,0.0156273,0.025281,-0.010557,-0.0119309,-0.016174,-0.000985346,-0.00112293,-0.00163915,-0.00531401,-0.00598533,-0.00779178,0.755849,0.91041,1.15562,-0.0226727,-0.0262549,-0.0439569,0.0523576,0.0598737,0.0885384,0.00719001,0.00809654,0.00990879,0.000602426,0.000711411,0.000954845,0.0136129,0.0156954,0.0253585,-0.0117495,-0.0132983,-0.0177302,-0.00203722,-0.00232907,-0.00301189,-0.00555313,-0.00625952,-0.00810385,0.796241,0.956665,1.22493,-0.0068611,-0.00796482,-0.0136065,0.0152788,0.0176076,0.027977,0.0179561,0.0205238,0.0308504,0.00392171,0.00455279,0.00737316,0.00355315,0.00412452,0.00703021,-0.000793993,-0.000942731,-0.00194683,-0.007531,-0.00862594,-0.0131979,-0.00471064,-0.00533534,-0.00734516,0.810671,0.9705,1.2309,0.00230774,0.0035619,0.0153705,0.0113564,0.0148536,0.0281815,0.0000261672,-0.00205918,-0.0186128,0.000173623,0.000707025,0.0068509,-0.00210021,-0.00274359,-0.00723294,-0.00570316,-0.00660273,-0.00598361,0.00188374,0.00311903,0.00969843,0.00160369,0.00147089,-0.000489016,0.851496,1.01076,1.23803,-0.0198486,-0.0187504,0.0171311,-0.0242301,-0.0203952,0.0170042,0.0033784,0.00334097,-0.00939571,-0.000553066,-0.000402888,0.00407701,0.00990815,0.00949257,-0.00634728,0.00348777,0.00259674,0.000215638,-0.00243173,-0.00272841,0.00258347,-0.00374276,-0.00400345,-0.000366706,0.86431,1.02369,1.24052,-0.0276295,-0.0268353,0.0135241,-0.0339443,-0.0306862,0.0153175,0.00921155,0.00821092,0.000581694,-0.0000475147,0.000412101,0.00328457,0.0148959,0.0146892,-0.00392417,0.00455744,0.00420803,0.000168181,-0.00557249,-0.00522193,-0.00288633,-0.00152255,-0.00242483,0.0000476273,0.86978,1.03018,1.24099,-0.0291664,-0.0285757,0.0132993,-0.0378841,-0.0352322,0.0148327,-0.00293681,-0.00419331,-0.00685286,0.00185436,0.00234016,0.00421894,0.0156146,0.0154856,-0.00380518,0.00512249,0.0046417,0.000163596,0.000904187,0.00149173,0.00189669,-0.000445809,-0.00102386,0.0000143418,0.875709,1.0358,1.2533,-0.0294543,-0.0285464,0.011731,-0.0469037,-0.0433947,0.00254374,-0.00681098,-0.00749945,-0.00432852,0.00260773,0.00309396,0.00391281,0.0163641,0.0159229,-0.00273635,0.0105257,0.00929809,0.00475459,0.00226914,0.00269874,0.000749171,-0.00157446,-0.00172881,0.00120342,0.86098,1.01799,1.24046,-0.0243427,-0.0226503,0.0146166,-0.0331145,-0.0262667,0.0167977,-0.0115728,-0.0113697,-0.00309225,0.00422961,0.00453422,0.00360396,0.0131573,0.0121329,-0.00502543,0.00613397,0.00346769,-0.00158971,0.00477561,0.00447611,-0.000173306,-0.00231652,-0.00242758,0.00131404,0.846173,1.0062,1.26434,-0.00969531,-0.00884849,0.00227676,-0.0166774,-0.0129655,0.00441221,-0.0224543,-0.0204405,-0.00307156,0.00536066,0.00518383,-0.0000022086,0.0044124,0.00375427,-0.00167365,-0.0004839,-0.00165263,-0.00300421,0.00981069,0.00845144,0.000377497,0.00506132,0.004663,0.00203809,0.821468,0.980117,1.24193,0.00298811,0.00602617,0.0196807,0.00225578,0.00518339,0.016166,0.0102584,0.00690256,-0.00745617,-0.00266511,-0.00151252,0.004697,-0.00296691,-0.00428599,-0.00911382,-0.00230023,-0.00194187,-0.000226552,-0.00271811,-0.00153836,0.00341521,0.00575563,0.00550131,0.00502971,0.862897,1.02408,1.26142,-0.0336285,-0.0325215,0.0021291,-0.0269994,-0.0254681,0.00132177,0.00978804,0.00880725,-0.00654088,-0.00408357,-0.0040218,0.00242431,0.0139969,0.0134724,-0.000268068,0.00034865,0.000525963,0.00160136,-0.00348023,-0.0033488,0.00262763,-0.00616212,-0.00670878,-0.000979832,0.870092,1.03275,1.26089,-0.0383655,-0.0381292,0.00428608,-0.0311363,-0.0302113,0.00244691,0.0047874,0.00629419,0.00122913,-0.00198377,-0.00244111,-0.000504493,0.015349,0.0151998,-0.00160393,0.000317928,0.000245612,0.00105968,-0.00143026,-0.00214413,0.00000493385,-0.0068378,-0.00721979,0.000273647,0.879958,1.03786,1.25926,-0.0446263,-0.0421809,0.00398593,-0.0362355,-0.0310928,0.00359163,0.00161115,0.000444121,0.00150944,-0.0000880058,0.000601692,0.0000878106,0.0176923,0.0160232,-0.00161248,-0.000228465,-0.00131053,0.00089924,-0.00173354,-0.000735432,0.000155206,-0.00618544,-0.00674788,-0.000655871,0.863949,1.02182,1.25183,-0.0358987,-0.0327076,0.00853402,-0.0245211,-0.0188141,0.011031,-0.00900985,-0.00911438,0.0017813,0.00452902,0.00479628,0.000362512,0.0133438,0.0110096,-0.00483938,-0.00179453,-0.00350896,-0.00150763,0.00261201,0.00285737,-0.000164386,-0.00652501,-0.00617361,0.000650005,0.859522,1.01651,1.25595,-0.0315602,-0.0278863,0.00589069,-0.0231244,-0.0167404,0.00749477,-0.013986,-0.0122725,0.0038006,0.0073597,0.00683745,-0.000605512,0.0122038,0.00961937,-0.00319946,-0.000699175,-0.00250754,-0.000714679,0.0045953,0.00366231,-0.00142353,-0.00565166,-0.00532555,0.00029033,0.846839,1.00918,1.2593,-0.0200197,-0.0192563,0.00376689,-0.0128674,-0.0113459,0.0053999,-0.0175228,-0.0169074,0.00323455,0.00842656,0.00827265,-0.000726324,0.00680173,0.00620661,-0.00207971,-0.00284099,-0.0032521,-0.000642953,0.00524263,0.00476047,-0.0016963,-0.000856329,-0.000812317,0.000127704]}diff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjsindex 3b9dba1e1..3776454c0 100644--- a/pipeline/bin/estella.mjs+++ b/pipeline/bin/estella.mjs@@ -339,19 +339,15 @@ async function bakeScene(baker, meta, sceneFile, check) {reflections: reflectionProbes.map((p) => p.center),ambient, options,});- // Each pass split across every core but one: a lumel is solved on its own.- const worker = await bundlePipeline(path.join(PIPELINE, 'src', 'assets', 'lightmapWorker.ts'),- 'lightmapWorker.mjs');- const pool = new baker.BakePool(worker.outfile);+ const kernel = await baker.BakeKernelExecutor.load();let result;try {result = await baker.bakeSceneLightmapParallel({surfaces, lights, probeVolumes: volumes, reflectionProbes, environment,options: { ...options, ambient },- }, pool);+ }, kernel);} finally {- await pool.close();- worker.cleanup();+ await kernel.close();}for (const w of result.warnings) console.warn(` ! ${w}`);@@ -566,7 +562,8 @@ async function bundlePipeline(entry, outName) {// load, which an ESM bundle has none of: inlined, the bundle dies before it// exports anything.external: ['esbuild', 'electron', 'sharp', 'draco3dgltf', 'typescript',- '../../../build-tools/basis/encoder.mjs', '../../../build-tools/ufbx/reader.mjs'],+ '../../../build-tools/basis/encoder.mjs', '../../../build-tools/ufbx/reader.mjs',+ '../../../build-tools/lightmap/kernel.mjs'],logLevel: 'error',banner: {js: "import { createRequire as __esCreateRequire } from 'node:module';\n"diff --git a/pipeline/src/assets/lightmapBake.ts b/pipeline/src/assets/lightmapBake.tsindex 7a9b48257..8a533b518 100644--- a/pipeline/src/assets/lightmapBake.ts+++ b/pipeline/src/assets/lightmapBake.ts@@ -11,11 +11,11 @@import { readFileSync } from 'node:fs';import { PNG } from 'pngjs';import { bakeLightmapSteps, bakeRunner, decodeMesh, unwrapLightmapUV, builtinMeshTemplate, MeshChannel,- type MeshData, type BakeSurface, type BakeLight, type BakeOptions, type BakeAlloc,+ type MeshData, type BakeSurface, type BakeLight, type BakeOptions,type BakeStep, type CapturedPanorama, type ProbeGrid } from 'esengine';import { encodeRgbaPng } from './png';-export { BakePool } from './lightmapPool';+export { BakeKernelExecutor } from './lightmapKernel';import { bakeSceneReflections, bakeSky, irradianceSky, type BakeEnvironment,type ReflectionBakeResult } from './reflectionBake';@@ -260,17 +260,15 @@ export function bakeSceneLightmap(input: SceneBakeInput): SceneBakeResult {}}-/** How {@link bakeSceneLightmapParallel} hands a pass to its threads. */+/** What runs each pass of {@link bakeSceneLightmapParallel} over every lumel. */export interface BakeExecutor {- /** Where the arrays a pass touches must live for its threads to see them. */- alloc: BakeAlloc;run(step: BakeStep): Promise<void>;}-/** {@link bakeSceneLightmap} with each pass split across `executor`'s threads. */+/** {@link bakeSceneLightmap} with each pass run by `executor` across its threads. */export async function bakeSceneLightmapParallel(input: SceneBakeInput,executor: BakeExecutor): Promise<SceneBakeResult> {- const steps = sceneBakeSteps(input, executor.alloc);+ const steps = sceneBakeSteps(input);for (;;) {const next = steps.next();if (next.done) return next.value;@@ -278,8 +276,7 @@ export async function bakeSceneLightmapParallel(input: SceneBakeInput,}}-function* sceneBakeSteps(input: SceneBakeInput,- alloc?: BakeAlloc): Generator<BakeStep, SceneBakeResult, void> {+function* sceneBakeSteps(input: SceneBakeInput): Generator<BakeStep, SceneBakeResult, void> {const warnings: string[] = [];const surfaces: BakeSurface[] = [];const slot: number[] = [];@@ -377,7 +374,7 @@ function* sceneBakeSteps(input: SceneBakeInput,// 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 = yield* bakeLightmapSteps([], input.lights,- { ...input.options, probeGrids: grids, ...reflectionOptions }, alloc);+ { ...input.options, probeGrids: grids, ...reflectionOptions });gridSlot.forEach((at, k) => { probes[at] = asDocument(grids[k], empty.probes[k]); });return {atlasBytes: encodeRgbaPng(1, 1, new Uint8Array([0, 0, 0, 255])),@@ -389,7 +386,7 @@ function* sceneBakeSteps(input: SceneBakeInput,}const result = yield* bakeLightmapSteps(surfaces, input.lights,- { ...input.options, probeGrids: grids, ...reflectionOptions }, alloc);+ { ...input.options, probeGrids: grids, ...reflectionOptions });result.shared.forEach((share, k) => {if (share > 0.25) {warnings.push(`${surfaces[k]!.label ?? `surface ${k}`}: its lightmap UVs lay`diff --git a/pipeline/src/assets/lightmapKernel.ts b/pipeline/src/assets/lightmapKernel.tsnew file mode 100644index 000000000..32511130e--- /dev/null+++ b/pipeline/src/assets/lightmapKernel.ts@@ -0,0 +1,86 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file lightmapKernel.ts+ * @brief A bake's passes run by the C++ kernel (tools/lightmap-wasm): the same+ * rules as the TypeScript solve, on every core, with a tree built for+ * tracing rather than for building quickly.+ */++import { SH_COSINE_BAND, type BakeLight, type BakeScene, type BakeStep } from 'esengine';+import type { BakeKernel } from '../../../build-tools/lightmap/kernel.mjs';+import type { BakeExecutor } from './lightmapBake';++const LIGHT_DOUBLES = 16;+const SKY_DOUBLES = 36;+const LIGHT_KIND = { directional: 0, point: 1, spot: 2 } as const;++export function packLights(lights: readonly BakeLight[]): Float64Array<ArrayBuffer> {+ const out = new Float64Array(Math.max(1, lights.length) * LIGHT_DOUBLES);+ lights.forEach((l, i) => {+ const at = i * LIGHT_DOUBLES;+ const p = l.position ?? [0, 0, 0];+ const d = l.direction ?? [0, 0, -1];+ out.set([LIGHT_KIND[l.kind], p[0], p[1], p[2], d[0], d[1], d[2], l.color[0], l.color[1], l.color[2],+ 0, l.intensity, l.radius ?? 0, l.innerCos ?? 0.9, l.outerCos ?? 0.7, 0], at);+ });+ return out;+}++export function packSky(sky: BakeScene['sky']): Float64Array<ArrayBuffer> {+ if (typeof sky === 'function') {+ throw new Error('BakeKernelExecutor: the kernel needs the sky as a SkySpec');+ }+ const out = new Float64Array(SKY_DOUBLES);+ if (sky.kind === 'flat') {+ out.set([0, sky.rgb[0], sky.rgb[1], sky.rgb[2]]);+ return out;+ }+ out.set([1, 0, 0, 0, sky.yaw, sky.tint[0], sky.tint[1], sky.tint[2]]);+ // Rounded to float first, as skyRadiance holds them.+ const radiance = Float32Array.from(sky.irradiance.slice(0, 27),+ (v, i) => v / SH_COSINE_BAND[Math.floor(i / 3)]!);+ out.set(radiance, 8);+ return out;+}++export class BakeKernelExecutor implements BakeExecutor {+ private scene: BakeScene | null = null;+ private lights = new Float64Array(0);+ private sky = new Float64Array(0);++ constructor(private readonly kernel: BakeKernel) {}++ static async load(): Promise<BakeKernelExecutor> {+ const { loadBakeKernel } = await import('../../../build-tools/lightmap/kernel.mjs');+ return new BakeKernelExecutor(await loadBakeKernel());+ }++ get threads(): number { return this.kernel.threads; }++ async run({ scene, job }: BakeStep): Promise<void> {+ if (scene !== this.scene) {+ const { lookup, lumels } = scene;+ const { tris } = scene;+ this.kernel.scene({+ positions: tris.positions.subarray(0, tris.count * 9), triCount: tris.count,+ triUV: lookup.triUV, triSurface: lookup.triSurface, patch: lookup.patch,+ albedo: lookup.albedo, triNormal: lookup.triNormal, twoSided: lookup.twoSided,+ coverage: lookup.coverage, backReach: lookup.backReach,+ lumelPosition: lumels.position.subarray(0, lumels.count * 3),+ lumelNormal: lumels.normal.subarray(0, lumels.count * 3), lumelCount: lumels.count,+ });+ this.lights = packLights(scene.lights);+ this.sky = packSky(scene.sky);+ this.scene = scene;+ }+ const out = job.out.subarray(0, scene.lumels.count * 3);+ if (job.kind === 'direct') this.kernel.direct(this.lights, scene.lights.length, out);+ else this.kernel.gather(job.atlas, scene.atlasSize, scene.samples, this.sky, out);+ }++ async close(): Promise<void> {+ this.kernel.release();+ this.scene = null;+ }+}diff --git a/pipeline/src/assets/lightmapPool.ts b/pipeline/src/assets/lightmapPool.tsdeleted file mode 100644index 338cd6e6e..000000000--- a/pipeline/src/assets/lightmapPool.ts+++ /dev/null@@ -1,66 +0,0 @@-// SPDX-License-Identifier: Apache-2.0-// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-/**- * @file lightmapPool.ts- * @brief A bake's passes split across worker threads. Every lumel is solved on- * its own, so the threads share one scene in shared memory and each takes- * ranges of lumels until a pass runs out.- */--import { Worker } from 'node:worker_threads';-import { availableParallelism } from 'node:os';-import type { BakeAlloc, BakeScene, BakeStep } from 'esengine';-import type { BakeExecutor } from './lightmapBake';--export const sharedAlloc: BakeAlloc = {- f32: (n) => new Float32Array(new SharedArrayBuffer(n * 4)),- i32: (n) => new Int32Array(new SharedArrayBuffer(n * 4)),- u8: (n) => new Uint8Array(new SharedArrayBuffer(n)),-};--/** Ranges per thread per pass: enough that one slow range does not idle the rest. */-const RANGES_PER_THREAD = 16;--export class BakePool implements BakeExecutor {- readonly alloc = sharedAlloc;- private readonly workers: Worker[];- private scene: BakeScene | null = null;-- /**- * @param workerFile A module that runs `lightmapWorker.ts`: each host builds its- * own, since a thread cannot start from TypeScript source.- */- constructor(workerFile: string | URL, threads = Math.max(1, availableParallelism() - 1)) {- this.workers = Array.from({ length: threads }, () => new Worker(workerFile));- }-- get threads(): number { return this.workers.length; }-- async run({ scene, job }: BakeStep): Promise<void> {- if (scene !== this.scene) {- if (typeof scene.sky === 'function') {- throw new Error('BakePool: a bake split across threads needs its sky as a SkySpec');- }- for (const w of this.workers) w.postMessage({ scene });- this.scene = scene;- }- const count = scene.lumels.count;- const range = Math.max(64, Math.ceil(count / (this.workers.length * RANGES_PER_THREAD)));- let next = 0;- await Promise.all(this.workers.map((w) => new Promise<void>((resolve, reject) => {- const give = (): void => {- if (next >= count) { w.off('message', give); w.off('error', reject); resolve(); return; }- const from = next;- next = Math.min(count, next + range);- w.postMessage({ job, from, to: next });- };- w.on('message', give);- w.on('error', reject);- give();- })));- }-- async close(): Promise<void> {- await Promise.all(this.workers.map((w) => w.terminate()));- }-}diff --git a/pipeline/src/assets/lightmapWorker.ts b/pipeline/src/assets/lightmapWorker.tsdeleted file mode 100644index c59b9f884..000000000--- a/pipeline/src/assets/lightmapWorker.ts+++ /dev/null@@ -1,18 +0,0 @@-// SPDX-License-Identifier: Apache-2.0-// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-/**- * @file lightmapWorker.ts- * @brief One thread of a {@link BakePool}: holds the scene it was handed, solves- * the ranges it is sent, and says when each is done.- */--import { parentPort } from 'node:worker_threads';-import { bakeRunner, type BakeJob, type BakeScene } from 'esengine';--let run: ReturnType<typeof bakeRunner> | null = null;--parentPort?.on('message', (m: { scene?: BakeScene; job?: BakeJob; from?: number; to?: number }) => {- if (m.scene) { run = bakeRunner(m.scene); return; }- run!(m.job!, m.from!, m.to!);- parentPort!.postMessage(0);-});diff --git a/pipeline/tests/lightmap-kernel.test.ts b/pipeline/tests/lightmap-kernel.test.tsnew file mode 100644index 000000000..da21584ab--- /dev/null+++ b/pipeline/tests/lightmap-kernel.test.ts@@ -0,0 +1,131 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file The C++ bake kernel solves what the TypeScript solve does: the same+ * rays, the same cutout hash, the same sky, to rounding — and the same+ * answer however many threads it runs on.+ */+import { describe, it, expect, beforeAll, afterAll } from 'vitest';+import { mkdtemp, rm, writeFile } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { encodeMesh, unwrapLightmapUV, decodeLightmap, MeshChannel, MeshChannelType,+ type MeshData, type BakeLight } from 'esengine';+import { bakeSceneLightmap, bakeSceneLightmapParallel, type SceneBakeInput } from '../src/assets/lightmapBake';+import { BakeKernelExecutor } from '../src/assets/lightmapKernel';+import { encodeRgbaPng } from '../src/assets/png';+import { decodeRgbaPng } from '../src/assets/tilesetExtrude';++let dir = '';+let kernel: BakeKernelExecutor;++function quad(half: number, y: number, facing: 1 | -1): MeshData {+ const p = [[-half, y, -half], [half, y, -half], [half, y, half], [-half, y, half]];+ const vertices = new Uint8Array(4 * 24);+ const view = new DataView(vertices.buffer);+ p.forEach((q, i) => {+ q.forEach((v, k) => view.setFloat32(i * 24 + k * 4, v, true));+ view.setFloat32(i * 24 + 16, facing, true);+ });+ return unwrapLightmapUV({+ channels: [+ { semantic: MeshChannel.Position, components: 3, type: MeshChannelType.Float32, offset: 0 },+ { semantic: MeshChannel.Normal, components: 3, type: MeshChannelType.Float32, offset: 12 },+ ],+ vertexStride: 24, vertexCount: 4, vertices,+ indices: Uint32Array.from(facing > 0 ? [0, 2, 1, 0, 3, 2] : [0, 1, 2, 0, 2, 3]),+ aabbMin: [-half, y, -half], aabbMax: [half, y, half],+ }).mesh;+}++beforeAll(async () => {+ dir = await mkdtemp(path.join(tmpdir(), 'estella-kernel-'));+ await writeFile(path.join(dir, 'floor.esmesh'), encodeMesh(quad(4, 0, 1)));+ await writeFile(path.join(dir, 'roof.esmesh'), encodeMesh(quad(1.5, 1, -1)));+ await writeFile(path.join(dir, 'shelf.esmesh'), encodeMesh(quad(0.8, 0.5, 1)));+ // Closer above the floor than half a lumel: the floor's rays pass its back.+ await writeFile(path.join(dir, 'decal.esmesh'), encodeMesh(quad(2.5, 0.03, 1)));+ const holes = new Uint8Array(4 * 4 * 4).fill(200);+ for (let i = 8; i < 16; i++) holes[i * 4 + 3] = 0;+ await writeFile(path.join(dir, 'holes.png'), encodeRgbaPng(4, 4, holes));+ await writeFile(path.join(dir, 'cutout.esmaterial'), JSON.stringify(+ { version: '1.0', type: 'material', shader: 'builtin:model', properties: { u_alphaCutoff: 0.5 } }));+ kernel = await BakeKernelExecutor.load();+});++afterAll(async () => {+ await kernel?.close();+ await rm(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });+});++const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];+const LIGHTS: BakeLight[] = [+ { kind: 'point', position: [2, 3, 1], color: [1, 0.8, 0.6], intensity: 5, radius: 20 },+ { kind: 'spot', position: [-1, 2.5, -1], direction: [0.2, -1, 0.1], color: [0.4, 0.6, 1], intensity: 8,+ radius: 10, innerCos: 0.95, outerCos: 0.8 },+ { kind: 'directional', direction: [-0.4, -1, -0.3], color: [1, 0.95, 0.9], intensity: 2 },+];+const SH = Array.from({ length: 27 }, (_, i) => [0.9, 0.3, -0.2, 0.25, 0.1, -0.05, 0.08, 0.04, -0.06][Math.floor(i / 3)]!+ * [1, 0.9, 1.2][i % 3]!);++function scene(sky: boolean): SceneBakeInput {+ return {+ surfaces: [+ { meshFile: path.join(dir, 'floor.esmesh'), label: 'Floor', transform: IDENTITY,+ baseColor: [0.7, 0.6, 0.5], realtimeDirect: true },+ { meshFile: path.join(dir, 'roof.esmesh'), label: 'Roof', transform: IDENTITY,+ baseColorTexture: path.join(dir, 'holes.png'), material: path.join(dir, 'cutout.esmaterial'),+ twoSided: true },+ { meshFile: path.join(dir, 'shelf.esmesh'), label: 'Shelf', transform: IDENTITY,+ baseColor: [0.3, 0.8, 0.4] },+ { meshFile: path.join(dir, 'decal.esmesh'), label: 'Decal', transform: IDENTITY,+ baseColor: [0.9, 0.2, 0.2] },+ ],+ lights: LIGHTS,+ probeVolumes: [{ label: 'Air', center: [0, 0.5, 0], halfExtents: [2, 0.4, 2], spacing: 1 }],+ // No face size: the environment lights the gather and nothing is captured from it.+ environment: sky ? { document: { irradiance: SH }, atlasPng: new Uint8Array(0), rotation: 40 } : null,+ options: { atlasSize: 128, texelsPerUnit: 6, bounces: 2, samples: 32, ambient: [0.3, 0.4, 0.5] },+ } as SceneBakeInput;+}++function worstTexel(pngA: Uint8Array, pngB: Uint8Array): { worst: number; differing: number } {+ const a = decodeRgbaPng(pngA).rgba, b = decodeRgbaPng(pngB).rgba;+ expect(a.length).toBe(b.length);+ let worst = 0, differing = 0;+ for (let i = 0; i < a.length / 4; i++) {+ const x = decodeLightmap(a, i), y = decodeLightmap(b, i);+ let d = 0;+ for (let k = 0; k < 3; k++) d = Math.max(d, Math.abs(x[k]! - y[k]!) / Math.max(0.05, y[k]!));+ if (d > 0) differing++;+ worst = Math.max(worst, d);+ }+ return { worst, differing };+}++describe('the C++ bake kernel', () => {+ for (const sky of [false, true]) {+ it(`bakes what the TypeScript solve bakes (${sky ? 'SH' : 'flat'} sky)`, async () => {+ const ts = bakeSceneLightmap(scene(sky));+ const cpp = await bakeSceneLightmapParallel(scene(sky), kernel);+ expect(cpp.lumels).toBe(ts.lumels);+ const { worst } = worstTexel(cpp.atlasBytes, ts.atlasBytes);+ expect(worst).toBeLessThan(0.02);+ expect(cpp.probes.length).toBe(ts.probes.length);+ });+ }++ it('bakes the same bytes on one thread as on many', async () => {+ const saved = (kernel as unknown as { kernel: { threads: number } }).kernel;+ const threads = saved.threads;+ try {+ saved.threads = 1;+ const one = await bakeSceneLightmapParallel(scene(true), kernel);+ saved.threads = 5;+ const many = await bakeSceneLightmapParallel(scene(true), kernel);+ expect(Buffer.from(many.atlasBytes).equals(Buffer.from(one.atlasBytes))).toBe(true);+ } finally {+ saved.threads = threads;+ }+ });+});diff --git a/pipeline/tests/lightmap-parallel.test.ts b/pipeline/tests/lightmap-parallel.test.tsdeleted file mode 100644index 80a2f2664..000000000--- a/pipeline/tests/lightmap-parallel.test.ts+++ /dev/null@@ -1,86 +0,0 @@-// SPDX-License-Identifier: Apache-2.0-// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-/**- * @file A bake split across threads is the same bake: every lumel is solved on- * its own, so the atlas comes out byte for byte what one thread writes.- */-import { describe, it, expect, beforeAll, afterAll } from 'vitest';-import { mkdtemp, rm, writeFile } from 'node:fs/promises';-import { tmpdir } from 'node:os';-import path from 'node:path';-import { build } from 'esbuild';-import { encodeMesh, unwrapLightmapUV, MeshChannel, MeshChannelType, type MeshData, type BakeLight } from 'esengine';-import { bakeSceneLightmap, bakeSceneLightmapParallel, type SceneBakeInput } from '../src/assets/lightmapBake';-import { BakePool } from '../src/assets/lightmapPool';-import { encodeRgbaPng } from '../src/assets/png';--let dir = '';-let pool: BakePool;--function quad(half: number, y: number, facing: 1 | -1): MeshData {- const p = [[-half, y, -half], [half, y, -half], [half, y, half], [-half, y, half]];- const vertices = new Uint8Array(4 * 24);- const view = new DataView(vertices.buffer);- p.forEach((q, i) => {- q.forEach((v, k) => view.setFloat32(i * 24 + k * 4, v, true));- view.setFloat32(i * 24 + 16, facing, true);- });- return unwrapLightmapUV({- channels: [- { semantic: MeshChannel.Position, components: 3, type: MeshChannelType.Float32, offset: 0 },- { semantic: MeshChannel.Normal, components: 3, type: MeshChannelType.Float32, offset: 12 },- ],- vertexStride: 24, vertexCount: 4, vertices,- indices: Uint32Array.from(facing > 0 ? [0, 2, 1, 0, 3, 2] : [0, 1, 2, 0, 2, 3]),- aabbMin: [-half, y, -half], aabbMax: [half, y, half],- }).mesh;-}--beforeAll(async () => {- dir = await mkdtemp(path.join(tmpdir(), 'estella-parallel-'));- await writeFile(path.join(dir, 'floor.esmesh'), encodeMesh(quad(4, 0, 1)));- await writeFile(path.join(dir, 'roof.esmesh'), encodeMesh(quad(1.5, 1, -1)));- const holes = new Uint8Array(4 * 4 * 4).fill(200);- for (let i = 8; i < 16; i++) holes[i * 4 + 3] = 0;- await writeFile(path.join(dir, 'holes.png'), encodeRgbaPng(4, 4, holes));- await writeFile(path.join(dir, 'cutout.esmaterial'), JSON.stringify(- { version: '1.0', type: 'material', shader: 'builtin:model', properties: { u_alphaCutoff: 0.5 } }));- const worker = path.join(dir, 'lightmapWorker.mjs');- await build({ entryPoints: [path.resolve(__dirname, '../src/assets/lightmapWorker.ts')],- outfile: worker, bundle: true, format: 'esm', platform: 'node', logLevel: 'error' });- pool = new BakePool(worker, 3);-});--afterAll(async () => {- await pool?.close();- await rm(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });-});--const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];-const LAMP: BakeLight[] = [{ kind: 'point', position: [2, 3, 1], color: [1, 0.8, 0.6], intensity: 5, radius: 20 }];--function scene(): SceneBakeInput {- return {- surfaces: [- { meshFile: path.join(dir, 'floor.esmesh'), label: 'Floor', transform: IDENTITY,- baseColor: [0.7, 0.6, 0.5], realtimeDirect: true },- { meshFile: path.join(dir, 'roof.esmesh'), label: 'Roof', transform: IDENTITY,- baseColorTexture: path.join(dir, 'holes.png'), material: path.join(dir, 'cutout.esmaterial'),- twoSided: true },- ],- lights: LAMP,- probeVolumes: [{ label: 'Air', center: [0, 0.5, 0], halfExtents: [2, 0.4, 2], spacing: 1 }],- options: { atlasSize: 128, texelsPerUnit: 6, bounces: 2, samples: 16, ambient: [0.3, 0.4, 0.5] },- } as SceneBakeInput;-}--describe('a bake split across threads', () => {- it('writes the atlas and the probes one thread writes', async () => {- const one = bakeSceneLightmap(scene());- const many = await bakeSceneLightmapParallel(scene(), pool);- expect(many.lumels).toBe(one.lumels);- expect(many.lumels).toBeGreaterThan(pool.threads * 64);- expect(Buffer.from(many.atlasBytes).equals(Buffer.from(one.atlasBytes))).toBe(true);- expect(many.probes).toEqual(one.probes);- });-});diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex fde02b1be..516aae8fa 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -1,7 +1,7 @@# API surface — esengine/index<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 91 beta · 1524 experimental · 3 deprecated+Symbols: 115 public · 91 beta · 1523 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -1384,13 +1384,6 @@ resolveUrl: (path: string) => stringsetBaseUrl: ((url: string) => void) | undefined```-## BakeAlloc — interface @experimental-```-f32: (length: number) => Float32Array-i32: (length: number) => Int32Array-u8: (length: number) => Uint8Array-```-## BakeInputs — interface @experimental```ambient: readonly [number, number, number] | undefined@@ -1461,12 +1454,12 @@ size: number## BakeScene — interface @experimental```atlasSize: number-bvh: BvhPartslights: readonly BakeLight[]lookup: HitLookuplumels: LumelFieldsamples: numbersky: SkySpec | SkyRadiance+tris: TriangleSoup```## BakeStep — interface @experimental@@ -10107,7 +10100,7 @@ AudioPlugin## bakeLightmapSteps — function @experimental```-(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions, alloc?: BakeAlloc): Generator<BakeStep, BakeResult, void>+(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): Generator<BakeStep, BakeResult, void>```## bakeRunner — function @experimentaldiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex 458249a8e..9732af566 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.native<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 115 public · 96 beta · 1543 experimental · 3 deprecated+Symbols: 115 public · 96 beta · 1542 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -1384,13 +1384,6 @@ resolveUrl: (path: string) => stringsetBaseUrl: ((url: string) => void) | undefined```-## BakeAlloc — interface @experimental-```-f32: (length: number) => Float32Array-i32: (length: number) => Int32Array-u8: (length: number) => Uint8Array-```-## BakeInputs — interface @experimental```ambient: readonly [number, number, number] | undefined@@ -1461,12 +1454,12 @@ size: number## BakeScene — interface @experimental```atlasSize: number-bvh: BvhPartslights: readonly BakeLight[]lookup: HitLookuplumels: LumelFieldsamples: numbersky: SkySpec | SkyRadiance+tris: TriangleSoup```## BakeStep — interface @experimental@@ -10323,7 +10316,7 @@ AudioPlugin## bakeLightmapSteps — function @experimental```-(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions, alloc?: BakeAlloc): Generator<BakeStep, BakeResult, void>+(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): Generator<BakeStep, BakeResult, void>```## bakeRunner — function @experimentaldiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 31517f338..d7455d733 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: 115 public · 93 beta · 1523 experimental · 3 deprecated+Symbols: 115 public · 93 beta · 1522 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -1379,13 +1379,6 @@ resolveUrl: (path: string) => stringsetBaseUrl: ((url: string) => void) | undefined```-## BakeAlloc — interface @experimental-```-f32: (length: number) => Float32Array-i32: (length: number) => Int32Array-u8: (length: number) => Uint8Array-```-## BakeInputs — interface @experimental```ambient: readonly [number, number, number] | undefined@@ -1456,12 +1449,12 @@ size: number## BakeScene — interface @experimental```atlasSize: number-bvh: BvhPartslights: readonly BakeLight[]lookup: HitLookuplumels: LumelFieldsamples: numbersky: SkySpec | SkyRadiance+tris: TriangleSoup```## BakeStep — interface @experimental@@ -10102,7 +10095,7 @@ AudioPlugin## bakeLightmapSteps — function @experimental```-(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions, alloc?: BakeAlloc): Generator<BakeStep, BakeResult, void>+(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): Generator<BakeStep, BakeResult, void>```## bakeRunner — function @experimentaldiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex cf995b1f4..830d470d6 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: 115 public · 91 beta · 1545 experimental · 3 deprecated+Symbols: 115 public · 91 beta · 1544 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -1379,13 +1379,6 @@ resolveUrl: (path: string) => stringsetBaseUrl: ((url: string) => void) | undefined```-## BakeAlloc — interface @experimental-```-f32: (length: number) => Float32Array-i32: (length: number) => Int32Array-u8: (length: number) => Uint8Array-```-## BakeInputs — interface @experimental```ambient: readonly [number, number, number] | undefined@@ -1456,12 +1449,12 @@ size: number## BakeScene — interface @experimental```atlasSize: number-bvh: BvhPartslights: readonly BakeLight[]lookup: HitLookuplumels: LumelFieldsamples: numbersky: SkySpec | SkyRadiance+tris: TriangleSoup```## BakeStep — interface @experimental@@ -10378,7 +10371,7 @@ AudioPlugin## bakeLightmapSteps — function @experimental```-(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions, alloc?: BakeAlloc): Generator<BakeStep, BakeResult, void>+(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): Generator<BakeStep, BakeResult, void>```## bakeRunner — function @experimentaldiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex aa8b9cbc1..00a5c6236 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: 115 public · 91 beta · 1536 experimental · 3 deprecated+Symbols: 115 public · 91 beta · 1535 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -1379,13 +1379,6 @@ resolveUrl: (path: string) => stringsetBaseUrl: ((url: string) => void) | undefined```-## BakeAlloc — interface @experimental-```-f32: (length: number) => Float32Array-i32: (length: number) => Int32Array-u8: (length: number) => Uint8Array-```-## BakeInputs — interface @experimental```ambient: readonly [number, number, number] | undefined@@ -1456,12 +1449,12 @@ size: number## BakeScene — interface @experimental```atlasSize: number-bvh: BvhPartslights: readonly BakeLight[]lookup: HitLookuplumels: LumelFieldsamples: numbersky: SkySpec | SkyRadiance+tris: TriangleSoup```## BakeStep — interface @experimental@@ -10133,7 +10126,7 @@ AudioPlugin## bakeLightmapSteps — function @experimental```-(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions, alloc?: BakeAlloc): Generator<BakeStep, BakeResult, void>+(surfaces: readonly BakeSurface[], lights: readonly BakeLight[], options?: BakeOptions): Generator<BakeStep, BakeResult, void>```## bakeRunner — function @experimentaldiff --git a/sdk/src/core-content.ts b/sdk/src/core-content.tsindex 9809dd3dc..fb28edb5e 100644--- a/sdk/src/core-content.ts+++ b/sdk/src/core-content.ts@@ -158,7 +158,7 @@ export {captureReflection, flatSky, type CapturedPanorama, type SkyRadiance,LIGHTMAP_RANGE, encodeLightmap, decodeLightmap,bakeLightmapSteps, bakeRunner, type BakeScene, type BakeJob, type BakeStep,- skyRadiance, type SkySpec, type BakeAlloc,+ skyRadiance, type SkySpec,} from './lightmap';/*** What a scene declares about its baked light: the knobs, and the fingerprint ofdiff --git a/sdk/src/lightmap/alloc.ts b/sdk/src/lightmap/alloc.tsdeleted file mode 100644index 9ea1566b2..000000000--- a/sdk/src/lightmap/alloc.ts+++ /dev/null@@ -1,27 +0,0 @@-// SPDX-License-Identifier: Apache-2.0-// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-/**- * @file alloc.ts- * @brief Where a bake's large arrays live: ordinary memory on one thread, memory- * every worker can see when the solve is split across several.- */--export interface BakeAlloc {- f32(length: number): Float32Array;- i32(length: number): Int32Array;- u8(length: number): Uint8Array;-}--export const plainAlloc: BakeAlloc = {- f32: (n) => new Float32Array(n),- i32: (n) => new Int32Array(n),- u8: (n) => new Uint8Array(n),-};--/** A copy of `src` in memory `alloc` hands out. */-export function adopt<T extends Float32Array | Int32Array | Uint8Array>(src: T, alloc: BakeAlloc): T {- const out = (src instanceof Float32Array ? alloc.f32(src.length)- : src instanceof Int32Array ? alloc.i32(src.length) : alloc.u8(src.length)) as T;- out.set(src as never);- return out;-}diff --git a/sdk/src/lightmap/bake.ts b/sdk/src/lightmap/bake.tsindex 7a3a411df..b30855bcc 100644--- a/sdk/src/lightmap/bake.ts+++ b/sdk/src/lightmap/bake.ts@@ -15,10 +15,8 @@ import {layoutAtlas, rasterizeLumels, atlasDemand, SPARSE_LIGHTMAP_UV, type BakeSurface, type SurfacePatch,} from './atlas';import { solveDirect, solveGather, type BakeLight, type HitLookup } from './solve';-import { plainAlloc, adopt, type BakeAlloc } from './alloc';import { skyRadiance, type SkySpec } from './sky';import type { LumelField } from './atlas';-import type { BvhParts } from './bvh';import { solveProbes, type ProbeGrid } from './probes';import { captureReflection, flatSky, type CapturedPanorama, type SkyRadiance }from './reflection';@@ -104,18 +102,17 @@ const chan = (m: MeshData, s: number): MeshChannelDesc | undefined =>/** Every surface's triangles in world space, plus what a ray hit has to know. */function collect(surfaces: readonly BakeSurface[], patches: readonly SurfacePatch[],- size: number, texelsPerUnit: number,- alloc: BakeAlloc): { soup: TriangleSoup; lookup: HitLookup } {+ size: number, texelsPerUnit: number): { soup: TriangleSoup; lookup: HitLookup } {let total = 0;for (const s of surfaces) total += Math.floor(s.mesh.indices.length / 3);- const positions = alloc.f32(total * 9);- const triUV = alloc.f32(total * 6);- const triSurface = alloc.i32(total);- const patch = alloc.f32(surfaces.length * 4);- const albedo = alloc.f32(surfaces.length * 3);- const triNormal = alloc.f32(total * 3);- const twoSided = alloc.u8(surfaces.length);- const coverage = alloc.f32(surfaces.length);+ const positions = new Float32Array(total * 9);+ const triUV = new Float32Array(total * 6);+ 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);+ const twoSided = new Uint8Array(surfaces.length);+ const coverage = new Float32Array(surfaces.length);let at = 0;for (let s = 0; s < surfaces.length; s++) {@@ -267,7 +264,7 @@ function refusal(surfaces: readonly BakeSurface[], size: number, texelsPerUnit:/** Everything a solve step reads, as arrays another thread can be handed. */export interface BakeScene {lumels: LumelField;- bvh: BvhParts;+ tris: TriangleSoup;lookup: HitLookup;lights: readonly BakeLight[];sky: SkySpec | SkyRadiance;@@ -288,7 +285,7 @@ export interface BakeStep {/** Runs jobs against one scene over any range of its lumels; one per thread. */export function bakeRunner(scene: BakeScene): (job: BakeJob, from: number, to: number) => void {- const bvh = new Bvh(scene.bvh);+ const bvh = new Bvh(scene.tris);const sky = typeof scene.sky === 'function' ? scene.sky : skyRadiance(scene.sky);return (job, from, to) => {if (job.kind === 'direct') solveDirect(scene.lumels, bvh, scene.lookup, scene.lights, job.out, from, to);@@ -298,41 +295,30 @@ export function bakeRunner(scene: BakeScene): (job: BakeJob, from: number, to: n/*** A bake as its passes, in order: the driver runs each yielded job over every- * lumel, on one thread or many, before asking for the next; `alloc` decides where- * a job's arrays live. Throws when the surfaces do not fit rather than shrinking+ * lumel, on one thread or many, before asking for the next. Throws when the surfaces do not fit rather than shrinking* one, which would light it at a different resolution from its neighbours.*/export function* bakeLightmapSteps(surfaces: readonly BakeSurface[], lights: readonly BakeLight[],- options: BakeOptions = {},- alloc: BakeAlloc = plainAlloc): Generator<BakeStep, BakeResult, void> {+ options: BakeOptions = {}): Generator<BakeStep, BakeResult, void> {const opts = { ...BAKE_DEFAULTS, ...options };const size = opts.atlasSize;const patches = layoutAtlas(surfaces, size, opts.texelsPerUnit);if (!patches) throw new Error(refusal(surfaces, size, opts.texelsPerUnit));- const raster = rasterizeLumels(surfaces, patches, size);- const lumels: LumelField = {- count: raster.count,- position: adopt(raster.position, alloc),- normal: adopt(raster.normal, alloc),- texel: adopt(raster.texel, alloc),- surface: adopt(raster.surface, alloc),- shared: raster.shared,- };- const { soup, lookup } = collect(surfaces, patches, size, opts.texelsPerUnit, alloc);- const bvh = new Bvh(soup, alloc);+ const lumels = rasterizeLumels(surfaces, patches, size);+ const { soup, lookup } = collect(surfaces, patches, size, opts.texelsPerUnit);const skyOf = options.sky ?? { kind: 'flat', rgb: opts.ambient };- const scene: BakeScene = { lumels, bvh: bvh.parts(), lookup, lights, sky: skyOf,+ const scene: BakeScene = { lumels, tris: soup, lookup, lights, sky: skyOf,atlasSize: size, samples: opts.samples };const sky = typeof skyOf === 'function' ? skyOf : skyRadiance(skyOf);- const direct = alloc.f32(lumels.count * 3);+ const direct = new Float32Array(lumels.count * 3);yield { scene, job: { kind: 'direct', out: direct } };// Each pass gathers against what every texel gave off after the pass before,// so pass n carries light n surfaces along. With no bounce the surfaces give// off nothing and the pass is the sky alone, still shadowed by them.- const outgoing = alloc.f32(size * size * 3);- const indirect = alloc.f32(lumels.count * 3);+ const outgoing = new Float32Array(size * size * 3);+ const indirect = new Float32Array(lumels.count * 3);for (let pass = 0; pass < Math.max(1, opts.bounces); pass++) {if (opts.bounces > 0) {for (let i = 0; i < lumels.count; i++) {@@ -364,15 +350,17 @@ export function* bakeLightmapSteps(surfaces: readonly BakeSurface[], lights: rea// The probes read the atlas as a gather does — after it holds everything the// surfaces ended up giving off, and before it is quantised to eight bits.+ let built: Bvh | null = null;+ const bvh = (): Bvh => (built ??= new Bvh(soup));const probes = opts.probeGrids.map((grid) =>- solveProbes(grid, bvh, lookup, radiance, size, opts.probeSamples, sky));+ solveProbes(grid, bvh(), lookup, radiance, size, opts.probeSamples, sky));// Captured from the same field, after the same bounces: a reflection of a// wall and the light that wall casts are then the same number.const width = Math.max(8, opts.reflectionWidth);const captured = options.reflectionSky ?? flatSky(opts.ambient);const reflections = opts.reflectionProbes.map((at) =>- captureReflection(at, bvh, lookup, radiance, size, width, Math.max(4, width >> 1), captured));+ captureReflection(at, bvh(), lookup, radiance, size, width, Math.max(4, width >> 1), captured));return {pixels,diff --git a/sdk/src/lightmap/bvh.ts b/sdk/src/lightmap/bvh.tsindex 1e8ae15c7..cb5a4ab89 100644--- a/sdk/src/lightmap/bvh.ts+++ b/sdk/src/lightmap/bvh.ts@@ -10,24 +10,12 @@* cost of the pass.*/-import { plainAlloc, type BakeAlloc } from './alloc';-/** Triangles as `9 * count` floats: three world-space corners each. */export interface TriangleSoup {positions: Float32Array;count: number;}-/** A built tree as plain arrays, which another thread can walk without rebuilding. */-export interface BvhParts {- tris: TriangleSoup;- bounds: Float32Array;- node: Int32Array;- order: Int32Array;- used: number;- depth: number;-}-const LEAF_TRIS = 4;/** The count an inner node carries: a leaf's is never negative, an empty one included. */const INNER = -1;@@ -48,33 +36,18 @@ export class Bvh {* fixed stack drops the deepest ones without a word. */private readonly stack: Int32Array;- constructor(tris: TriangleSoup | BvhParts, alloc: BakeAlloc = plainAlloc) {- if ('bounds' in tris) {- this.tris = tris.tris;- this.order = tris.order;- this.bounds = tris.bounds;- this.node = tris.node;- this.used = tris.used;- this.depth = tris.depth;- } else {- this.tris = tris;- this.order = alloc.i32(tris.count);- for (let i = 0; i < tris.count; i++) this.order[i] = i;- const maxNodes = Math.max(1, tris.count * 2);- this.bounds = alloc.f32(maxNodes * 6);- this.node = alloc.i32(maxNodes * 2);- this.used = 1;- this.build(0, 0, tris.count, 0);- }+ constructor(tris: TriangleSoup) {+ this.tris = tris;+ this.order = new Int32Array(tris.count);+ for (let i = 0; i < tris.count; i++) this.order[i] = i;+ const maxNodes = Math.max(1, tris.count * 2);+ this.bounds = new Float32Array(maxNodes * 6);+ this.node = new Int32Array(maxNodes * 2);+ this.used = 1;+ this.build(0, 0, tris.count, 0);this.stack = new Int32Array(this.depth + 2);}- /** The tree as arrays, to walk from another thread with `new Bvh(parts)`. */- parts(): BvhParts {- return { tris: this.tris, bounds: this.bounds, node: this.node, order: this.order,- used: this.used, depth: this.depth };- }-private centroid(tri: number, axis: number): number {const at = this.order[tri] * 9;return (this.tris.positions[at + axis] + this.tris.positions[at + 3 + axis]@@ -195,6 +168,9 @@ export class Bvh {const t = this.intersect(tri, ox, oy, oz, dx, dy, dz, epsilon, bestT);if (t < 0) continue;if (anyHit) { this.hitDistance = t; return tri; }+ // A tie goes to the lower index, so the answer is the geometry's and+ // not the order a tree happens to visit coincident triangles in.+ if (t === bestT && (best < 0 || tri > best)) continue;bestT = t; best = tri;this.hitU = this.lastU; this.hitV = this.lastV;}@@ -225,7 +201,7 @@ export class Bvh {const v = f * (dx * qx + dy * qy + dz * qz);if (v < 0 || u + v > 1) return -1;const t = f * (e2x * qx + e2y * qy + e2z * qz);- if (t <= epsilon || t >= far) return -1;+ if (t <= epsilon || t > far) return -1;this.lastU = u; this.lastV = v;return t;}diff --git a/sdk/src/lightmap/index.ts b/sdk/src/lightmap/index.tsindex 242aa99b9..b401562ca 100644--- a/sdk/src/lightmap/index.ts+++ b/sdk/src/lightmap/index.ts@@ -4,7 +4,6 @@ export { unwrapLightmapUV, type UnwrapOptions, type UnwrapResult } from './unwraexport { bakeLightmap, bakeLightmapSteps, bakeRunner, LIGHTMAP_RANGE, encodeLightmap, decodeLightmap,type BakeOptions, type BakeResult, type BakeScene, type BakeJob, type BakeStep } from './bake';export { skyRadiance, type SkySpec } from './sky';-export type { BakeAlloc } from './alloc';export type { BakeSurface } from './atlas';export type { BakeLight } from './solve';export { solveProbes, probeAt, type ProbeGrid } from './probes';diff --git a/tools/lightmap-wasm/build.mjs b/tools/lightmap-wasm/build.mjsnew file mode 100644index 000000000..997d77579--- /dev/null+++ b/tools/lightmap-wasm/build.mjs@@ -0,0 +1,38 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file Build the lightmap bake kernel into the committed+ * build-tools/lightmap/lightmap-kernel.{mjs,wasm}. Rerun after editing+ * kernel.cpp.+ *+ * node tools/lightmap-wasm/build.mjs+ */+import { execFileSync } from 'node:child_process';+import { statSync } from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import { ensureEmscriptenEnv } from '../../build-tools/utils/emscripten.js';++const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');+const OUT = path.join(ROOT, 'build-tools', 'lightmap', 'lightmap-kernel.mjs');++await ensureEmscriptenEnv();++const EXPORTS = ['_lm_scene', '_lm_direct', '_lm_gather', '_malloc', '_free'];++execFileSync('em++', [+ path.join(ROOT, 'tools', 'lightmap-wasm', 'kernel.cpp'),+ '-O3', '-std=c++17', '-msimd128', '-pthread',+ '-sMODULARIZE=1', '-sEXPORT_ES6=1', '-sENVIRONMENT=node,worker',+ '-sALLOW_MEMORY_GROWTH=1', '-sMAXIMUM_MEMORY=4GB',+ // Workers exist before the first bake, so starting its threads never waits on+ // the event loop the bake is blocking.+ '-sPTHREAD_POOL_SIZE=((typeof navigator!=="undefined"&&navigator.hardwareConcurrency)||8)',+ '-sSTACK_SIZE=1048576',+ `-sEXPORTED_FUNCTIONS=${EXPORTS.join(',')}`,+ '-sEXPORTED_RUNTIME_METHODS=HEAPU8,HEAPF32,HEAP32',+ '-o', OUT,+], { stdio: 'inherit', shell: process.platform === 'win32' });++const wasm = OUT.replace(/\.mjs$/, '.wasm');+console.log(`OK -> ${OUT} (${(statSync(wasm).size / 1024).toFixed(0)} KB wasm)`);diff --git a/tools/lightmap-wasm/kernel.cpp b/tools/lightmap-wasm/kernel.cppnew file mode 100644index 000000000..e673a126b--- /dev/null+++ b/tools/lightmap-wasm/kernel.cpp@@ -0,0 +1,503 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file kernel.cpp+ * @brief The lightmap solve's ray casting, in C++ on every core: an SAH-built+ * BVH and the two per-lumel passes, direct and gather.+ *+ * The rules are sdk/src/lightmap/solve.ts's, term for term — the sample set,+ * the cutout hash, the back-face reach, the sky — computed in double precision+ * as that code is, so the two agree to rounding. Each lumel writes only its own+ * results, so the answer does not depend on how the threads divide the work.+ */++#include <algorithm>+#include <atomic>+#include <cmath>+#include <cstdint>+#include <thread>+#include <vector>++namespace {++constexpr double kShadowEpsilon = 1e-3;+constexpr int kLeafTris = 4;+constexpr int kBins = 16;++struct Node {+ float lo[3];+ float hi[3];+ int first; // a leaf's first triangle in `order`, or an inner node's left child+ int count; // -1 for an inner node, whose right child follows its left+};++struct Scene {+ const float* pos = nullptr;+ int triCount = 0;+ const float* triUV = nullptr;+ const int* triSurface = nullptr;+ const float* patch = nullptr;+ const float* albedo = nullptr;+ const float* triNormal = nullptr;+ const uint8_t* twoSided = nullptr;+ const float* coverage = nullptr;+ bool cutouts = false;+ double backReach = 0;+ std::vector<Node> nodes;+ std::vector<int> order;+};++Scene g_scene;++struct Hit {+ double t = 0, u = 0, v = 0;+};++void boundsOf(const Scene& s, const int* tris, int n, float* lo, float* hi) {+ for (int k = 0; k < 3; ++k) { lo[k] = INFINITY; hi[k] = -INFINITY; }+ for (int i = 0; i < n; ++i) {+ const float* p = s.pos + static_cast<size_t>(tris[i]) * 9;+ for (int c = 0; c < 3; ++c) {+ for (int k = 0; k < 3; ++k) {+ lo[k] = std::min(lo[k], p[c * 3 + k]);+ hi[k] = std::max(hi[k], p[c * 3 + k]);+ }+ }+ }+}++double area(const float* lo, const float* hi) {+ const double x = hi[0] - lo[0], y = hi[1] - lo[1], z = hi[2] - lo[2];+ if (!(x >= 0 && y >= 0 && z >= 0)) return 0;+ return x * y + y * z + z * x;+}++/** Binned SAH: the split that makes a ray's expected cost smallest, tried per axis. */+void build(Scene& s, const std::vector<float>& centroid, int node, int from, int to) {+ Node& self = s.nodes[node];+ boundsOf(s, s.order.data() + from, to - from, self.lo, self.hi);+ const int n = to - from;+ if (n <= kLeafTris) { self.first = from; self.count = n; return; }++ float clo[3] = {INFINITY, INFINITY, INFINITY}, chi[3] = {-INFINITY, -INFINITY, -INFINITY};+ for (int i = from; i < to; ++i) {+ for (int k = 0; k < 3; ++k) {+ const float c = centroid[static_cast<size_t>(s.order[i]) * 3 + k];+ clo[k] = std::min(clo[k], c); chi[k] = std::max(chi[k], c);+ }+ }+ int bestAxis = -1, bestBin = 0;+ double bestCost = INFINITY;+ for (int axis = 0; axis < 3; ++axis) {+ const double extent = chi[axis] - clo[axis];+ if (!(extent > 0)) continue;+ int count[kBins] = {};+ float lo[kBins][3], hi[kBins][3];+ for (int b = 0; b < kBins; ++b) for (int k = 0; k < 3; ++k) { lo[b][k] = INFINITY; hi[b][k] = -INFINITY; }+ for (int i = from; i < to; ++i) {+ const int tri = s.order[i];+ int b = static_cast<int>((centroid[static_cast<size_t>(tri) * 3 + axis] - clo[axis]) / extent * kBins);+ b = std::min(kBins - 1, std::max(0, b));+ ++count[b];+ const float* p = s.pos + static_cast<size_t>(tri) * 9;+ for (int c = 0; c < 3; ++c) for (int k = 0; k < 3; ++k) {+ lo[b][k] = std::min(lo[b][k], p[c * 3 + k]); hi[b][k] = std::max(hi[b][k], p[c * 3 + k]);+ }+ }+ // Sweep from the right, then from the left, pricing each boundary.+ double rightArea[kBins]; int rightCount[kBins];+ float rlo[3] = {INFINITY, INFINITY, INFINITY}, rhi[3] = {-INFINITY, -INFINITY, -INFINITY};+ int rc = 0;+ for (int b = kBins - 1; b > 0; --b) {+ rc += count[b];+ for (int k = 0; k < 3; ++k) { rlo[k] = std::min(rlo[k], lo[b][k]); rhi[k] = std::max(rhi[k], hi[b][k]); }+ rightArea[b] = area(rlo, rhi); rightCount[b] = rc;+ }+ float llo[3] = {INFINITY, INFINITY, INFINITY}, lhi[3] = {-INFINITY, -INFINITY, -INFINITY};+ int lc = 0;+ for (int b = 0; b < kBins - 1; ++b) {+ lc += count[b];+ for (int k = 0; k < 3; ++k) { llo[k] = std::min(llo[k], lo[b][k]); lhi[k] = std::max(lhi[k], hi[b][k]); }+ if (lc == 0 || rightCount[b + 1] == 0) continue;+ const double cost = area(llo, lhi) * lc + rightArea[b + 1] * rightCount[b + 1];+ if (cost < bestCost) { bestCost = cost; bestAxis = axis; bestBin = b; }+ }+ }++ int split = from;+ if (bestAxis >= 0) {+ const double extent = chi[bestAxis] - clo[bestAxis];+ auto mid = std::partition(s.order.begin() + from, s.order.begin() + to, [&](int tri) {+ int b = static_cast<int>((centroid[static_cast<size_t>(tri) * 3 + bestAxis] - clo[bestAxis]) / extent * kBins);+ b = std::min(kBins - 1, std::max(0, b));+ return b <= bestBin;+ });+ split = static_cast<int>(mid - s.order.begin());+ }+ // Every centroid in one bin (or on one point): split down the middle so the+ // recursion still shrinks.+ if (split == from || split == to) split = (from + to) / 2;++ const int left = static_cast<int>(s.nodes.size());+ s.nodes.push_back({});+ s.nodes.push_back({});+ s.nodes[node].first = left;+ s.nodes[node].count = -1;+ build(s, centroid, left, from, split);+ build(s, centroid, left + 1, split, to);+}++// A slab product is NaN only for a zero direction component. Such a ray takes+// Math.min/Math.max's rule (NaN wins: the box is visited) via wasm's f64.min/max;+// every other ray takes the plain compare, which costs far less.+template <bool Exact> inline double jsMin(double a, double b) { return Exact ? __builtin_wasm_min_f64(a, b) : (a < b ? a : b); }+template <bool Exact> inline double jsMax(double a, double b) { return Exact ? __builtin_wasm_max_f64(a, b) : (a > b ? a : b); }++/** Slab test; the entry distance, or +inf when the box is missed within (eps, far). */+template <bool Exact>+inline double enter(const Node& n, double ox, double oy, double oz, double ix, double iy, double iz,+ double epsilon, double far) {+ const double tx1 = (n.lo[0] - ox) * ix, tx2 = (n.hi[0] - ox) * ix;+ double tmin = jsMin<Exact>(tx1, tx2), tmax = jsMax<Exact>(tx1, tx2);+ const double ty1 = (n.lo[1] - oy) * iy, ty2 = (n.hi[1] - oy) * iy;+ tmin = jsMax<Exact>(tmin, jsMin<Exact>(ty1, ty2)); tmax = jsMin<Exact>(tmax, jsMax<Exact>(ty1, ty2));+ const double tz1 = (n.lo[2] - oz) * iz, tz2 = (n.hi[2] - oz) * iz;+ tmin = jsMax<Exact>(tmin, jsMin<Exact>(tz1, tz2)); tmax = jsMin<Exact>(tmax, jsMax<Exact>(tz1, tz2));+ if (tmax < jsMax<Exact>(tmin, epsilon) || tmin > far) return INFINITY;+ return tmin != tmin ? -INFINITY : tmin;+}++/** Möller–Trumbore, both faces, as the TypeScript BVH has it; `far` itself is a hit. */+inline bool intersect(const Scene& s, int tri, double ox, double oy, double oz,+ double dx, double dy, double dz, double epsilon, double far, Hit& hit) {+ const float* p = s.pos + static_cast<size_t>(tri) * 9;+ const double e1x = static_cast<double>(p[3]) - p[0], e1y = static_cast<double>(p[4]) - p[1], e1z = static_cast<double>(p[5]) - p[2];+ const double e2x = static_cast<double>(p[6]) - p[0], e2y = static_cast<double>(p[7]) - p[1], e2z = static_cast<double>(p[8]) - p[2];+ const double hx = dy * e2z - dz * e2y, hy = dz * e2x - dx * e2z, hz = dx * e2y - dy * e2x;+ const double a = e1x * hx + e1y * hy + e1z * hz;+ if (a > -1e-12 && a < 1e-12) return false;+ const double f = 1 / a;+ const double sx = ox - p[0], sy = oy - p[1], sz = oz - p[2];+ const double u = f * (sx * hx + sy * hy + sz * hz);+ if (u < 0 || u > 1) return false;+ const double qx = sy * e1z - sz * e1y, qy = sz * e1x - sx * e1z, qz = sx * e1y - sy * e1x;+ const double v = f * (dx * qx + dy * qy + dz * qz);+ if (v < 0 || u + v > 1) return false;+ const double t = f * (e2x * qx + e2y * qy + e2z * qz);+ if (t <= epsilon || t > far) return false;+ hit.t = t; hit.u = u; hit.v = v;+ return true;+}++/** The nearest triangle in (epsilon, far], or -1; `anyHit` stops at the first. */+template <bool Exact>+int traceWith(const Scene& s, double ox, double oy, double oz, double dx, double dy, double dz,+ double far, double epsilon, bool anyHit, Hit& hit) {+ if (s.nodes.empty()) return -1;+ const double ix = 1 / dx, iy = 1 / dy, iz = 1 / dz;+ int best = -1;+ double bestT = far;+ int stack[128];+ int sp = 0;+ if (enter<Exact>(s.nodes[0], ox, oy, oz, ix, iy, iz, epsilon, bestT) == INFINITY) return -1;+ stack[sp++] = 0;+ Hit h;+ while (sp > 0) {+ const Node& n = s.nodes[stack[--sp]];+ if (n.count >= 0) {+ for (int k = 0; k < n.count; ++k) {+ const int tri = s.order[n.first + k];+ if (!intersect(s, tri, ox, oy, oz, dx, dy, dz, epsilon, bestT, h)) continue;+ if (anyHit) { hit = h; return tri; }+ if (h.t == bestT && (best < 0 || tri > best)) continue;+ bestT = h.t; best = tri; hit = h;+ }+ continue;+ }+ const Node& a = s.nodes[n.first];+ const Node& b = s.nodes[n.first + 1];+ const double ta = enter<Exact>(a, ox, oy, oz, ix, iy, iz, epsilon, bestT);+ const double tb = enter<Exact>(b, ox, oy, oz, ix, iy, iz, epsilon, bestT);+ // Nearer child on top: its hits shrink `bestT` before the farther is opened.+ if (ta <= tb) {+ if (tb != INFINITY) stack[sp++] = n.first + 1;+ if (ta != INFINITY) stack[sp++] = n.first;+ } else {+ if (ta != INFINITY) stack[sp++] = n.first;+ if (tb != INFINITY) stack[sp++] = n.first + 1;+ }+ }+ if (best >= 0) hit.t = bestT;+ return best;+}++int trace(const Scene& s, double ox, double oy, double oz, double dx, double dy, double dz,+ double far, double epsilon, bool anyHit, Hit& hit) {+ return dx == 0 || dy == 0 || dz == 0+ ? traceWith<true>(s, ox, oy, oz, dx, dy, dz, far, epsilon, anyHit, hit)+ : traceWith<false>(s, ox, oy, oz, dx, dy, dz, far, epsilon, anyHit, hit);+}++inline double lengthOr1(double x, double y, double z) {+ const double len = std::sqrt(x * x + y * y + z * z);+ return len > 0 ? len : 1;+}++inline bool facesRay(const Scene& s, int tri, double dx, double dy, double dz) {+ if (s.twoSided[s.triSurface[tri]]) return true;+ const float* n = s.triNormal + static_cast<size_t>(tri) * 3;+ return n[0] * dx + n[1] * dy + n[2] * dz < 0;+}++inline uint32_t mix32(uint32_t x) {+ x = (x ^ (x >> 16)) * 0x7feb352du;+ x = (x ^ (x >> 15)) * 0x846ca68bu;+ return x ^ (x >> 16);+}++int firstHit(const Scene& s, double ox, double oy, double oz, double dx, double dy, double dz,+ double far, double epsilon, uint32_t seed, double backReach, Hit& hit) {+ double travelled = 0;+ for (int step = 0; step < 16; ++step) {+ const int tri = trace(s, ox, oy, oz, dx, dy, dz, far - travelled,+ step == 0 ? epsilon : std::max(epsilon, kShadowEpsilon), false, hit);+ if (tri < 0) return -1;+ const bool near = travelled + hit.t < backReach && !facesRay(s, tri, dx, dy, dz);+ const double keep = s.coverage[s.triSurface[tri]];+ if (!near && (keep >= 1 || mix32(seed ^ (static_cast<uint32_t>(step + 1) * 0x9e3779b9u)) / 4294967296.0 < keep)) {+ return tri;+ }+ ox += dx * hit.t; oy += dy * hit.t; oz += dz * hit.t;+ travelled += hit.t;+ }+ return -1;+}++bool blocked(const Scene& s, double ox, double oy, double oz, double dx, double dy, double dz,+ double far, uint32_t seed) {+ Hit hit;+ if (!s.cutouts && !(s.backReach > 0)) {+ return trace(s, ox, oy, oz, dx, dy, dz, far, kShadowEpsilon, true, hit) >= 0;+ }+ return firstHit(s, ox, oy, oz, dx, dy, dz, far, kShadowEpsilon, seed, s.backReach, hit) >= 0;+}++int texelOf(const Scene& s, int tri, double u, double v, int size) {+ const float* uv = s.triUV + static_cast<size_t>(tri) * 6;+ const double w0 = 1 - u - v;+ const double uu = w0 * uv[0] + u * uv[2] + v * uv[4];+ const double vv = w0 * uv[1] + u * uv[3] + v * uv[5];+ const float* p = s.patch + static_cast<size_t>(s.triSurface[tri]) * 4;+ const bool rotated = p[3] != 0;+ const double side = p[2];+ const double x = std::floor(p[0] + (rotated ? vv : uu) * side);+ const double y = std::floor(p[1] + (rotated ? uu : vv) * side);+ if (x < 0 || y < 0 || x >= size || y >= size) return -1;+ return static_cast<int>(y) * size + static_cast<int>(x);+}++/** Cosine-weighted Hammersley directions, as solve.ts's `hemisphere`. */+std::vector<float> hemisphere(int samples) {+ std::vector<float> out(static_cast<size_t>(samples) * 3);+ for (int i = 0; i < samples; ++i) {+ uint32_t bits = static_cast<uint32_t>(i);+ bits = (bits << 16) | (bits >> 16);+ bits = ((bits & 0x55555555u) << 1) | ((bits & 0xaaaaaaaau) >> 1);+ bits = ((bits & 0x33333333u) << 2) | ((bits & 0xccccccccu) >> 2);+ bits = ((bits & 0x0f0f0f0fu) << 4) | ((bits & 0xf0f0f0f0u) >> 4);+ bits = ((bits & 0x00ff00ffu) << 8) | ((bits & 0xff00ff00u) >> 8);+ const double u = (i + 0.5) / samples;+ const double v = bits * 2.3283064365386963e-10;+ const double r = std::sqrt(u);+ const double phi = 2 * M_PI * v;+ out[i * 3] = static_cast<float>(r * std::cos(phi));+ out[i * 3 + 1] = static_cast<float>(r * std::sin(phi));+ out[i * 3 + 2] = static_cast<float>(std::sqrt(std::max(0.0, 1 - u)));+ }+ return out;+}++inline void frame(double nx, double ny, double nz, float* out) {+ const double sign = nz >= 0 ? 1 : -1;+ const double a = -1 / (sign + nz);+ const double b = nx * ny * a;+ out[0] = static_cast<float>(1 + sign * nx * nx * a); out[1] = static_cast<float>(sign * b);+ out[2] = static_cast<float>(-sign * nx); out[3] = static_cast<float>(b);+ out[4] = static_cast<float>(sign + ny * ny * a); out[5] = static_cast<float>(-ny);+}++/** The sky: kind 0 flat (rgb), kind 1 nine unconvolved coefficients turned by yaw and tinted. */+struct Sky {+ int kind = 0;+ double rgb[3] = {0, 0, 0};+ double radiance[27] = {};+ double c = 1, s = 0;+ double tint[3] = {1, 1, 1};++ void at(double dx, double dy, double dz, double* out) const {+ // Rounded to float where skyRadiance holds values in a Float32Array: the+ // basis, and what it writes out.+ if (kind == 0) { for (int k = 0; k < 3; ++k) out[k] = static_cast<float>(rgb[k]); return; }+ const double x = c * dx + s * dz, y = dy, z = -s * dx + c * dz;+ const float basis[9] = {+ 0.282095f, static_cast<float>(0.488603 * y), static_cast<float>(0.488603 * z),+ static_cast<float>(0.488603 * x), static_cast<float>(1.092548 * x * y),+ static_cast<float>(1.092548 * y * z), static_cast<float>(0.315392 * (3 * z * z - 1)),+ static_cast<float>(1.092548 * x * z), static_cast<float>(0.546274 * (x * x - y * y)),+ };+ for (int k = 0; k < 3; ++k) {+ double v = 0;+ for (int i = 0; i < 9; ++i) v += radiance[i * 3 + k] * basis[i];+ out[k] = static_cast<float>(std::max(0.0, v) * tint[k]);+ }+ }+};++/** Runs `body(i)` for every i in [0, count) on `threads` threads, in chunks. */+template <typename F>+void parallelFor(int count, int threads, F body) {+ std::atomic<int> next{0};+ const int chunk = std::max(64, count / std::max(1, threads * 32));+ auto work = [&]() {+ for (;;) {+ const int from = next.fetch_add(chunk);+ if (from >= count) return;+ const int to = std::min(count, from + chunk);+ for (int i = from; i < to; ++i) body(i);+ }+ };+ std::vector<std::thread> pool;+ for (int t = 1; t < threads; ++t) pool.emplace_back(work);+ work();+ for (auto& t : pool) t.join();+}++} // namespace++extern "C" {++/** Adopts the triangle arrays (the caller keeps them alive) and builds the tree. */+void lm_scene(const float* pos, int triCount, const float* triUV, const int* triSurface,+ const float* patch, const float* albedo, const float* triNormal,+ const uint8_t* twoSided, const float* coverage, int surfaceCount, double backReach) {+ Scene& s = g_scene;+ s.pos = pos; s.triCount = triCount; s.triUV = triUV; s.triSurface = triSurface;+ s.patch = patch; s.albedo = albedo; s.triNormal = triNormal; s.twoSided = twoSided;+ s.coverage = coverage; s.backReach = backReach;+ s.cutouts = false;+ for (int i = 0; i < surfaceCount; ++i) if (coverage[i] < 1) s.cutouts = true;+ s.order.resize(triCount);+ for (int i = 0; i < triCount; ++i) s.order[i] = i;+ std::vector<float> centroid(static_cast<size_t>(triCount) * 3);+ for (int t = 0; t < triCount; ++t) {+ const float* p = pos + static_cast<size_t>(t) * 9;+ for (int k = 0; k < 3; ++k) centroid[static_cast<size_t>(t) * 3 + k] = (p[k] + p[3 + k] + p[6 + k]) / 3;+ }+ s.nodes.clear();+ s.nodes.reserve(static_cast<size_t>(std::max(1, triCount)) * 2);+ s.nodes.push_back({});+ if (triCount > 0) build(s, centroid, 0, 0, triCount);+ else s.nodes.clear();+}++/**+ * Direct light at every lumel. `lights` is 16 doubles each: kind (0 directional,+ * 1 point, 2 spot), position 3, direction 3, colour 3, intensity, radius,+ * inner cos, outer cos, unused.+ */+void lm_direct(const float* position, const float* normal, int count,+ const double* lights, int lightCount, float* out, int threads) {+ const Scene& s = g_scene;+ parallelFor(count, threads, [&](int i) {+ const double px = position[i * 3], py = position[i * 3 + 1], pz = position[i * 3 + 2];+ const double nx = normal[i * 3], ny = normal[i * 3 + 1], nz = normal[i * 3 + 2];+ double r = 0, g = 0, b = 0;+ for (int li = 0; li < lightCount; ++li) {+ const double* L = lights + li * 16;+ const int kind = static_cast<int>(L[0]);+ double lx, ly, lz, distance, falloff = 1;+ if (kind == 0) {+ const double len = lengthOr1(L[4], L[5], L[6]);+ lx = -L[4] / len; ly = -L[5] / len; lz = -L[6] / len;+ distance = INFINITY;+ } else {+ lx = L[1] - px; ly = L[2] - py; lz = L[3] - pz;+ distance = std::sqrt(lx * lx + ly * ly + lz * lz);+ if (distance < 1e-6) continue;+ lx /= distance; ly /= distance; lz /= distance;+ const double radius = L[12];+ if (radius > 0) {+ if (distance >= radius) continue;+ const double k = 1 - distance / radius;+ falloff = k * k;+ }+ if (kind == 2) {+ const double len = lengthOr1(L[4], L[5], L[6]);+ const double cosA = -(lx * L[4] + ly * L[5] + lz * L[6]) / len;+ const double outer = L[14], inner = L[13];+ if (cosA <= outer) continue;+ falloff *= std::min(1.0, (cosA - outer) / std::max(inner - outer, 1e-4));+ }+ }+ const double lambert = nx * lx + ny * ly + nz * lz;+ if (lambert <= 0) continue;+ const double far = distance == INFINITY ? 1e7 : distance - kShadowEpsilon;+ const uint32_t seed = static_cast<uint32_t>(i) * 31u ^ static_cast<uint32_t>(li);+ if (blocked(s, px + nx * kShadowEpsilon, py + ny * kShadowEpsilon, pz + nz * kShadowEpsilon,+ lx, ly, lz, far, seed)) continue;+ const double w = lambert * falloff * L[11];+ r += L[7] * w; g += L[8] * w; b += L[9] * w;+ }+ out[i * 3] = static_cast<float>(r); out[i * 3 + 1] = static_cast<float>(g); out[i * 3 + 2] = static_cast<float>(b);+ });+}++/**+ * Everything that reaches each lumel indirectly. `sky` is 36 doubles: kind, flat+ * rgb, yaw, tint rgb, then the 27 unconvolved coefficients (rounded to float,+ * as skyRadiance holds them).+ */+void lm_gather(const float* position, const float* normal, int count,+ const float* atlas, int atlasSize, int samples, const double* sky, float* out, int threads) {+ const Scene& s = g_scene;+ Sky skyOf;+ skyOf.kind = static_cast<int>(sky[0]);+ for (int k = 0; k < 3; ++k) { skyOf.rgb[k] = sky[1 + k]; skyOf.tint[k] = sky[5 + k]; }+ skyOf.c = std::cos(sky[4]); skyOf.s = std::sin(sky[4]);+ for (int k = 0; k < 27; ++k) skyOf.radiance[k] = sky[8 + k];+ const std::vector<float> dirs = hemisphere(samples);+ parallelFor(count, threads, [&](int i) {+ const double px = position[i * 3], py = position[i * 3 + 1], pz = position[i * 3 + 2];+ const double nx = normal[i * 3], ny = normal[i * 3 + 1], nz = normal[i * 3 + 2];+ float basis[6];+ frame(nx, ny, nz, basis);+ double r = 0, g = 0, b = 0, seen[3];+ Hit hit;+ for (int k = 0; k < samples; ++k) {+ const double a = dirs[k * 3], c = dirs[k * 3 + 1], d = dirs[k * 3 + 2];+ const double dx = basis[0] * a + basis[3] * c + nx * d;+ const double dy = basis[1] * a + basis[4] * c + ny * d;+ const double dz = basis[2] * a + basis[5] * c + nz * d;+ const uint32_t seed = static_cast<uint32_t>(i) * static_cast<uint32_t>(samples) + static_cast<uint32_t>(k);+ const int tri = firstHit(s, px + nx * kShadowEpsilon, py + ny * kShadowEpsilon, pz + nz * kShadowEpsilon,+ dx, dy, dz, 1e7, kShadowEpsilon, seed, s.backReach, hit);+ if (tri < 0) {+ skyOf.at(dx, dy, dz, seen);+ r += seen[0]; g += seen[1]; b += seen[2];+ continue;+ }+ if (!facesRay(s, tri, dx, dy, dz)) continue;+ const int texel = texelOf(s, tri, hit.u, hit.v, atlasSize);+ if (texel < 0) continue;+ const float* alb = s.albedo + static_cast<size_t>(s.triSurface[tri]) * 3;+ r += static_cast<double>(atlas[static_cast<size_t>(texel) * 3]) * alb[0];+ g += static_cast<double>(atlas[static_cast<size_t>(texel) * 3 + 1]) * alb[1];+ b += static_cast<double>(atlas[static_cast<size_t>(texel) * 3 + 2]) * alb[2];+ }+ out[i * 3] = static_cast<float>(r / samples);+ out[i * 3 + 1] = static_cast<float>(g / samples);+ out[i * 3 + 2] = static_cast<float>(b / samples);+ });+}++} // extern "C"diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 3035bfbfb..b342da5a4 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -1279,9 +1279,13 @@ export const NOTED = {'feat(bake): baked light is a lit surface\'s indirect light':{ note: 'Baked light is a lit surface\'s indirect light' },'perf(bake): a bake uses every core':- { note: 'A bake uses every core' },+ { note: 'A bake uses every core, in C++' },'perf(bake): the editor bakes on every core':- { note: 'A bake uses every core' },+ { note: 'A bake uses every core, in C++' },+ 'perf(bake): the rays of a bake run in a C++ kernel on every core':+ { note: 'A bake uses every core, in C++' },+ 'perf(bake): the editor bakes through the C++ kernel':+ { note: 'A bake uses every core, in C++' },'fix(bake): a coloured light bakes the colour it lights with':{ note: 'A coloured light bakes the colour it lights with' },'fix(bake): the collector reads the colour space from the engine host':