rayzee 9.4.1 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -25
- package/dist/ActiveColor-YvuQq44O.js +13 -0
- package/dist/ArchiveImporter-xuUJiklP.js +4301 -0
- package/dist/AssetConfig-DSEntE65.js +30 -0
- package/dist/BidirectionalIntegrator-C5PKjJoT.js +934 -0
- package/dist/ColorManagement-CheBCPaW.js +1488 -0
- package/dist/EngineDefaults-DH3bI5t-.js +844 -0
- package/dist/EngineEvents-Ci8dVWCP.js +73 -0
- package/dist/EngineIssues-CIZnXHsF.js +72 -0
- package/dist/FileFormats-sPGJeCRc.js +102 -0
- package/dist/Logger-BnHghprG.js +97 -0
- package/dist/{NeuralRetouch-vkdXXyK2.js → NeuralRetouch-CW11yLZ_.js} +8 -6
- package/dist/{NeuralSuperRes-FVqRJKQV.js → NeuralSuperRes-BekaecYg.js} +55 -120
- package/dist/PathTracer-Ccl9KOuF.js +29729 -0
- package/dist/PhysicalSky-Dv2PMFGW.js +1219 -0
- package/dist/RayzeeRenderer-BQxnzCTD.js +3542 -0
- package/dist/SolarLimb-ken-JbDK.js +721 -0
- package/dist/ToneMapGPU-BHi5JzIq.js +177 -0
- package/dist/ViewTransforms-D0rTLBsX.js +255 -0
- package/dist/WorkingMatrix-C6y233hT.js +27 -0
- package/dist/ZipReader-gDSWr0I5.js +98 -0
- package/dist/addons/archives.es.js +3 -0
- package/dist/addons/bidirectional.es.js +2 -0
- package/dist/addons/color.es.js +3 -0
- package/dist/addons/formats.es.js +2 -0
- package/dist/addons/physical-sky.es.js +2 -0
- package/dist/addons/storage.es.js +3 -0
- package/dist/archiveFormats-BZw7TiDp.js +75 -0
- package/dist/identity-DrQsGT2o.js +39 -0
- package/dist/openStorage-DwcBRUj7.js +820 -0
- package/dist/rayzee-core.es.js +12 -0
- package/dist/rayzee.es.js +2266 -44125
- package/dist/rayzee.umd.js +485 -473
- package/dist/sceneCachePolicy-BmwYOYDu.js +183 -0
- package/dist/shared-BGBcSxBQ.js +17 -0
- package/package.json +23 -2
- package/src/Color/ActiveColor.js +34 -0
- package/src/Color/BasicColor.js +147 -0
- package/src/Color/ColorManagement.js +7 -31
- package/src/EngineDefaults.js +23 -14
- package/src/EngineEvents.js +2 -0
- package/src/EngineIssues.js +1 -0
- package/src/PathTracerApp.js +617 -4016
- package/src/Pipeline/PipelineContext.js +0 -4
- package/src/Platform.js +36 -0
- package/src/Processor/ArchiveCache.js +1 -1
- package/src/Processor/ArchiveImporter.js +1259 -0
- package/src/Processor/AssetLoader.js +322 -1746
- package/src/Processor/AtmosphereModel.js +1 -2
- package/src/Processor/BVHBuilder.js +4 -95
- package/src/Processor/EnvironmentExactTable.js +187 -0
- package/src/Processor/EquirectHDRInfo.js +30 -223
- package/src/Processor/FileFormats.js +116 -0
- package/src/Processor/GLTFDecoders.js +85 -0
- package/src/Processor/GLTFDiffuseTransmission.js +63 -0
- package/src/Processor/GeometryExtractor.js +12 -1
- package/src/Processor/IESParser.js +47 -35
- package/src/Processor/KernelManager.js +35 -2
- package/src/Processor/MaterialPacking.js +8 -7
- package/src/Processor/PBRT/PBRTMaterials.js +129 -41
- package/src/Processor/PBRT/PBRTParser.js +30 -17
- package/src/Processor/PBRT/PBRTSceneBuilder.js +548 -37
- package/src/Processor/PBRT/PBRTTextureBake.js +154 -0
- package/src/Processor/PBRT/PFM.js +59 -0
- package/src/Processor/PackedRayBuffer.js +116 -9
- package/src/Processor/ParallelBVHBuilder.js +3 -6
- package/src/Processor/PhysicalSky.js +5 -4
- package/src/Processor/PlatformImageLoader.js +50 -6
- package/src/Processor/QueueManager.js +12 -3
- package/src/Processor/ReinsertionOptimizer.js +2 -2
- package/src/Processor/SceneProcessor.js +15 -55
- package/src/Processor/ShaderBuilder.js +6 -16
- package/src/Processor/SimpleSky.js +1 -62
- package/src/Processor/SolarLimb.js +3 -0
- package/src/Processor/TextureCreator.js +1 -1
- package/src/Processor/Workers/BVHSubtreeWorker.js +1 -34
- package/src/Processor/Workers/BVHWorker.js +5 -18
- package/src/Processor/Workers/CDFWorker.js +6 -183
- package/src/Processor/archiveFormats.js +7 -0
- package/src/Processor/utils.js +2 -1
- package/src/RayzeeRenderer.js +3902 -0
- package/src/RenderSettings.js +49 -41
- package/src/Stages/ASVGF.js +5 -7
- package/src/Stages/AutoExposure.js +3 -12
- package/src/Stages/Compositor.js +8 -23
- package/src/Stages/NRD.js +9 -2
- package/src/Stages/NormalDepth.js +9 -6
- package/src/Stages/PathTracer.js +254 -38
- package/src/Stages/PathTracerStage.js +11 -16
- package/src/Storage/BLASCache.js +1 -1
- package/src/Storage/CDFCache.js +18 -17
- package/src/Storage/DownloadCache.js +1 -1
- package/src/Storage/SceneGraphCodec.js +46 -3
- package/src/Storage/SpillStore.js +1 -1
- package/src/Storage/StorageManager.js +2 -4
- package/src/Storage/areas.js +4 -0
- package/src/TSL/BVHTraversal.js +62 -24
- package/src/TSL/Bidirectional.js +204 -0
- package/src/TSL/BidirectionalLamps.js +132 -0
- package/src/TSL/Clearcoat.js +15 -6
- package/src/TSL/Common.js +19 -14
- package/src/TSL/ConnectKernel.js +147 -0
- package/src/TSL/Debugger.js +1 -1
- package/src/TSL/Displacement.js +4 -3
- package/src/TSL/EmissiveSampling.js +64 -17
- package/src/TSL/Environment.js +77 -106
- package/src/TSL/EnvironmentCDF.js +85 -39
- package/src/TSL/ExtendKernel.js +8 -3
- package/src/TSL/FinalWriteKernel.js +4 -4
- package/src/TSL/GenerateKernel.js +18 -4
- package/src/TSL/HitFacet.js +35 -5
- package/src/TSL/LightBVHSampling.js +40 -9
- package/src/TSL/LightGenerateKernel.js +293 -0
- package/src/TSL/LightGuide.js +198 -0
- package/src/TSL/LightSplatKernel.js +165 -0
- package/src/TSL/LightsCore.js +13 -38
- package/src/TSL/LightsDirect.js +28 -29
- package/src/TSL/LightsIndirect.js +3 -1
- package/src/TSL/LightsSampling.js +90 -38
- package/src/TSL/MaterialEvaluation.js +113 -31
- package/src/TSL/MaterialProperties.js +44 -17
- package/src/TSL/MaterialTransmission.js +52 -47
- package/src/TSL/MergeKernel.js +218 -0
- package/src/TSL/PathTracerCore.js +65 -29
- package/src/TSL/Random.js +4 -0
- package/src/TSL/SceneResources.js +51 -0
- package/src/TSL/ShadeKernel.js +881 -103
- package/src/TSL/Struct.js +10 -0
- package/src/TSL/Sun.js +1 -1
- package/src/TSL/TextureSampling.js +65 -60
- package/src/addons/archives.js +14 -0
- package/src/addons/bidirectional.js +13 -0
- package/src/addons/color.js +32 -0
- package/src/addons/formats.js +16 -0
- package/src/addons/physicalSky.js +14 -0
- package/src/addons/storage.js +19 -0
- package/src/core.js +35 -0
- package/src/index.js +3 -1
- package/src/integrators/BidirectionalIntegrator.js +832 -0
- package/src/managers/EnvironmentManager.js +94 -91
- package/src/managers/MaterialDataManager.js +42 -0
- package/src/managers/UniformManager.js +0 -1
- package/dist/ToneMapGPU-DKQM1pMd.js +0 -552
- package/dist/rolldown-runtime-CAFD8bLK.js +0 -11
- package/src/Processor/TreeletOptimizer.js +0 -574
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { t as e } from "./EngineEvents-Ci8dVWCP.js";
|
|
2
|
+
import { n as t, r as n } from "./shared-BGBcSxBQ.js";
|
|
3
|
+
import { n as r } from "./AssetConfig-DSEntE65.js";
|
|
4
|
+
import "three";
|
|
5
|
+
//#region src/Processor/utils.js
|
|
6
|
+
var i = null;
|
|
7
|
+
function a(e) {
|
|
8
|
+
i = e;
|
|
9
|
+
}
|
|
10
|
+
var o = () => i?.({ type: e.LOADING_RESET }), s = (t) => {
|
|
11
|
+
i?.({
|
|
12
|
+
type: e.LOADING_UPDATE,
|
|
13
|
+
...t
|
|
14
|
+
});
|
|
15
|
+
}, c = (t) => {
|
|
16
|
+
i?.({
|
|
17
|
+
type: e.STATS_UPDATE,
|
|
18
|
+
...t
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
function l(e) {
|
|
22
|
+
return e.frameCount || 0;
|
|
23
|
+
}
|
|
24
|
+
function u(e) {
|
|
25
|
+
if (Array.isArray(e)) e.forEach((e) => {
|
|
26
|
+
e.userData && e.userData.isFallback || (d(e), e.dispose());
|
|
27
|
+
});
|
|
28
|
+
else {
|
|
29
|
+
if (e.userData && e.userData.isFallback) return;
|
|
30
|
+
d(e), e.dispose();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function d(e) {
|
|
34
|
+
e && [
|
|
35
|
+
"alphaMap",
|
|
36
|
+
"aoMap",
|
|
37
|
+
"bumpMap",
|
|
38
|
+
"clearcoatMap",
|
|
39
|
+
"clearcoatNormalMap",
|
|
40
|
+
"clearcoatRoughnessMap",
|
|
41
|
+
"displacementMap",
|
|
42
|
+
"emissiveMap",
|
|
43
|
+
"envMap",
|
|
44
|
+
"gradientMap",
|
|
45
|
+
"lightMap",
|
|
46
|
+
"map",
|
|
47
|
+
"metalnessMap",
|
|
48
|
+
"normalMap",
|
|
49
|
+
"roughnessMap",
|
|
50
|
+
"specularMap",
|
|
51
|
+
"sheenColorMap",
|
|
52
|
+
"sheenRoughnessMap",
|
|
53
|
+
"specularIntensityMap",
|
|
54
|
+
"specularColorMap",
|
|
55
|
+
"thicknessMap",
|
|
56
|
+
"transmissionMap",
|
|
57
|
+
"diffuseTransmissionMap",
|
|
58
|
+
"diffuseTransmissionColorMap"
|
|
59
|
+
].forEach((t) => {
|
|
60
|
+
e[t] && (e[t].dispose(), e[t] = null);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function f({ material: e, geometry: t, children: n }) {
|
|
64
|
+
if (e && u(e), t && t.dispose(), n.length > 0) for (let e of n) f(e);
|
|
65
|
+
}
|
|
66
|
+
function p(e) {
|
|
67
|
+
if (!e) return;
|
|
68
|
+
e._canvasTarget && e._onCanvasTargetResize && e._canvasTarget.removeEventListener("resize", e._onCanvasTargetResize);
|
|
69
|
+
let t = e.dispose();
|
|
70
|
+
return e._canvasTarget = null, t;
|
|
71
|
+
}
|
|
72
|
+
function m(e, t = []) {
|
|
73
|
+
if (e && !(t.includes(e.name) || e.isScene)) {
|
|
74
|
+
if (e.isMaterial) {
|
|
75
|
+
u(e);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
for (; e.children.length > 0;) for (let t of e.children) m(t);
|
|
79
|
+
f(e), e.removeFromParent(), e.clear();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function h(e) {
|
|
83
|
+
e?.traverse((e) => {
|
|
84
|
+
e.geometry?.userData?.__rayzeeOwned && e.geometry.dispose();
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function g(e, t) {
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
function _(e, t = !1) {
|
|
91
|
+
return t ? 1 : 1 / (e + 1);
|
|
92
|
+
}
|
|
93
|
+
function v() {
|
|
94
|
+
let e = 0, t = 0, n = 0, r = 0;
|
|
95
|
+
return {
|
|
96
|
+
start() {
|
|
97
|
+
e = performance.now();
|
|
98
|
+
},
|
|
99
|
+
end() {
|
|
100
|
+
t = performance.now();
|
|
101
|
+
let i = t - e;
|
|
102
|
+
return r += i, n++, i;
|
|
103
|
+
},
|
|
104
|
+
getAverageFrameTime() {
|
|
105
|
+
return n > 0 ? r / n : 0;
|
|
106
|
+
},
|
|
107
|
+
getFPS() {
|
|
108
|
+
let e = this.getAverageFrameTime();
|
|
109
|
+
return e > 0 ? 1e3 / e : 0;
|
|
110
|
+
},
|
|
111
|
+
reset() {
|
|
112
|
+
n = 0, r = 0;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/Storage/CDFCache.js
|
|
118
|
+
var y = 5;
|
|
119
|
+
function b(e, t) {
|
|
120
|
+
e && t && (e.userData.__rayzeeSource = t);
|
|
121
|
+
}
|
|
122
|
+
function x(e) {
|
|
123
|
+
let t = e?.userData?.__rayzeeSource;
|
|
124
|
+
if (!t) return null;
|
|
125
|
+
let { width: n = 0, height: r = 0 } = e.image ?? {};
|
|
126
|
+
return `cdf:${y}:${t}|${n}x${r}|${e.userData.__rayzeeColorSpace ?? "native"}`;
|
|
127
|
+
}
|
|
128
|
+
var S = () => t(r().cacheNamespace)?.area(n.CDF) ?? null, C = [
|
|
129
|
+
"exactConditional",
|
|
130
|
+
"exactMarginal",
|
|
131
|
+
"exactRowGuide",
|
|
132
|
+
"exactMarginalGuide"
|
|
133
|
+
], w = C.map((e) => `${e}.f32`);
|
|
134
|
+
async function T(e) {
|
|
135
|
+
let t = x(e), n = t ? await S()?.open(t) : null;
|
|
136
|
+
if (!n) return null;
|
|
137
|
+
try {
|
|
138
|
+
let e = await Promise.all(w.map((e) => n.file(e)));
|
|
139
|
+
if (e.some((e) => !e)) return null;
|
|
140
|
+
let t = await Promise.all(e.map(async (e) => new Float32Array(await e.arrayBuffer()))), { totalSum: r, width: i, height: a, exactWidth: o, exactHeight: s, radianceIntegral: c } = n.extra;
|
|
141
|
+
return {
|
|
142
|
+
...Object.fromEntries(C.map((e, n) => [e, t[n]])),
|
|
143
|
+
totalSum: r,
|
|
144
|
+
width: i,
|
|
145
|
+
height: a,
|
|
146
|
+
exactWidth: o,
|
|
147
|
+
exactHeight: s,
|
|
148
|
+
radianceIntegral: c
|
|
149
|
+
};
|
|
150
|
+
} finally {
|
|
151
|
+
n.release();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function E(e, t) {
|
|
155
|
+
let { totalSum: n, width: r, height: i, exactWidth: a, exactHeight: o, radianceIntegral: s } = t, c = C.map((e) => t[e]), l = x(e), u = l ? S() : null;
|
|
156
|
+
if (!u || c.some((e) => !e)) return !1;
|
|
157
|
+
let d = await u.create(l, {
|
|
158
|
+
label: e.name || "environment",
|
|
159
|
+
expectedBytes: c.reduce((e, t) => e + t.byteLength, 0)
|
|
160
|
+
});
|
|
161
|
+
if (!d) return !1;
|
|
162
|
+
try {
|
|
163
|
+
for (let e = 0; e < w.length; e++) await d.write(w[e], c[e]);
|
|
164
|
+
return await d.commit({
|
|
165
|
+
totalSum: n,
|
|
166
|
+
width: r,
|
|
167
|
+
height: i,
|
|
168
|
+
exactWidth: a,
|
|
169
|
+
exactHeight: o,
|
|
170
|
+
radianceIntegral: s
|
|
171
|
+
}), !0;
|
|
172
|
+
} catch {
|
|
173
|
+
return await d.abort(), !1;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/version.js
|
|
178
|
+
var D = "9.5.0", O = 1e4, k = 15e5;
|
|
179
|
+
function A(e, t, n = O) {
|
|
180
|
+
return e >= n && t / k < e / 3;
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
183
|
+
export { c as _, E as a, v as c, p as d, l as f, s as g, g as h, T as i, h as l, a as m, A as n, b as o, o as p, D as r, _ as s, O as t, m as u };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/Storage/areas.js
|
|
2
|
+
var e = Object.freeze({
|
|
3
|
+
CACHE: "cache",
|
|
4
|
+
USER: "user",
|
|
5
|
+
SCRATCH: "scratch"
|
|
6
|
+
}), t = Object.freeze({
|
|
7
|
+
DOWNLOADS: "downloads",
|
|
8
|
+
ARCHIVES: "archives",
|
|
9
|
+
SCENES: "scenes",
|
|
10
|
+
CDF: "cdf",
|
|
11
|
+
SPILL: "spill"
|
|
12
|
+
}), n = /* @__PURE__ */ new Map();
|
|
13
|
+
function r(e) {
|
|
14
|
+
return n.get(e)?.storage ?? null;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as i, r as n, t as r, n as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rayzee",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Real-time WebGPU path tracing engine built on Three.js",
|
|
6
6
|
"main": "dist/rayzee.umd.js",
|
|
@@ -10,6 +10,27 @@
|
|
|
10
10
|
"import": "./dist/rayzee.es.js",
|
|
11
11
|
"require": "./dist/rayzee.umd.js"
|
|
12
12
|
},
|
|
13
|
+
"./core": {
|
|
14
|
+
"import": "./dist/rayzee-core.es.js"
|
|
15
|
+
},
|
|
16
|
+
"./addons/physical-sky": {
|
|
17
|
+
"import": "./dist/addons/physical-sky.es.js"
|
|
18
|
+
},
|
|
19
|
+
"./addons/archives": {
|
|
20
|
+
"import": "./dist/addons/archives.es.js"
|
|
21
|
+
},
|
|
22
|
+
"./addons/bidirectional": {
|
|
23
|
+
"import": "./dist/addons/bidirectional.es.js"
|
|
24
|
+
},
|
|
25
|
+
"./addons/color": {
|
|
26
|
+
"import": "./dist/addons/color.es.js"
|
|
27
|
+
},
|
|
28
|
+
"./addons/storage": {
|
|
29
|
+
"import": "./dist/addons/storage.es.js"
|
|
30
|
+
},
|
|
31
|
+
"./addons/formats": {
|
|
32
|
+
"import": "./dist/addons/formats.es.js"
|
|
33
|
+
},
|
|
13
34
|
"./node": "./src/node/index.js"
|
|
14
35
|
},
|
|
15
36
|
"files": [
|
|
@@ -32,7 +53,7 @@
|
|
|
32
53
|
"author": "Atul Mourya",
|
|
33
54
|
"license": "MIT",
|
|
34
55
|
"scripts": {
|
|
35
|
-
"build": "vite build",
|
|
56
|
+
"build": "vite build && RAYZEE_FORMAT=umd vite build",
|
|
36
57
|
"prepublishOnly": "npm run build"
|
|
37
58
|
},
|
|
38
59
|
"peerDependencies": {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour management the engine reads — `BasicColor` in the renderer core, the OCIO `ColorManagement` once a host
|
|
3
|
+
* installs it (rayzee/addons/color). A config, a working space and a set of view transforms are process-wide — there
|
|
4
|
+
* is one OCIO runtime and one set of baked tables — so code far from the app (texture processing, the environment)
|
|
5
|
+
* asks for the active instance rather than having one threaded through six constructors.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** What the engine renders in when no config has been adopted. */
|
|
9
|
+
export const DEFAULT_WORKING_SPACE = 'Linear Rec.709 (sRGB)';
|
|
10
|
+
|
|
11
|
+
let active = null;
|
|
12
|
+
|
|
13
|
+
/** The colour management the engine is currently using, or null. */
|
|
14
|
+
export function getActiveColorManagement() {
|
|
15
|
+
|
|
16
|
+
return active;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Make an instance the one the engine reads. Normally the app's own, set on construction. */
|
|
21
|
+
export function setActiveColorManagement( cm ) {
|
|
22
|
+
|
|
23
|
+
active = cm;
|
|
24
|
+
// Whatever the previous instance published is not this one's working space.
|
|
25
|
+
cm?._publishWorkingMatrix?.();
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Becomes the active one only when there is none, without publishing (a constructor's claim). */
|
|
30
|
+
export function claimActiveColorManagement( cm ) {
|
|
31
|
+
|
|
32
|
+
if ( active === null ) active = cm;
|
|
33
|
+
|
|
34
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The renderer core's colour management: linear Rec.709, three.js's built-in view transforms, nothing converted — what
|
|
3
|
+
* the OCIO `ColorManagement` (rayzee/addons/color) does with no config loaded. `renderer.setColorManagement(
|
|
4
|
+
* ColorManagement )` replaces it.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { SRGBColorSpace } from 'three';
|
|
8
|
+
import { DEFAULT_WORKING_SPACE, getActiveColorManagement, setActiveColorManagement } from './ActiveColor.js';
|
|
9
|
+
import { registerWithRenderer, onRegistryChange, getViewTransform, listViewTransforms, getRegistryVersion } from './ViewTransforms.js';
|
|
10
|
+
import { setWorkingMatrix } from './WorkingMatrix.js';
|
|
11
|
+
import { ISSUE_CODES } from '../EngineIssues.js';
|
|
12
|
+
|
|
13
|
+
export class BasicColor {
|
|
14
|
+
|
|
15
|
+
constructor( { issues = null } = {} ) {
|
|
16
|
+
|
|
17
|
+
this._issues = issues;
|
|
18
|
+
this._renderer = null;
|
|
19
|
+
this._offRegistry = onRegistryChange( () => {
|
|
20
|
+
|
|
21
|
+
if ( this._renderer ) registerWithRenderer( this._renderer );
|
|
22
|
+
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get hasConfig() {
|
|
28
|
+
|
|
29
|
+
return false;
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get workingSpace() {
|
|
34
|
+
|
|
35
|
+
return DEFAULT_WORKING_SPACE;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get workingSpaceAdopted() {
|
|
40
|
+
|
|
41
|
+
return false;
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Part of a converted texture's cache key: nothing is converted here. */
|
|
46
|
+
get inputKey() {
|
|
47
|
+
|
|
48
|
+
return '-';
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
attachRenderer( renderer ) {
|
|
53
|
+
|
|
54
|
+
this._renderer = renderer;
|
|
55
|
+
const n = registerWithRenderer( renderer );
|
|
56
|
+
renderer.outputColorSpace = SRGBColorSpace;
|
|
57
|
+
return n;
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Every registered view transform, for a host menu. */
|
|
62
|
+
listViews() {
|
|
63
|
+
|
|
64
|
+
return listViewTransforms();
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The active OCIO view: none without a config. */
|
|
69
|
+
get activeView() {
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Make a registered transform the one the renderer uses — three.js's own seven, or one a host added. A view that
|
|
77
|
+
* returns display-encoded colour (an OCIO view) needs the OCIO pipeline, which sets the output colour space for it.
|
|
78
|
+
*/
|
|
79
|
+
setActiveView( id ) {
|
|
80
|
+
|
|
81
|
+
const t = getViewTransform( id );
|
|
82
|
+
if ( ! t ) throw new Error( `no view transform with id ${id}` );
|
|
83
|
+
if ( t.outputEncoded ) throw new Error( `"${t.name}" returns display-encoded colour: it needs rayzee/addons/color` );
|
|
84
|
+
if ( this._renderer ) this._renderer.toneMapping = id;
|
|
85
|
+
return t;
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_publishWorkingMatrix() {
|
|
90
|
+
|
|
91
|
+
setWorkingMatrix( null, DEFAULT_WORKING_SPACE );
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Colour configs, views and working spaces need the OCIO pipeline. */
|
|
96
|
+
loadConfig() {
|
|
97
|
+
|
|
98
|
+
const message = 'colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color';
|
|
99
|
+
this._issues?.record( ISSUE_CODES.CAPABILITY_MISSING, message, { capability: 'color' } );
|
|
100
|
+
return Promise.reject( new Error( message ) );
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
unloadConfig() {}
|
|
105
|
+
|
|
106
|
+
setWorkingSpace() {}
|
|
107
|
+
|
|
108
|
+
/** No export space without a config: the working space as it is. */
|
|
109
|
+
exportPixels( rgba ) {
|
|
110
|
+
|
|
111
|
+
return { rgba, colorSpace: DEFAULT_WORKING_SPACE };
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
status() {
|
|
116
|
+
|
|
117
|
+
const active = this._renderer ? getViewTransform( this._renderer.toneMapping ) : null;
|
|
118
|
+
return {
|
|
119
|
+
config: null,
|
|
120
|
+
workingSpace: DEFAULT_WORKING_SPACE,
|
|
121
|
+
workingSpaceAdopted: false,
|
|
122
|
+
activeTransform: active ? { id: active.id, name: active.name, source: active.source } : null,
|
|
123
|
+
activeView: null,
|
|
124
|
+
context: null,
|
|
125
|
+
exportSpace: null,
|
|
126
|
+
views: listViewTransforms(),
|
|
127
|
+
registryVersion: getRegistryVersion(),
|
|
128
|
+
bakeError: active?.error ?? null,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
dispose() {
|
|
134
|
+
|
|
135
|
+
this._offRegistry?.();
|
|
136
|
+
this._renderer = null;
|
|
137
|
+
this._issues = null;
|
|
138
|
+
if ( getActiveColorManagement() === this ) {
|
|
139
|
+
|
|
140
|
+
setWorkingMatrix( null );
|
|
141
|
+
setActiveColorManagement( null );
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
@@ -44,34 +44,9 @@ import {
|
|
|
44
44
|
} from './InputColorSpaces.js';
|
|
45
45
|
import { setWorkingMatrix, convertLinearTriple, convertLinearTriples } from './WorkingMatrix.js';
|
|
46
46
|
import { packHalf, unpackHalf } from './LutBake.js';
|
|
47
|
+
import { DEFAULT_WORKING_SPACE, getActiveColorManagement, setActiveColorManagement, claimActiveColorManagement } from './ActiveColor.js';
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
export const DEFAULT_WORKING_SPACE = 'Linear Rec.709 (sRGB)';
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The instance the rest of the engine reads.
|
|
53
|
-
*
|
|
54
|
-
* A config, a working space and a set of view transforms are process-wide — there is one OCIO
|
|
55
|
-
* runtime and one set of baked tables — so code far from the app (texture processing, the asset
|
|
56
|
-
* loader) asks for the active instance rather than having one threaded through six constructors.
|
|
57
|
-
*/
|
|
58
|
-
let active = null;
|
|
59
|
-
|
|
60
|
-
/** The colour management the engine is currently using, or null. */
|
|
61
|
-
export function getActiveColorManagement() {
|
|
62
|
-
|
|
63
|
-
return active;
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Make an instance the one the engine reads. Normally the app's own, set on construction. */
|
|
68
|
-
export function setActiveColorManagement( cm ) {
|
|
69
|
-
|
|
70
|
-
active = cm;
|
|
71
|
-
// Whatever the previous instance published is not this one's working space.
|
|
72
|
-
cm?._publishWorkingMatrix?.();
|
|
73
|
-
|
|
74
|
-
}
|
|
49
|
+
export { DEFAULT_WORKING_SPACE, getActiveColorManagement, setActiveColorManagement };
|
|
75
50
|
|
|
76
51
|
/** The canvas colour space for a display: its own when it has one, sRGB otherwise. */
|
|
77
52
|
export function canvasColorSpaceFor( display ) {
|
|
@@ -150,7 +125,7 @@ export class ColorManagement {
|
|
|
150
125
|
|
|
151
126
|
} );
|
|
152
127
|
|
|
153
|
-
|
|
128
|
+
claimActiveColorManagement( this );
|
|
154
129
|
|
|
155
130
|
}
|
|
156
131
|
|
|
@@ -850,6 +825,7 @@ export class ColorManagement {
|
|
|
850
825
|
/** Recompute the published primaries matrix. Called whenever the config or space changes. */
|
|
851
826
|
_publishWorkingMatrix() {
|
|
852
827
|
|
|
828
|
+
const active = getActiveColorManagement();
|
|
853
829
|
if ( active !== null && active !== this ) return;
|
|
854
830
|
setWorkingMatrix( hasConfig() ? this.primariesMatrixToWorking() : null, this.workingSpace );
|
|
855
831
|
|
|
@@ -1094,12 +1070,12 @@ export class ColorManagement {
|
|
|
1094
1070
|
setOcioIssueLog( null );
|
|
1095
1071
|
this._renderer = null;
|
|
1096
1072
|
this._issues = null;
|
|
1097
|
-
if (
|
|
1073
|
+
if ( getActiveColorManagement() === this ) {
|
|
1098
1074
|
|
|
1099
1075
|
// The matrix is module state that materials and lights read with no idea whose it is.
|
|
1100
1076
|
// Left behind, the next app would convert every colour into a space it never adopted.
|
|
1101
1077
|
setWorkingMatrix( null );
|
|
1102
|
-
|
|
1078
|
+
setActiveColorManagement( null );
|
|
1103
1079
|
|
|
1104
1080
|
}
|
|
1105
1081
|
|
|
@@ -1108,7 +1084,7 @@ export class ColorManagement {
|
|
|
1108
1084
|
/** Tear down the shared runtime as well. Tests use this; an app normally should not. */
|
|
1109
1085
|
static resetAll() {
|
|
1110
1086
|
|
|
1111
|
-
|
|
1087
|
+
setActiveColorManagement( null );
|
|
1112
1088
|
setWorkingMatrix( null );
|
|
1113
1089
|
disposeOcioViewTextures();
|
|
1114
1090
|
resetViewTransforms();
|
package/src/EngineDefaults.js
CHANGED
|
@@ -52,6 +52,12 @@ export function getRenderProfile( name = 'viewer' ) {
|
|
|
52
52
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// Scene-archive budgets with the memory spill on: the triangles and BVH leave the heap as the build goes, so the host
|
|
56
|
+
// passes these instead of the importer's own. The whole 15-part Moana subset (55.7M / 7.0M) loads cold under them, at
|
|
57
|
+
// an 8.1 GB preflight estimate; the preflight, not the budget, refuses anything larger.
|
|
58
|
+
export const SPILL_TRIANGLE_BUDGET = 60_000_000;
|
|
59
|
+
export const SPILL_PLACEMENT_BUDGET = 8_000_000;
|
|
60
|
+
|
|
55
61
|
export const ENGINE_DEFAULTS = {
|
|
56
62
|
// Canvas output
|
|
57
63
|
resolution: 512,
|
|
@@ -91,12 +97,7 @@ export const ENGINE_DEFAULTS = {
|
|
|
91
97
|
globalIlluminationIntensity: 1,
|
|
92
98
|
|
|
93
99
|
// Environment Mode System
|
|
94
|
-
environmentMode: 'hdri', // 'hdri' | 'procedural' | '
|
|
95
|
-
|
|
96
|
-
// Gradient Sky Colors
|
|
97
|
-
gradientZenithColor: '#0077BE',
|
|
98
|
-
gradientHorizonColor: '#87CEEB',
|
|
99
|
-
gradientGroundColor: '#654321',
|
|
100
|
+
environmentMode: 'hdri', // 'hdri' | 'procedural' | 'color'
|
|
100
101
|
|
|
101
102
|
// Solid Color Sky
|
|
102
103
|
solidSkyColor: '#87CEEB',
|
|
@@ -169,6 +170,7 @@ export const ENGINE_DEFAULTS = {
|
|
|
169
170
|
convergenceOverlay: false, // display-only Compositor overlay; never alters the render
|
|
170
171
|
|
|
171
172
|
samplingTechnique: 2,
|
|
173
|
+
integrator: 'path', // 'path' | 'bidirectional' | 'vcm'
|
|
172
174
|
enableEmissiveTriangleSampling: false,
|
|
173
175
|
emissiveBoost: 1.0,
|
|
174
176
|
|
|
@@ -634,8 +636,8 @@ export function unpackNormalOct( packed, out ) {
|
|
|
634
636
|
// Shared between CPU writers (TextureCreator, MaterialDataManager) and GPU readers (Common.js getMaterial).
|
|
635
637
|
export const MATERIAL_DATA_LAYOUT = {
|
|
636
638
|
|
|
637
|
-
SLOTS_PER_MATERIAL:
|
|
638
|
-
FLOATS_PER_MATERIAL:
|
|
639
|
+
SLOTS_PER_MATERIAL: 34, // vec4 slots per material
|
|
640
|
+
FLOATS_PER_MATERIAL: 136, // total floats per material (34 × 4)
|
|
639
641
|
|
|
640
642
|
// ── Flat float offsets (CPU side) ────────────────────────────────
|
|
641
643
|
// Used as: data[ materialIndex * FLOATS_PER_MATERIAL + offset ]
|
|
@@ -659,8 +661,8 @@ export const MATERIAL_DATA_LAYOUT = {
|
|
|
659
661
|
EMISSIVE_MAP_INDEX: 28, BUMP_MAP_INDEX: 29, CLEARCOAT: 30, CLEARCOAT_ROUGHNESS: 31,
|
|
660
662
|
// Slot 8: dispersion + visible + sheen + sheenRoughness [extended BxDF]
|
|
661
663
|
DISPERSION: 32, VISIBLE: 33, SHEEN: 34, SHEEN_ROUGHNESS: 35,
|
|
662
|
-
// Slot 9: sheenColor.rgb +
|
|
663
|
-
SHEEN_COLOR: 36,
|
|
664
|
+
// Slot 9: sheenColor.rgb + diffuseTransmission [extended BxDF]
|
|
665
|
+
SHEEN_COLOR: 36, DIFFUSE_TRANSMISSION: 39,
|
|
664
666
|
// Slot 10: specularIntensity + specularColor.rgb [extended BxDF]
|
|
665
667
|
SPECULAR_INTENSITY: 40, SPECULAR_COLOR: 41,
|
|
666
668
|
// Slot 11: iridescence + iridescenceIOR + iridescenceThicknessRange [extended BxDF]
|
|
@@ -688,8 +690,11 @@ export const MATERIAL_DATA_LAYOUT = {
|
|
|
688
690
|
TRANSMISSION_MAP_INDEX: 120, CLEARCOAT_MAP_INDEX: 121, CLEARCOAT_ROUGHNESS_MAP_INDEX: 122, SHEEN_COLOR_MAP_INDEX: 123,
|
|
689
691
|
// Slot 31: extension-texture map indices B (sheenRoughness, iridescence, iridescenceThickness, specularIntensity)
|
|
690
692
|
SHEEN_ROUGHNESS_MAP_INDEX: 124, IRIDESCENCE_MAP_INDEX: 125, IRIDESCENCE_THICKNESS_MAP_INDEX: 126, SPECULAR_INTENSITY_MAP_INDEX: 127,
|
|
691
|
-
// Slot 32: extension-texture map
|
|
692
|
-
SPECULAR_COLOR_MAP_INDEX: 128,
|
|
693
|
+
// Slot 32: extension-texture map index C (specularColor) + diffuseTransmissionColor.rgb
|
|
694
|
+
SPECULAR_COLOR_MAP_INDEX: 128, DIFFUSE_TRANSMISSION_COLOR: 129,
|
|
695
|
+
// Slot 33: extension-texture map indices D (diffuseTransmission, diffuseTransmissionColor) + 2 reserved;
|
|
696
|
+
// read only for a material with diffuse transmission
|
|
697
|
+
DIFFUSE_TRANSMISSION_MAP_INDEX: 132, DIFFUSE_TRANSMISSION_COLOR_MAP_INDEX: 133,
|
|
693
698
|
|
|
694
699
|
// ── Vec4 slot indices (GPU/TSL side) ─────────────────────────────
|
|
695
700
|
// Used with getDatafromStorageBuffer( buf, matIdx, int(slot), int(SLOTS_PER_MATERIAL) )
|
|
@@ -703,7 +708,7 @@ export const MATERIAL_DATA_LAYOUT = {
|
|
|
703
708
|
MAP_INDICES_A: 6, // [maps] albedo, normal, roughness, metalness
|
|
704
709
|
MAP_INDICES_B: 7, // [maps] emissive, bump, clearcoat, clearcoatRoughness
|
|
705
710
|
DISPERSION_SHEEN: 8, // [extended] dispersion, visible, sheen, sheenRoughness
|
|
706
|
-
SHEEN_COLOR: 9, // [extended] sheenColor,
|
|
711
|
+
SHEEN_COLOR: 9, // [extended] sheenColor, diffuseTransmission
|
|
707
712
|
SPECULAR: 10, // [extended] specularIntensity, specularColor
|
|
708
713
|
IRIDESCENCE: 11, // [extended] iridescence, iridescenceIOR, iridescenceThicknessRange
|
|
709
714
|
BUMP_DISPLACEMENT: 12, // bumpScale, displacementScale, displacementMapIndex
|
|
@@ -719,7 +724,8 @@ export const MATERIAL_DATA_LAYOUT = {
|
|
|
719
724
|
SUBSURFACE_C: 29, // subsurfaceAnisotropy g, anisotropy, anisotropyRotation, anisotropyMapIndex
|
|
720
725
|
EXT_MAP_INDICES_A: 30, // transmission, clearcoat, clearcoatRoughness, sheenColor map indices
|
|
721
726
|
EXT_MAP_INDICES_B: 31, // sheenRoughness, iridescence, iridescenceThickness, specularIntensity map indices
|
|
722
|
-
EXT_MAP_INDICES_C: 32, // specularColor map index
|
|
727
|
+
EXT_MAP_INDICES_C: 32, // specularColor map index, diffuseTransmissionColor
|
|
728
|
+
EXT_MAP_INDICES_D: 33, // diffuseTransmission, diffuseTransmissionColor map indices + 2 reserved
|
|
723
729
|
},
|
|
724
730
|
|
|
725
731
|
};
|
|
@@ -769,6 +775,9 @@ export const MATERIAL_DEFAULTS = deepFreeze( {
|
|
|
769
775
|
subsurfaceAnisotropy: 0,
|
|
770
776
|
anisotropy: 0,
|
|
771
777
|
anisotropyRotation: 0,
|
|
778
|
+
// KHR_materials_diffuse_transmission: the share of the diffuse lobe passed through to the other side.
|
|
779
|
+
diffuseTransmission: 0,
|
|
780
|
+
diffuseTransmissionColor: [ 1, 1, 1 ],
|
|
772
781
|
} );
|
|
773
782
|
|
|
774
783
|
function deepFreeze( object ) {
|
package/src/EngineEvents.js
CHANGED
|
@@ -8,6 +8,8 @@ export const EngineEvents = {
|
|
|
8
8
|
RENDER_COMPLETE: 'engine:renderComplete',
|
|
9
9
|
RENDER_RESET: 'engine:renderReset',
|
|
10
10
|
FRAME: 'engine:frame',
|
|
11
|
+
// The path tracer compiles its shaders in the background ({ compiling }); the canvas keeps its last frame meanwhile.
|
|
12
|
+
SHADERS_COMPILING: 'engine:shadersCompiling',
|
|
11
13
|
|
|
12
14
|
// Denoiser
|
|
13
15
|
DENOISING_START: 'engine:denoisingStart',
|
package/src/EngineIssues.js
CHANGED
|
@@ -34,6 +34,7 @@ export const ISSUE_CODES = Object.freeze( {
|
|
|
34
34
|
OUTPUT_SOURCE_FALLBACK: 'output.source_fallback',
|
|
35
35
|
OUTPUT_TONEMAP_FALLBACK: 'output.tonemap_fallback',
|
|
36
36
|
LIGHT_PLACEHOLDER_SKIPPED: 'light.placeholder_skipped',
|
|
37
|
+
CAPABILITY_MISSING: 'capability.missing',
|
|
37
38
|
} );
|
|
38
39
|
|
|
39
40
|
/** Strict throws on ERROR only. */
|