rayzee 11.11.0 → 11.13.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/dist/{ArchiveImporter-D5XOC3tN.js → ArchiveImporter-DQU55mit.js} +1322 -1290
- package/dist/{BidirectionalIntegrator-DqG0BEIz.js → BidirectionalIntegrator-CLmFjSN3.js} +2 -2
- package/dist/{ColorManagement-B_HjAiy2.js → ColorManagement-3xw0xXRg.js} +859 -374
- package/dist/{NeuralRetouch-BkxZPOYq.js → NeuralRetouch-CEkBhI1M.js} +1 -1
- package/dist/{NeuralSuperRes-a8xDtvXM.js → NeuralSuperRes-Drjws9nE.js} +6 -6
- package/dist/{PathTracer-C_gliSWI.js → PathTracer-7a7L3cGF.js} +3448 -3404
- package/dist/{PhysicalSky-DWK8pS0U.js → PhysicalSky-DUIbTE93.js} +1 -1
- package/dist/{RayzeeRenderer-B4ZehMg_.js → RayzeeRenderer-CjjGT2e0.js} +390 -330
- package/dist/{SceneMetadata-Bb3iwWhh.js → SceneMetadata-CoAHTAmo.js} +1 -1
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/color.es.js +2 -2
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/rayzee-core.es.js +4 -4
- package/dist/rayzee.es.js +639 -629
- package/dist/rayzee.umd.js +110 -110
- package/dist/{sceneCachePolicy-BHNKvrHR.js → sceneCachePolicy-DavHt6Ii.js} +217 -185
- package/package.json +1 -1
- package/src/Color/BakedViews.js +5 -2
- package/src/Color/BasicColor.js +27 -0
- package/src/Color/ColorManagement.js +255 -11
- package/src/Color/Displays.js +149 -7
- package/src/Color/OcioRuntime.js +19 -4
- package/src/Color/OcioViews.js +251 -37
- package/src/Passes/AIUpscaler.js +6 -2
- package/src/PathTracerApp.js +2 -0
- package/src/Processor/ArchiveImporter.js +25 -3
- package/src/Processor/AssetLoader.js +6 -4
- package/src/Processor/InstanceTable.js +36 -11
- package/src/Processor/PBRT/PBRTCurves.js +6 -3
- package/src/Processor/PBRT/PBRTSceneBuilder.js +26 -3
- package/src/Processor/PBRT/index.js +1 -0
- package/src/Processor/SceneProcessor.js +43 -5
- package/src/Processor/TLASBuilder.js +5 -4
- package/src/Processor/USD/USDScene.js +6 -1
- package/src/Processor/USD/index.js +2 -2
- package/src/Processor/utils.js +80 -1
- package/src/RayzeeRenderer.js +54 -9
- package/src/Stages/Compositor.js +86 -3
- package/src/Stages/PathTracerStage.js +17 -6
- package/src/TSL/BVHTraversal.js +1 -1
- package/src/addons/color.js +2 -2
- package/src/index.js +2 -2
- package/src/managers/DenoisingManager.js +18 -4
- package/src/managers/VideoRenderManager.js +10 -1
- package/src/neural/NeuralSuperRes.js +5 -5
|
@@ -3,23 +3,100 @@ import { n as t } from "./EngineIssues-CfJiBaNj.js";
|
|
|
3
3
|
import { a as n, n as r, t as i } from "./WorkingMatrix-C6y233hT.js";
|
|
4
4
|
import { i as a, n as o, r as s, t as c } from "./ActiveColor-YvuQq44O.js";
|
|
5
5
|
import { n as l } from "./AssetConfig-DSEntE65.js";
|
|
6
|
-
import { _ as u, a as d, c as f, d as p, f as m, g as h, h as g, l as _, m as v, n as
|
|
7
|
-
import { Fn as
|
|
8
|
-
import { ClampToEdgeWrapping as le, Data3DTexture as ue, HalfFloatType as de, LinearSRGBColorSpace as fe, NearestFilter as pe, NoColorSpace as me,
|
|
6
|
+
import { _ as u, a as d, c as f, d as p, f as m, g as h, h as g, l as _, m as v, n as y, o as ee, p as te, u as b } from "./ViewTransforms-CYN7bq2w.js";
|
|
7
|
+
import { Fn as ne, If as re, clamp as x, float as ie, floor as ae, ivec3 as S, log2 as oe, max as se, texture3DLoad as ce, vec3 as C } from "three/tsl";
|
|
8
|
+
import { ClampToEdgeWrapping as le, Data3DTexture as ue, HalfFloatType as de, LinearSRGBColorSpace as fe, NearestFilter as pe, NoColorSpace as me, NoToneMapping as he, RGBAFormat as ge, SRGBColorSpace as _e } from "three";
|
|
9
9
|
//#region src/Color/Displays.js
|
|
10
10
|
function w(e) {
|
|
11
11
|
let t = String(e ?? "");
|
|
12
|
-
return /(hdr|pq|hlg|2100|st2084)/i.test(t) ? null : /^display\s*p3\b/i.test(t) ? "display-p3" : /^
|
|
12
|
+
return /(hdr|pq|hlg|2100|st2084)/i.test(t) ? null : /^display\s*p3\b/i.test(t) ? "display-p3" : /^srgb\b(?!.*(p3|2020))/i.test(t) ? "srgb" : null;
|
|
13
|
+
}
|
|
14
|
+
var ve = new Set(["hdr-video", "edr-video"]), ye = /(^|[^a-z])(hdr|pq|hlg|st-?2084|2100)([^a-z]|$)/i;
|
|
15
|
+
function be(e, t) {
|
|
16
|
+
let n = /* @__PURE__ */ new Map();
|
|
17
|
+
for (let t of e?.colorSpaces ?? []) for (let e of [t.name, ...t.aliases ?? []]) n.set(e, t.encoding);
|
|
18
|
+
let r = (e) => e.colorSpace === "<USE_DISPLAY_NAME>" ? t : e.colorSpace;
|
|
19
|
+
return (e?.views?.[t] ?? []).map((e) => n.get(r(e))).filter(Boolean);
|
|
20
|
+
}
|
|
21
|
+
function T(e, t) {
|
|
22
|
+
let n = be(e, t);
|
|
23
|
+
return n.length ? n.some((e) => ve.has(e)) : ye.test(t);
|
|
24
|
+
}
|
|
25
|
+
var xe = 1e3, E = (e) => String(e).replace(/\([^)]*\)/g, " ").split(/\s+-\s+/)[0].trim().replace(/\s+/g, " ").toLowerCase(), Se = (e) => e.replace(/\s*\d+(\.\d+)*$/, ""), D = (e) => /\bHDR\b/i.test(e) ? "hdr" : /\bSDR\b/i.test(e) ? "sdr" : null;
|
|
26
|
+
function Ce(e, t) {
|
|
27
|
+
let n = e.findIndex((e, n) => e !== t[n]);
|
|
28
|
+
return n >= 0 && e[n] < t[n];
|
|
29
|
+
}
|
|
30
|
+
var we = (e) => new Set((e?.colorSpaces ?? []).filter((e) => e.isData).flatMap((e) => [e.name, ...e.aliases ?? []]));
|
|
31
|
+
function Te(e, t, n) {
|
|
32
|
+
return we(e).has(e?.views?.[t]?.find((e) => e.name === n)?.colorSpace);
|
|
33
|
+
}
|
|
34
|
+
function Ee(e, t) {
|
|
35
|
+
return E(e) === E(t);
|
|
36
|
+
}
|
|
37
|
+
var De = (e, t) => Se(E(e)) === Se(E(t));
|
|
38
|
+
function Oe(e, t, n) {
|
|
39
|
+
let r = D(t), i = Number(/(\d+)\s*nits/i.exec(t)?.[1] ?? xe);
|
|
40
|
+
return [
|
|
41
|
+
E(t) === E(e) ? 0 : 1,
|
|
42
|
+
(n ? r === "hdr" : r !== "hdr") ? 0 : 1,
|
|
43
|
+
t === e ? 0 : 1,
|
|
44
|
+
n ? Math.abs(Math.log2(i / xe)) : 0,
|
|
45
|
+
+!/p3/i.test(t)
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
function ke(e, t, n) {
|
|
49
|
+
let r = we(e), i = T(e, n), a = null;
|
|
50
|
+
for (let o of e?.views?.[n] ?? []) {
|
|
51
|
+
if (r.has(o.colorSpace) || !De(t, o.name)) continue;
|
|
52
|
+
let e = Oe(t, o.name, i);
|
|
53
|
+
(!a || Ce(e, a.rank)) && (a = {
|
|
54
|
+
view: o.name,
|
|
55
|
+
rank: e
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return a;
|
|
59
|
+
}
|
|
60
|
+
function Ae(e, t, n, r) {
|
|
61
|
+
if (Te(e, t, n)) {
|
|
62
|
+
let t = we(e);
|
|
63
|
+
return e?.views?.[r]?.find((e) => t.has(e.colorSpace))?.name ?? null;
|
|
64
|
+
}
|
|
65
|
+
return ke(e, n, r)?.view ?? null;
|
|
66
|
+
}
|
|
67
|
+
function je(e, t, n) {
|
|
68
|
+
if (Te(e, t, n)) return null;
|
|
69
|
+
if (T(e, t)) return {
|
|
70
|
+
display: t,
|
|
71
|
+
view: n
|
|
72
|
+
};
|
|
73
|
+
if (D(n) === "hdr") return null;
|
|
74
|
+
let r = null;
|
|
75
|
+
for (let t of e?.displays ?? []) {
|
|
76
|
+
if (!T(e, t)) continue;
|
|
77
|
+
let i = ke(e, n, t), a = D(i?.view) === null;
|
|
78
|
+
if (!i || D(i.view) === "sdr" || a && (i.rank[0] || D(n) !== null)) continue;
|
|
79
|
+
let o = [...i.rank, be(e, t).includes("edr-video") ? 0 : /pq|st-?2084/i.test(t) ? 1 : 2];
|
|
80
|
+
(!r || Ce(o, r.rank)) && (r = {
|
|
81
|
+
display: t,
|
|
82
|
+
view: i.view,
|
|
83
|
+
rank: o
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return r && {
|
|
87
|
+
display: r.display,
|
|
88
|
+
view: r.view
|
|
89
|
+
};
|
|
13
90
|
}
|
|
14
91
|
//#endregion
|
|
15
92
|
//#region src/Color/OcioRuntime.js
|
|
16
|
-
var
|
|
17
|
-
function
|
|
93
|
+
var Me = e("ocio");
|
|
94
|
+
function Ne(e) {
|
|
18
95
|
let t = String(e);
|
|
19
|
-
/\[OpenColorIO Error\]/.test(t) ?
|
|
96
|
+
/\[OpenColorIO Error\]/.test(t) ? Me.error(t) : /\[OpenColorIO Warning\]/.test(t) ? Me.warn(t) : Me.debug(t);
|
|
20
97
|
}
|
|
21
|
-
var
|
|
22
|
-
async function
|
|
98
|
+
var O = null, k = null, A = null, j = null, M = null;
|
|
99
|
+
async function Pe() {
|
|
23
100
|
let { ocioRuntimeFactory: e, ocioRuntimeUrl: t } = l();
|
|
24
101
|
if (typeof e == "function") return await e();
|
|
25
102
|
if (typeof t == "string" && t) return await import(
|
|
@@ -28,28 +105,28 @@ async function ve() {
|
|
|
28
105
|
);
|
|
29
106
|
throw Error("OpenColorIO runtime not configured. Call configureAssets({ ocioRuntimeFactory: () => import('@bb-studio/ocio') }) before loading a config.");
|
|
30
107
|
}
|
|
31
|
-
async function
|
|
32
|
-
return
|
|
33
|
-
let e = await
|
|
108
|
+
async function Fe() {
|
|
109
|
+
return k || (O ||= (async () => {
|
|
110
|
+
let e = await Pe();
|
|
34
111
|
if (typeof e.createOcioRuntime != "function") throw Error("OCIO module has no createOcioRuntime() — wrong package or version");
|
|
35
112
|
let { ocioWasmUrl: t } = l();
|
|
36
|
-
return
|
|
113
|
+
return k = await e.createOcioRuntime({
|
|
37
114
|
...t ? { wasmUrl: t } : {},
|
|
38
115
|
moduleOptions: {
|
|
39
|
-
print:
|
|
40
|
-
printErr:
|
|
116
|
+
print: Ne,
|
|
117
|
+
printErr: Ne
|
|
41
118
|
}
|
|
42
|
-
}),
|
|
119
|
+
}), k;
|
|
43
120
|
})().catch((e) => {
|
|
44
|
-
throw
|
|
45
|
-
}), await
|
|
121
|
+
throw O = null, e;
|
|
122
|
+
}), await O);
|
|
46
123
|
}
|
|
47
|
-
async function
|
|
48
|
-
return (await
|
|
124
|
+
async function Ie() {
|
|
125
|
+
return (await Fe()).ocio.listBuiltinConfigs();
|
|
49
126
|
}
|
|
50
|
-
async function
|
|
51
|
-
let a = await
|
|
52
|
-
if (e)
|
|
127
|
+
async function Le({ builtin: e, text: t, files: n = [], configPath: r = "config.ocio", id: i } = {}) {
|
|
128
|
+
let a = await Fe();
|
|
129
|
+
if (e) A = a.loadBuiltinConfig(e), j = e, M = Be(a, e);
|
|
53
130
|
else {
|
|
54
131
|
let e = n.map((e) => ({
|
|
55
132
|
relativePath: e.relativePath ?? e.path ?? e.name,
|
|
@@ -59,42 +136,45 @@ async function xe({ builtin: e, text: t, files: n = [], configPath: r = "config.
|
|
|
59
136
|
relativePath: r,
|
|
60
137
|
data: new TextEncoder().encode(t)
|
|
61
138
|
}), !e.some((e) => e.relativePath === r)) throw Error(`config package has no "${r}" — pass configPath to name the .ocio file`);
|
|
62
|
-
|
|
139
|
+
A = a.loadConfigPackage({
|
|
63
140
|
configRelativePath: r,
|
|
64
141
|
files: e
|
|
65
|
-
}, i ? { id: i } : void 0),
|
|
142
|
+
}, i ? { id: i } : void 0), j = i ?? A.id;
|
|
66
143
|
let o = e.find((e) => e.relativePath === r);
|
|
67
|
-
|
|
144
|
+
M = o ? new TextDecoder().decode(o.data) : null;
|
|
68
145
|
}
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
function Se() {
|
|
72
|
-
O = null, k = null, A = null;
|
|
73
|
-
}
|
|
74
|
-
function j() {
|
|
75
|
-
return O !== null;
|
|
146
|
+
return I();
|
|
76
147
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
148
|
+
function Re() {
|
|
149
|
+
A = null, j = null, M = null;
|
|
79
150
|
}
|
|
80
151
|
function N() {
|
|
81
|
-
return
|
|
152
|
+
return A !== null;
|
|
82
153
|
}
|
|
83
154
|
function P() {
|
|
84
|
-
|
|
85
|
-
|
|
155
|
+
return A ? k : null;
|
|
156
|
+
}
|
|
157
|
+
function F() {
|
|
158
|
+
return A;
|
|
159
|
+
}
|
|
160
|
+
function ze() {
|
|
161
|
+
return M;
|
|
162
|
+
}
|
|
163
|
+
function I() {
|
|
164
|
+
if (!A) return null;
|
|
165
|
+
let e = Object.fromEntries(A.roles.map((e) => [e.name, e.colorSpace]));
|
|
86
166
|
return {
|
|
87
|
-
id:
|
|
88
|
-
name:
|
|
89
|
-
ocioVersion:
|
|
90
|
-
version:
|
|
167
|
+
id: j,
|
|
168
|
+
name: M?.match(/^name:\s*(\S.*?)\s*$/m)?.[1] ?? null,
|
|
169
|
+
ocioVersion: A.ocioVersion,
|
|
170
|
+
version: A.version,
|
|
91
171
|
roles: e,
|
|
92
172
|
sceneLinear: e.scene_linear ?? null,
|
|
93
173
|
colorPicking: e.color_picking ?? e.texture_paint ?? null,
|
|
94
174
|
texturePaint: e.texture_paint ?? e.color_picking ?? null,
|
|
95
175
|
data: e.data ?? null,
|
|
96
176
|
compositingLog: e.compositing_log ?? e.color_timing ?? null,
|
|
97
|
-
colorSpaces:
|
|
177
|
+
colorSpaces: A.colorSpaces.map((e) => ({
|
|
98
178
|
name: e.name,
|
|
99
179
|
family: e.family,
|
|
100
180
|
categories: e.categories ?? [],
|
|
@@ -103,25 +183,25 @@ function P() {
|
|
|
103
183
|
aliases: e.aliases,
|
|
104
184
|
description: e.description
|
|
105
185
|
})),
|
|
106
|
-
displays:
|
|
107
|
-
defaultDisplay:
|
|
108
|
-
views: Object.fromEntries(Object.entries(
|
|
186
|
+
displays: A.displays.slice(),
|
|
187
|
+
defaultDisplay: A.defaultDisplay,
|
|
188
|
+
views: Object.fromEntries(Object.entries(A.viewsByDisplay).map(([e, t]) => [e, t.map((e) => ({
|
|
109
189
|
name: e.name,
|
|
110
190
|
transform: e.transform,
|
|
111
191
|
colorSpace: e.colorSpace,
|
|
112
192
|
looks: e.looks,
|
|
113
193
|
description: e.description
|
|
114
194
|
}))])),
|
|
115
|
-
defaultViews: { ...
|
|
116
|
-
looks:
|
|
195
|
+
defaultViews: { ...A.defaultViewsByDisplay },
|
|
196
|
+
looks: A.looks.map((e) => ({
|
|
117
197
|
name: e.name,
|
|
118
198
|
processSpace: e.processSpace,
|
|
119
199
|
description: e.description,
|
|
120
200
|
forward: e.hasForwardTransform,
|
|
121
201
|
inverse: e.hasInverseTransform
|
|
122
202
|
})),
|
|
123
|
-
namedTransforms:
|
|
124
|
-
fileRules:
|
|
203
|
+
namedTransforms: A.namedTransforms.map((e) => e.name),
|
|
204
|
+
fileRules: A.fileRules.map((e) => ({
|
|
125
205
|
index: e.index,
|
|
126
206
|
name: e.name,
|
|
127
207
|
colorSpace: e.colorSpace,
|
|
@@ -129,19 +209,19 @@ function P() {
|
|
|
129
209
|
extension: e.extension,
|
|
130
210
|
regex: e.regex
|
|
131
211
|
})),
|
|
132
|
-
contextVariables:
|
|
212
|
+
contextVariables: Ve()
|
|
133
213
|
};
|
|
134
214
|
}
|
|
135
|
-
function
|
|
136
|
-
try {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
215
|
+
function Be(e, t) {
|
|
216
|
+
for (let n of [t, t.replace(/^ocio:\/\//, "")]) try {
|
|
217
|
+
let t = e.ocio.getBuiltinConfigYaml(n);
|
|
218
|
+
if (t) return t;
|
|
219
|
+
} catch {}
|
|
220
|
+
return null;
|
|
141
221
|
}
|
|
142
|
-
function
|
|
143
|
-
if (!
|
|
144
|
-
let e = /* @__PURE__ */ new Map(), t =
|
|
222
|
+
function Ve() {
|
|
223
|
+
if (!M) return [];
|
|
224
|
+
let e = /* @__PURE__ */ new Map(), t = M.split(/\r?\n/), n = t.findIndex((e) => /^environment:\s*(\{\s*\})?\s*$/.test(e));
|
|
145
225
|
if (n >= 0 && !/\{\s*\}/.test(t[n])) for (let r = n + 1; r < t.length; r++) {
|
|
146
226
|
let n = t[r];
|
|
147
227
|
if (/^\S/.test(n)) break;
|
|
@@ -152,99 +232,99 @@ function we() {
|
|
|
152
232
|
declared: !0
|
|
153
233
|
});
|
|
154
234
|
}
|
|
155
|
-
for (let t of
|
|
235
|
+
for (let t of M.matchAll(/\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?/g)) e.has(t[1]) || e.set(t[1], {
|
|
156
236
|
name: t[1],
|
|
157
237
|
default: null,
|
|
158
238
|
declared: !1
|
|
159
239
|
});
|
|
160
240
|
return [...e.values()].sort((e, t) => e.name.localeCompare(t.name));
|
|
161
241
|
}
|
|
162
|
-
function
|
|
163
|
-
|
|
242
|
+
function He() {
|
|
243
|
+
Re(), k?.dispose?.(), k = null, O = null;
|
|
164
244
|
}
|
|
165
245
|
//#endregion
|
|
166
246
|
//#region src/Color/ColorSpaces.js
|
|
167
|
-
var
|
|
168
|
-
function
|
|
247
|
+
var L = 1 << 20, R = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ new Map(), Ue = 4096, B = /* @__PURE__ */ new Map();
|
|
248
|
+
function We(e, t, n) {
|
|
169
249
|
return `${e}\u0000${t}\u0000${n ? JSON.stringify(n) : ""}`;
|
|
170
250
|
}
|
|
171
|
-
function
|
|
172
|
-
for (let e of
|
|
173
|
-
|
|
251
|
+
function Ge() {
|
|
252
|
+
for (let e of R.values()) e.dispose?.();
|
|
253
|
+
R.clear(), z.clear(), B.clear();
|
|
174
254
|
}
|
|
175
|
-
function
|
|
176
|
-
if (!
|
|
177
|
-
let r =
|
|
255
|
+
function Ke(e, t, { context: n = null } = {}) {
|
|
256
|
+
if (!P() || e === t) return null;
|
|
257
|
+
let r = We(e, t, n), i = R.get(r);
|
|
178
258
|
if (i !== void 0) return i;
|
|
179
259
|
try {
|
|
180
|
-
i =
|
|
260
|
+
i = Je().createColorSpaceProcessor(e, t, n ? { context: n } : void 0), i.isNoOp && (i.dispose(), i = null);
|
|
181
261
|
} catch (n) {
|
|
182
262
|
throw Error(`no OCIO transform from "${e}" to "${t}": ${n.message}`);
|
|
183
263
|
}
|
|
184
|
-
return
|
|
264
|
+
return R.set(r, i), i;
|
|
185
265
|
}
|
|
186
|
-
var
|
|
187
|
-
function
|
|
188
|
-
let e =
|
|
266
|
+
var V = null, qe = null, H = !1;
|
|
267
|
+
function Je() {
|
|
268
|
+
let e = P();
|
|
189
269
|
if (!e) throw Error("no OCIO config loaded");
|
|
190
270
|
if (e.config) return e.config;
|
|
191
|
-
let t =
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
return
|
|
271
|
+
let t = F();
|
|
272
|
+
if (V && qe === t.id) return V;
|
|
273
|
+
if (H && V?.dispose?.(), !t.id?.startsWith("ocio://")) throw Error("OCIO runtime exposes no Config handle for this config");
|
|
274
|
+
return V = e.ocio.createBuiltinConfig(t.id), H = !0, qe = t.id, V;
|
|
195
275
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
276
|
+
function Ye() {
|
|
277
|
+
H && V?.dispose?.(), V = null, qe = null, H = !1, Ge();
|
|
198
278
|
}
|
|
199
|
-
function
|
|
200
|
-
let i =
|
|
279
|
+
function Xe(e, t, n, { context: r = null } = {}) {
|
|
280
|
+
let i = P();
|
|
201
281
|
if (!i || t === n) return [
|
|
202
282
|
e[0],
|
|
203
283
|
e[1],
|
|
204
284
|
e[2]
|
|
205
285
|
];
|
|
206
|
-
let a = `${
|
|
286
|
+
let a = `${We(t, n, r)}\u0000${e[0]},${e[1]},${e[2]}`, o = z.get(a);
|
|
207
287
|
if (o) return o.slice();
|
|
208
288
|
let s = i.transformRgb(t, n, [
|
|
209
289
|
e[0],
|
|
210
290
|
e[1],
|
|
211
291
|
e[2]
|
|
212
292
|
], r ? { context: r } : void 0);
|
|
213
|
-
return
|
|
293
|
+
return z.size >= Ue && z.clear(), z.set(a, s), s.slice();
|
|
214
294
|
}
|
|
215
|
-
function
|
|
295
|
+
function U(e, t, n, { context: r = null } = {}) {
|
|
216
296
|
if (e.length % 4 != 0) throw Error("convertPixelsF32 wants 4 floats per pixel");
|
|
217
|
-
let i =
|
|
297
|
+
let i = Ke(t, n, { context: r });
|
|
218
298
|
if (!i) return e;
|
|
219
299
|
let a = e.length / 4;
|
|
220
|
-
if (a <=
|
|
221
|
-
for (let t = 0; t < a; t +=
|
|
222
|
-
let n = Math.min(
|
|
300
|
+
if (a <= L) return i.applyRGBAF32(e), e;
|
|
301
|
+
for (let t = 0; t < a; t += L) {
|
|
302
|
+
let n = Math.min(L, a - t);
|
|
223
303
|
i.applyRGBAF32(e.subarray(t * 4, (t + n) * 4));
|
|
224
304
|
}
|
|
225
305
|
return e;
|
|
226
306
|
}
|
|
227
|
-
var
|
|
228
|
-
function
|
|
229
|
-
return e <= .04045 ? e / 12.92 : ((e +
|
|
307
|
+
var W = .055;
|
|
308
|
+
function Ze(e) {
|
|
309
|
+
return e <= .04045 ? e / 12.92 : ((e + W) / (1 + W)) ** 2.4;
|
|
230
310
|
}
|
|
231
|
-
function
|
|
232
|
-
return e <= 0 ? 0 : e <= .0031308 ? 12.92 * e : (1 +
|
|
311
|
+
function Qe(e) {
|
|
312
|
+
return e <= 0 ? 0 : e <= .0031308 ? 12.92 * e : (1 + W) * e ** (1 / 2.4) - W;
|
|
233
313
|
}
|
|
234
|
-
var
|
|
235
|
-
for (let e = 0; e < 256; e++)
|
|
236
|
-
var
|
|
237
|
-
for (let e = 0; e < 256; e++)
|
|
238
|
-
function
|
|
239
|
-
return e === "srgb" ?
|
|
314
|
+
var $e = new Float32Array(256);
|
|
315
|
+
for (let e = 0; e < 256; e++) $e[e] = Ze(e / 255);
|
|
316
|
+
var et = new Float32Array(256);
|
|
317
|
+
for (let e = 0; e < 256; e++) et[e] = e / 255;
|
|
318
|
+
function tt(e) {
|
|
319
|
+
return e === "srgb" ? $e : et;
|
|
240
320
|
}
|
|
241
|
-
function
|
|
321
|
+
function nt(e, t, n, { context: r = null, inputEncoding: i = "raw", outputEncoding: a = "srgb" } = {}) {
|
|
242
322
|
if (e.length % 4 != 0) throw Error("convertEncodedRGBA8 wants 4 bytes per pixel");
|
|
243
|
-
let o =
|
|
323
|
+
let o = Ke(t, n, { context: r });
|
|
244
324
|
if (!o) return e;
|
|
245
|
-
let s = e.length / 4, c =
|
|
246
|
-
for (let t = 0; t < s; t +=
|
|
247
|
-
let n = Math.min(
|
|
325
|
+
let s = e.length / 4, c = tt(i), l = a === "srgb" ? it : at, u = new Float32Array(Math.min(L, s) * 4);
|
|
326
|
+
for (let t = 0; t < s; t += L) {
|
|
327
|
+
let n = Math.min(L, s - t), r = n * 4 === u.length ? u : u.subarray(0, n * 4);
|
|
248
328
|
for (let i = 0; i < n; i++) {
|
|
249
329
|
let n = (t + i) * 4, a = i * 4;
|
|
250
330
|
r[a] = c[e[n]], r[a + 1] = c[e[n + 1]], r[a + 2] = c[e[n + 2]], r[a + 3] = 1;
|
|
@@ -257,28 +337,28 @@ function Pe(e, t, n, { context: r = null, inputEncoding: i = "raw", outputEncodi
|
|
|
257
337
|
}
|
|
258
338
|
return e;
|
|
259
339
|
}
|
|
260
|
-
var
|
|
261
|
-
for (let e = 0; e <=
|
|
262
|
-
let t = e /
|
|
263
|
-
|
|
340
|
+
var G = 65536, rt = new Uint8Array(G + 1);
|
|
341
|
+
for (let e = 0; e <= G; e++) {
|
|
342
|
+
let t = e / G;
|
|
343
|
+
rt[e] = Math.round(Qe(t * t) * 255);
|
|
264
344
|
}
|
|
265
|
-
function
|
|
266
|
-
return e > 0 ? e >= 1 ? 255 :
|
|
345
|
+
function it(e) {
|
|
346
|
+
return e > 0 ? e >= 1 ? 255 : rt[Math.sqrt(e) * G + .5 | 0] : 0;
|
|
267
347
|
}
|
|
268
|
-
function
|
|
348
|
+
function at(e) {
|
|
269
349
|
return e > 0 ? e >= 1 ? 255 : e * 255 + .5 | 0 : 0;
|
|
270
350
|
}
|
|
271
|
-
function
|
|
351
|
+
function ot(e, t, n = "srgb") {
|
|
272
352
|
if (!t) return e;
|
|
273
|
-
let r =
|
|
353
|
+
let r = tt(n), i = n === "srgb" ? it : at, [a, o, s, c, l, u, d, f, p] = t;
|
|
274
354
|
for (let t = 0; t < e.length; t += 4) {
|
|
275
355
|
let n = r[e[t]], m = r[e[t + 1]], h = r[e[t + 2]];
|
|
276
356
|
e[t] = i(a * n + o * m + s * h), e[t + 1] = i(c * n + l * m + u * h), e[t + 2] = i(d * n + f * m + p * h);
|
|
277
357
|
}
|
|
278
358
|
return e;
|
|
279
359
|
}
|
|
280
|
-
function
|
|
281
|
-
if (!
|
|
360
|
+
function st(e, t, { context: n = null, tolerance: r = 1e-4 } = {}) {
|
|
361
|
+
if (!P()) return null;
|
|
282
362
|
if (e === t) return [
|
|
283
363
|
1,
|
|
284
364
|
0,
|
|
@@ -290,10 +370,10 @@ function ze(e, t, { context: n = null, tolerance: r = 1e-4 } = {}) {
|
|
|
290
370
|
0,
|
|
291
371
|
1
|
|
292
372
|
];
|
|
293
|
-
let i =
|
|
294
|
-
if (
|
|
295
|
-
let a =
|
|
296
|
-
if (!a) return
|
|
373
|
+
let i = We(e, t, n);
|
|
374
|
+
if (B.has(i)) return B.get(i);
|
|
375
|
+
let a = Ke(e, t, { context: n });
|
|
376
|
+
if (!a) return B.set(i, [
|
|
297
377
|
1,
|
|
298
378
|
0,
|
|
299
379
|
0,
|
|
@@ -303,7 +383,7 @@ function ze(e, t, { context: n = null, tolerance: r = 1e-4 } = {}) {
|
|
|
303
383
|
0,
|
|
304
384
|
0,
|
|
305
385
|
1
|
|
306
|
-
]),
|
|
386
|
+
]), B.get(i);
|
|
307
387
|
let o = (e) => {
|
|
308
388
|
let t = new Float32Array([
|
|
309
389
|
e[0],
|
|
@@ -384,36 +464,36 @@ function ze(e, t, { context: n = null, tolerance: r = 1e-4 } = {}) {
|
|
|
384
464
|
if (!d) break;
|
|
385
465
|
}
|
|
386
466
|
let f = d ? c : null;
|
|
387
|
-
return
|
|
467
|
+
return B.set(i, f), f;
|
|
388
468
|
}
|
|
389
|
-
function
|
|
390
|
-
let t =
|
|
469
|
+
function ct(e) {
|
|
470
|
+
let t = F();
|
|
391
471
|
if (!t) return !1;
|
|
392
472
|
let n = t.colorSpaces.find((t) => t.name === e || t.aliases?.includes(e));
|
|
393
473
|
return n ? n.isData : !1;
|
|
394
474
|
}
|
|
395
|
-
function
|
|
396
|
-
let t =
|
|
475
|
+
function K(e) {
|
|
476
|
+
let t = F();
|
|
397
477
|
return !t || !e ? !1 : t.colorSpaces.some((t) => t.name === e || t.aliases?.includes(e));
|
|
398
478
|
}
|
|
399
479
|
//#endregion
|
|
400
480
|
//#region src/Color/LutBake.js
|
|
401
|
-
var
|
|
402
|
-
function
|
|
481
|
+
var lt = 1e-10;
|
|
482
|
+
function ut(e, t, n, r) {
|
|
403
483
|
return e <= 0 ? 0 : 2 ** (n + e / (t - 1) * (r - n));
|
|
404
484
|
}
|
|
405
|
-
function
|
|
406
|
-
let i = (Math.log2(Math.max(e,
|
|
485
|
+
function dt(e, t, n, r) {
|
|
486
|
+
let i = (Math.log2(Math.max(e, lt)) - n) / (r - n);
|
|
407
487
|
return Math.min(Math.max(i, 0), 1) * (t - 1);
|
|
408
488
|
}
|
|
409
|
-
function
|
|
489
|
+
function ft({ size: e, minEv: t, maxEv: n, apply: r }) {
|
|
410
490
|
let i = e * e * e, a = new Float32Array(i * 4), o = new Float64Array(e);
|
|
411
|
-
for (let r = 0; r < e; r++) o[r] =
|
|
491
|
+
for (let r = 0; r < e; r++) o[r] = ut(r, e, t, n);
|
|
412
492
|
let s = 0;
|
|
413
493
|
for (let t = 0; t < e; t++) for (let n = 0; n < e; n++) for (let r = 0; r < e; r++) a[s++] = o[r], a[s++] = o[n], a[s++] = o[t], a[s++] = 1;
|
|
414
494
|
return r(a), a;
|
|
415
495
|
}
|
|
416
|
-
function
|
|
496
|
+
function pt(e) {
|
|
417
497
|
let t = new Uint16Array(e.length), n = new Float32Array(1), r = new Uint32Array(n.buffer);
|
|
418
498
|
for (let i = 0; i < e.length; i++) {
|
|
419
499
|
n[0] = e[i];
|
|
@@ -430,23 +510,23 @@ function Ge(e) {
|
|
|
430
510
|
}
|
|
431
511
|
return t;
|
|
432
512
|
}
|
|
433
|
-
function
|
|
513
|
+
function mt(e, t = new Float32Array(e.length)) {
|
|
434
514
|
for (let n = 0; n < e.length; n++) {
|
|
435
515
|
let r = e[n], i = r & 32768 ? -1 : 1, a = (r & 31744) >> 10, o = r & 1023;
|
|
436
516
|
a === 0 ? t[n] = i * 2 ** -14 * (o / 1024) : a === 31 ? t[n] = o ? NaN : i * Infinity : t[n] = i * 2 ** (a - 15) * (1 + o / 1024);
|
|
437
517
|
}
|
|
438
518
|
return t;
|
|
439
519
|
}
|
|
440
|
-
var
|
|
441
|
-
function
|
|
442
|
-
if (!
|
|
520
|
+
var ht = null;
|
|
521
|
+
function gt() {
|
|
522
|
+
if (!ht) {
|
|
443
523
|
let e = new Uint16Array(65536);
|
|
444
524
|
for (let t = 0; t < 65536; t++) e[t] = t;
|
|
445
|
-
|
|
525
|
+
ht = mt(e);
|
|
446
526
|
}
|
|
447
|
-
return
|
|
527
|
+
return ht;
|
|
448
528
|
}
|
|
449
|
-
function
|
|
529
|
+
function _t(e, t, n) {
|
|
450
530
|
return e > t ? t > n ? {
|
|
451
531
|
w: [
|
|
452
532
|
e,
|
|
@@ -587,10 +667,10 @@ function Ye(e, t, n) {
|
|
|
587
667
|
]
|
|
588
668
|
};
|
|
589
669
|
}
|
|
590
|
-
function
|
|
591
|
-
let i = t * t, a = t - 1, o = e instanceof Uint16Array, s = o ?
|
|
670
|
+
function vt({ data: e, size: t, minEv: n, maxEv: r }) {
|
|
671
|
+
let i = t * t, a = t - 1, o = e instanceof Uint16Array, s = o ? gt() : null, c = o ? (n, r, a, o) => s[e[(n + r * t + a * i) * 4 + o]] : (n, r, a, o) => e[(n + r * t + a * i) * 4 + o];
|
|
592
672
|
return function(e, i, o, s) {
|
|
593
|
-
let l =
|
|
673
|
+
let l = dt(e, t, n, r), u = dt(i, t, n, r), d = dt(o, t, n, r), f = Math.min(Math.floor(l), a - 1), p = Math.min(Math.floor(u), a - 1), m = Math.min(Math.floor(d), a - 1), { w: h, c: g } = _t(Math.min(Math.max(l - f, 0), 1), Math.min(Math.max(u - p, 0), 1), Math.min(Math.max(d - m, 0), 1));
|
|
594
674
|
for (let e = 0; e < 3; e++) {
|
|
595
675
|
let t = c(f, p, m, e), n = t, r = t;
|
|
596
676
|
for (let t = 0; t < 3; t++) {
|
|
@@ -601,7 +681,7 @@ function Xe({ data: e, size: t, minEv: n, maxEv: r }) {
|
|
|
601
681
|
}
|
|
602
682
|
};
|
|
603
683
|
}
|
|
604
|
-
function
|
|
684
|
+
function yt({ fnName: e, texName: t, size: n, minEv: r, maxEv: i }) {
|
|
605
685
|
let a = (e) => Number.isInteger(e) ? `${e}.0` : String(e);
|
|
606
686
|
return `
|
|
607
687
|
fn ${e}_shape( v: vec3<f32> ) -> vec3<f32> {
|
|
@@ -657,7 +737,7 @@ fn ${e}( c: vec3<f32> ) -> vec3<f32> {
|
|
|
657
737
|
}
|
|
658
738
|
`;
|
|
659
739
|
}
|
|
660
|
-
function
|
|
740
|
+
function bt({ sampler: e, apply: t, count: n = 4e3, seed: r = 31337 }) {
|
|
661
741
|
let i = r >>> 0, a = () => (i = i * 1664525 + 1013904223 >>> 0) / 4294967296, o = [];
|
|
662
742
|
for (let e = 0; e < n; e++) {
|
|
663
743
|
let e = .18 * 2 ** (-7 + a() * 13), t = a() ** 1.2, n = a() * 6, r = [
|
|
@@ -689,41 +769,199 @@ function Qe({ sampler: e, apply: t, count: n = 4e3, seed: r = 31337 }) {
|
|
|
689
769
|
}
|
|
690
770
|
//#endregion
|
|
691
771
|
//#region src/Color/OcioViews.js
|
|
692
|
-
var
|
|
693
|
-
function
|
|
694
|
-
|
|
772
|
+
var xt = -12.47393, St = 12.5260688117, Ct = 65, wt = null, q = /* @__PURE__ */ new Map();
|
|
773
|
+
function Tt(e) {
|
|
774
|
+
wt = e;
|
|
695
775
|
}
|
|
696
|
-
function
|
|
697
|
-
let e =
|
|
776
|
+
function Et() {
|
|
777
|
+
let e = P();
|
|
698
778
|
if (!e) throw Error("load an OCIO config first");
|
|
699
779
|
if (!e.config) throw Error("OCIO runtime exposes no Config handle");
|
|
700
780
|
return e.config;
|
|
701
781
|
}
|
|
702
|
-
function
|
|
703
|
-
let
|
|
704
|
-
return r ?
|
|
705
|
-
type: "look",
|
|
706
|
-
source: e,
|
|
707
|
-
destination: e,
|
|
708
|
-
looks: r
|
|
709
|
-
}, {
|
|
710
|
-
type: "displayView",
|
|
782
|
+
function Dt({ source: e, display: t, view: n, look: r, context: i, decodeFrom: a = null, decodeTo: o = null }) {
|
|
783
|
+
let s = Et(), c = i ? { context: i } : void 0;
|
|
784
|
+
return !r && !o ? s.createDisplayViewProcessor({
|
|
711
785
|
source: e,
|
|
712
786
|
display: t,
|
|
713
|
-
view: n
|
|
714
|
-
|
|
787
|
+
view: n,
|
|
788
|
+
...i ? { context: i } : {}
|
|
789
|
+
}) : s.createGroupTransformProcessor([
|
|
790
|
+
...r ? [{
|
|
791
|
+
type: "look",
|
|
792
|
+
source: e,
|
|
793
|
+
destination: e,
|
|
794
|
+
looks: r
|
|
795
|
+
}] : [],
|
|
796
|
+
{
|
|
797
|
+
type: "displayView",
|
|
798
|
+
source: e,
|
|
799
|
+
display: t,
|
|
800
|
+
view: n
|
|
801
|
+
},
|
|
802
|
+
...o ? [{
|
|
803
|
+
type: "colorSpace",
|
|
804
|
+
source: a,
|
|
805
|
+
destination: o
|
|
806
|
+
}] : []
|
|
807
|
+
], c);
|
|
808
|
+
}
|
|
809
|
+
function Ot(e, t, n) {
|
|
810
|
+
let r = e.viewsByDisplay[t]?.find((e) => e.name === n)?.colorSpace;
|
|
811
|
+
return !r || r === "<USE_DISPLAY_NAME>" ? t : r;
|
|
812
|
+
}
|
|
813
|
+
var kt = /* @__PURE__ */ new WeakMap(), At = (e) => Math.sign(e) * (Math.abs(e) <= .04045 ? Math.abs(e) / 12.92 : ((Math.abs(e) + .055) / 1.055) ** 2.4), jt = (e, t) => [
|
|
814
|
+
0,
|
|
815
|
+
3,
|
|
816
|
+
6
|
|
817
|
+
].map((n) => e[n] * t[0] + e[n + 1] * t[1] + e[n + 2] * t[2]);
|
|
818
|
+
function Mt(e) {
|
|
819
|
+
let [t, n, r, i, a, o, s, c, l] = e, u = a * l - o * c, d = o * s - i * l, f = i * c - a * s, p = t * u + n * d + r * f;
|
|
820
|
+
return [
|
|
821
|
+
u,
|
|
822
|
+
r * c - n * l,
|
|
823
|
+
n * o - r * a,
|
|
824
|
+
d,
|
|
825
|
+
t * l - r * s,
|
|
826
|
+
r * i - t * o,
|
|
827
|
+
f,
|
|
828
|
+
n * s - t * c,
|
|
829
|
+
t * a - n * i
|
|
830
|
+
].map((e) => e / p);
|
|
831
|
+
}
|
|
832
|
+
function Nt(e) {
|
|
833
|
+
let t = F();
|
|
834
|
+
if (!t) return {
|
|
835
|
+
fit: w(e),
|
|
836
|
+
wide: !1,
|
|
837
|
+
convertible: !1
|
|
838
|
+
};
|
|
839
|
+
let n = kt.get(t);
|
|
840
|
+
if (n || kt.set(t, n = /* @__PURE__ */ new Map()), n.has(e)) return n.get(e);
|
|
841
|
+
let r = t.colorSpaces.find((t) => t.name === e || t.aliases?.includes(e)), i = Y(), a = {
|
|
842
|
+
fit: w(e),
|
|
843
|
+
wide: !1,
|
|
844
|
+
convertible: !1
|
|
845
|
+
};
|
|
846
|
+
if (i && !r?.isData && r?.referenceSpace !== 0) {
|
|
847
|
+
let t = [
|
|
848
|
+
[
|
|
849
|
+
1,
|
|
850
|
+
0,
|
|
851
|
+
0
|
|
852
|
+
],
|
|
853
|
+
[
|
|
854
|
+
0,
|
|
855
|
+
1,
|
|
856
|
+
0
|
|
857
|
+
],
|
|
858
|
+
[
|
|
859
|
+
0,
|
|
860
|
+
0,
|
|
861
|
+
1
|
|
862
|
+
],
|
|
863
|
+
[
|
|
864
|
+
.5,
|
|
865
|
+
.5,
|
|
866
|
+
.5
|
|
867
|
+
],
|
|
868
|
+
[
|
|
869
|
+
.2,
|
|
870
|
+
.7,
|
|
871
|
+
.1
|
|
872
|
+
],
|
|
873
|
+
[
|
|
874
|
+
.9,
|
|
875
|
+
.05,
|
|
876
|
+
.4
|
|
877
|
+
],
|
|
878
|
+
[
|
|
879
|
+
.02,
|
|
880
|
+
.02,
|
|
881
|
+
.02
|
|
882
|
+
],
|
|
883
|
+
[
|
|
884
|
+
1,
|
|
885
|
+
1,
|
|
886
|
+
1
|
|
887
|
+
]
|
|
888
|
+
], n = new Float32Array(t.flatMap((e) => [...e, 1])), r = Et().createColorSpaceProcessor(e, i);
|
|
889
|
+
try {
|
|
890
|
+
r.applyRGBAF32(n);
|
|
891
|
+
} finally {
|
|
892
|
+
r.dispose();
|
|
893
|
+
}
|
|
894
|
+
let o = (e) => [
|
|
895
|
+
n[e * 4],
|
|
896
|
+
n[e * 4 + 1],
|
|
897
|
+
n[e * 4 + 2]
|
|
898
|
+
], s = (e) => {
|
|
899
|
+
let n = Mt(J[e]);
|
|
900
|
+
return t.every((e, t) => jt(n, e.map(At)).every((e, n) => Math.abs(o(t)[n] - e) <= .002 * Math.max(1, Math.abs(e))));
|
|
901
|
+
}, c = [
|
|
902
|
+
0,
|
|
903
|
+
1,
|
|
904
|
+
2
|
|
905
|
+
].some((e) => {
|
|
906
|
+
let t = jt(J.srgb, o(e));
|
|
907
|
+
return Math.min(...t) < -.001 * Math.max(...t.map(Math.abs));
|
|
908
|
+
});
|
|
909
|
+
a = {
|
|
910
|
+
fit: ["srgb", "display-p3"].find(s) ?? null,
|
|
911
|
+
wide: c,
|
|
912
|
+
convertible: !0
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
return n.set(e, a), a;
|
|
916
|
+
}
|
|
917
|
+
function Pt(e, t) {
|
|
918
|
+
let n = J[t];
|
|
919
|
+
for (let t = 0; t < e.length; t += 4) {
|
|
920
|
+
let r = e[t], i = e[t + 1], a = e[t + 2];
|
|
921
|
+
e[t] = Vt(n[0] * r + n[1] * i + n[2] * a), e[t + 1] = Vt(n[3] * r + n[4] * i + n[5] * a), e[t + 2] = Vt(n[6] * r + n[7] * i + n[8] * a);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
function Ft({ source: e, display: t, view: n, look: r, context: i, canvas: a = null, size: o, minEv: s, maxEv: c }) {
|
|
925
|
+
let l = Dt({
|
|
715
926
|
source: e,
|
|
716
927
|
display: t,
|
|
717
928
|
view: n,
|
|
718
|
-
|
|
719
|
-
|
|
929
|
+
look: r,
|
|
930
|
+
context: i,
|
|
931
|
+
decodeFrom: a ? Ot(F(), t, n) : null,
|
|
932
|
+
decodeTo: a && Y()
|
|
933
|
+
}), u = (e) => {
|
|
934
|
+
l.applyRGBAF32(e), a && Pt(e, a);
|
|
935
|
+
};
|
|
936
|
+
try {
|
|
937
|
+
let e = pt(ft({
|
|
938
|
+
size: o,
|
|
939
|
+
minEv: s,
|
|
940
|
+
maxEv: c,
|
|
941
|
+
apply: u
|
|
942
|
+
}));
|
|
943
|
+
return {
|
|
944
|
+
half: e,
|
|
945
|
+
error: bt({
|
|
946
|
+
sampler: vt({
|
|
947
|
+
data: e,
|
|
948
|
+
size: o,
|
|
949
|
+
minEv: s,
|
|
950
|
+
maxEv: c
|
|
951
|
+
}),
|
|
952
|
+
apply: u
|
|
953
|
+
})
|
|
954
|
+
};
|
|
955
|
+
} finally {
|
|
956
|
+
l.dispose();
|
|
957
|
+
}
|
|
720
958
|
}
|
|
721
|
-
function
|
|
959
|
+
function It({ texture: e, size: t, minEv: n, maxEv: r }) {
|
|
722
960
|
let i = t - 1, a = r - n, o = (t) => ce(e, x(t, S(0), S(i))).rgb;
|
|
723
|
-
return
|
|
961
|
+
return ne(([e, r]) => {
|
|
724
962
|
let s = x(oe(se(se(e.mul(r), C(0)), C(1e-10))).sub(ie(n)).div(ie(a)), C(0), C(1)).mul(ie(i)).toVar(), c = x(S(ae(s)), S(0), S(t - 2)).toVar(), l = x(s.sub(C(c)), C(0), C(1)).toVar(), u = C(0).toVar(), d = S(0).toVar(), f = S(0).toVar(), p = S(1).toVar();
|
|
725
|
-
|
|
726
|
-
|
|
963
|
+
re(l.x.greaterThan(l.y), () => {
|
|
964
|
+
re(l.y.greaterThan(l.z), () => {
|
|
727
965
|
u.assign(C(l.x, l.y, l.z)), d.assign(S(1, 0, 0)), f.assign(S(1, 1, 0)), p.assign(S(1, 1, 1));
|
|
728
966
|
}).ElseIf(l.x.greaterThan(l.z), () => {
|
|
729
967
|
u.assign(C(l.x, l.z, l.y)), d.assign(S(1, 0, 0)), f.assign(S(1, 0, 1)), p.assign(S(1, 1, 1));
|
|
@@ -731,7 +969,7 @@ function ot({ texture: e, size: t, minEv: n, maxEv: r }) {
|
|
|
731
969
|
u.assign(C(l.z, l.x, l.y)), d.assign(S(0, 0, 1)), f.assign(S(1, 0, 1)), p.assign(S(1, 1, 1));
|
|
732
970
|
});
|
|
733
971
|
}).Else(() => {
|
|
734
|
-
|
|
972
|
+
re(l.z.greaterThan(l.y), () => {
|
|
735
973
|
u.assign(C(l.z, l.y, l.x)), d.assign(S(0, 0, 1)), f.assign(S(0, 1, 1)), p.assign(S(1, 1, 1));
|
|
736
974
|
}).ElseIf(l.z.greaterThan(l.x), () => {
|
|
737
975
|
u.assign(C(l.y, l.z, l.x)), d.assign(S(0, 1, 0)), f.assign(S(0, 1, 1)), p.assign(S(1, 1, 1));
|
|
@@ -743,8 +981,8 @@ function ot({ texture: e, size: t, minEv: n, maxEv: r }) {
|
|
|
743
981
|
return m.add(h.sub(m).mul(u.x)).add(g.sub(h).mul(u.y)).add(_.sub(g).mul(u.z));
|
|
744
982
|
});
|
|
745
983
|
}
|
|
746
|
-
function
|
|
747
|
-
let d =
|
|
984
|
+
function Lt({ display: e, view: n, look: r = null, context: i = null, source: a = null, size: o = 65, minEv: s = xt, maxEv: c = St, id: l = null, name: u = null } = {}) {
|
|
985
|
+
let d = F();
|
|
748
986
|
if (!d) throw Error("load an OCIO config first");
|
|
749
987
|
let f = d.roles.find((e) => e.name === "scene_linear")?.colorSpace, p = a ?? f;
|
|
750
988
|
if (!p) throw Error("config has no scene_linear role — pass an explicit source space");
|
|
@@ -752,39 +990,26 @@ function st({ display: e, view: n, look: r = null, context: i = null, source: a
|
|
|
752
990
|
let m = (d.viewsByDisplay[e] ?? []).map((e) => e.name);
|
|
753
991
|
if (!m.includes(n)) throw Error(`display "${e}" has no view "${n}" — has ${m.join(", ")}`);
|
|
754
992
|
if (r && !d.looks.some((e) => e.name === r)) throw Error(`config has no look "${r}" — has ${d.looks.map((e) => e.name).join(", ")}`);
|
|
755
|
-
|
|
993
|
+
let { fit: h, wide: g, convertible: _ } = Nt(Ot(d, e, n)), v = !h && _, y = h ?? (v && g ? "display-p3" : "srgb");
|
|
994
|
+
!h && !Y() && !Te(I(), e, n) && wt?.warn(t.VIEW_TRANSFORM_DISPLAY_MISMATCH, `"${e}" is no canvas colour space and the config cannot convert it, so the screen shows its codes as sRGB`, {
|
|
756
995
|
display: e,
|
|
757
996
|
view: n
|
|
758
997
|
});
|
|
759
|
-
let
|
|
998
|
+
let { half: ee, error: te } = Ft({
|
|
760
999
|
source: p,
|
|
761
1000
|
display: e,
|
|
762
1001
|
view: n,
|
|
763
1002
|
look: r,
|
|
764
|
-
context: i
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
apply: g
|
|
772
|
-
})), v = Qe({
|
|
773
|
-
sampler: Xe({
|
|
774
|
-
data: _,
|
|
775
|
-
size: o,
|
|
776
|
-
minEv: s,
|
|
777
|
-
maxEv: c
|
|
778
|
-
}),
|
|
779
|
-
apply: g
|
|
780
|
-
});
|
|
781
|
-
} finally {
|
|
782
|
-
h.dispose();
|
|
783
|
-
}
|
|
784
|
-
return lt({
|
|
1003
|
+
context: i,
|
|
1004
|
+
canvas: v ? y : null,
|
|
1005
|
+
size: o,
|
|
1006
|
+
minEv: s,
|
|
1007
|
+
maxEv: c
|
|
1008
|
+
});
|
|
1009
|
+
return Bt({
|
|
785
1010
|
id: l,
|
|
786
|
-
half:
|
|
787
|
-
error:
|
|
1011
|
+
half: ee,
|
|
1012
|
+
error: te,
|
|
788
1013
|
name: u ?? (r ? `${n} + ${r} (${e})` : `${n} (${e})`),
|
|
789
1014
|
ocio: {
|
|
790
1015
|
display: e,
|
|
@@ -795,13 +1020,15 @@ function st({ display: e, view: n, look: r = null, context: i = null, source: a
|
|
|
795
1020
|
configId: d.id,
|
|
796
1021
|
size: o,
|
|
797
1022
|
minEv: s,
|
|
798
|
-
maxEv: c
|
|
1023
|
+
maxEv: c,
|
|
1024
|
+
canvas: y,
|
|
1025
|
+
emulated: v
|
|
799
1026
|
}
|
|
800
1027
|
});
|
|
801
1028
|
}
|
|
802
|
-
function
|
|
803
|
-
let { name: n, data: r, error: i, configId: a, display: o, view: s, look: c, context: l, source: u, size: d, minEv: f, maxEv: p, fingerprint: m, ocioVersion: h } = e;
|
|
804
|
-
return
|
|
1029
|
+
function Rt(e, t = null) {
|
|
1030
|
+
let { name: n, data: r, error: i, configId: a, display: o, view: s, look: c, context: l, source: u, size: d, minEv: f, maxEv: p, fingerprint: m, ocioVersion: h, canvas: g, emulated: _ } = e;
|
|
1031
|
+
return Bt({
|
|
805
1032
|
id: t,
|
|
806
1033
|
name: n,
|
|
807
1034
|
error: i,
|
|
@@ -816,6 +1043,8 @@ function ct(e, t = null) {
|
|
|
816
1043
|
size: d,
|
|
817
1044
|
minEv: f,
|
|
818
1045
|
maxEv: p,
|
|
1046
|
+
canvas: g ?? w(o) ?? "srgb",
|
|
1047
|
+
emulated: !!_,
|
|
819
1048
|
baked: {
|
|
820
1049
|
fingerprint: m ?? null,
|
|
821
1050
|
ocioVersion: h ?? null
|
|
@@ -823,19 +1052,23 @@ function ct(e, t = null) {
|
|
|
823
1052
|
}
|
|
824
1053
|
});
|
|
825
1054
|
}
|
|
826
|
-
function
|
|
827
|
-
let
|
|
1055
|
+
function zt(e, t) {
|
|
1056
|
+
let n = new ue(e, t, t, t);
|
|
1057
|
+
return n.format = ge, n.type = de, n.minFilter = pe, n.magFilter = pe, n.wrapS = n.wrapT = n.wrapR = le, n.needsUpdate = !0, n;
|
|
1058
|
+
}
|
|
1059
|
+
function Bt({ id: e, name: t, half: n, error: r, ocio: i }) {
|
|
1060
|
+
let { size: a, minEv: o, maxEv: s } = i, c = vt({
|
|
828
1061
|
data: n,
|
|
829
1062
|
size: a,
|
|
830
1063
|
minEv: o,
|
|
831
1064
|
maxEv: s
|
|
832
|
-
}), l = e ?? m(), u = `TM_OCIO_${l}`, d = `tm_ocio_${l}`, f =
|
|
833
|
-
return p ? (h = f.texture, h.image.data = n, h.needsUpdate = !0, g = f.tsl) : (f?.texture.dispose(), h =
|
|
1065
|
+
}), l = e ?? m(), u = `TM_OCIO_${l}`, d = `tm_ocio_${l}`, f = q.get(l), p = f && f.size === a && f.minEv === o && f.maxEv === s, h, g;
|
|
1066
|
+
return p ? (h = f.texture, h.image.data = n, h.needsUpdate = !0, g = f.tsl) : (f?.texture.dispose(), h = zt(n, a), g = It({
|
|
834
1067
|
texture: h,
|
|
835
1068
|
size: a,
|
|
836
1069
|
minEv: o,
|
|
837
1070
|
maxEv: s
|
|
838
|
-
})),
|
|
1071
|
+
})), q.set(l, {
|
|
839
1072
|
texture: h,
|
|
840
1073
|
tsl: g,
|
|
841
1074
|
size: a,
|
|
@@ -849,7 +1082,7 @@ function lt({ id: e, name: t, half: n, error: r, ocio: i }) {
|
|
|
849
1082
|
outputEncoded: !0,
|
|
850
1083
|
appliesExposure: !0,
|
|
851
1084
|
cpu: (e, t, n, r, i) => c(e * r, t * r, n * r, i),
|
|
852
|
-
wgsl:
|
|
1085
|
+
wgsl: yt({
|
|
853
1086
|
fnName: d,
|
|
854
1087
|
texName: `${u.toLowerCase()}_tex`,
|
|
855
1088
|
size: a,
|
|
@@ -867,11 +1100,121 @@ function lt({ id: e, name: t, half: n, error: r, ocio: i }) {
|
|
|
867
1100
|
ocio: i
|
|
868
1101
|
};
|
|
869
1102
|
}
|
|
870
|
-
|
|
871
|
-
|
|
1103
|
+
var J = Object.freeze({
|
|
1104
|
+
srgb: [
|
|
1105
|
+
3.2409699419045226,
|
|
1106
|
+
-1.537383177570094,
|
|
1107
|
+
-.4986107602930034,
|
|
1108
|
+
-.9692436362808796,
|
|
1109
|
+
1.8759675015077202,
|
|
1110
|
+
.04155505740717559,
|
|
1111
|
+
.05563007969699366,
|
|
1112
|
+
-.20397695888897652,
|
|
1113
|
+
1.0569715142428786
|
|
1114
|
+
],
|
|
1115
|
+
"display-p3": [
|
|
1116
|
+
446124 / 178915,
|
|
1117
|
+
-333277 / 357830,
|
|
1118
|
+
-72051 / 178915,
|
|
1119
|
+
-14852 / 17905,
|
|
1120
|
+
63121 / 35810,
|
|
1121
|
+
423 / 17905,
|
|
1122
|
+
11844 / 330415,
|
|
1123
|
+
-50337 / 660830,
|
|
1124
|
+
316169 / 330415
|
|
1125
|
+
]
|
|
1126
|
+
});
|
|
1127
|
+
function Vt(e) {
|
|
1128
|
+
let t = Math.abs(e), n = t <= .0031308 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - .055;
|
|
1129
|
+
return e < 0 ? -n : n;
|
|
1130
|
+
}
|
|
1131
|
+
function Y() {
|
|
1132
|
+
let e = F()?.colorSpaces.find((e) => e.encoding === "display-linear")?.name, t = (ze()?.split(/^display_colorspaces:[^\n]*$/m)[1]?.split(/^\S/m)[0] ?? "").split(/-\s*!<ColorSpace>/).slice(1), n = t.find((e) => /^\s*encoding:\s*display-linear\s*$/m.test(e)) ?? t.find((e) => !/_display_reference:/.test(e)), r = e ?? n?.match(/^\s*name:\s*(.+?)\s*$/m)?.[1].replace(/^["']|["']$/g, "") ?? null;
|
|
1133
|
+
return r && /xyz/i.test(r) ? r : null;
|
|
1134
|
+
}
|
|
1135
|
+
function Ht({ display: e, view: t, look: n = null, context: r = null, source: i = null, canvas: a = "srgb", for: o = null, size: s = 65, minEv: c = xt, maxEv: l = St } = {}) {
|
|
1136
|
+
let u = F();
|
|
1137
|
+
if (!u) throw Error("load an OCIO config first");
|
|
1138
|
+
let d = i ?? u.roles.find((e) => e.name === "scene_linear")?.colorSpace;
|
|
1139
|
+
if (!Y()) throw Error("the config names no display-referred CIE XYZ space to decode its displays in");
|
|
1140
|
+
if (!J[a]) throw Error(`no encoding for a "${a}" canvas`);
|
|
1141
|
+
let { half: f, error: p } = Ft({
|
|
1142
|
+
source: d,
|
|
1143
|
+
display: e,
|
|
1144
|
+
view: t,
|
|
1145
|
+
look: n,
|
|
1146
|
+
context: r,
|
|
1147
|
+
canvas: a,
|
|
1148
|
+
size: s,
|
|
1149
|
+
minEv: c,
|
|
1150
|
+
maxEv: l
|
|
1151
|
+
});
|
|
1152
|
+
return Wt({
|
|
1153
|
+
name: n ? `${t} + ${n} (${e})` : `${t} (${e})`,
|
|
1154
|
+
half: f,
|
|
1155
|
+
error: p,
|
|
1156
|
+
ocio: {
|
|
1157
|
+
display: e,
|
|
1158
|
+
view: t,
|
|
1159
|
+
look: n,
|
|
1160
|
+
context: r,
|
|
1161
|
+
source: d,
|
|
1162
|
+
configId: u.id,
|
|
1163
|
+
size: s,
|
|
1164
|
+
minEv: c,
|
|
1165
|
+
maxEv: l,
|
|
1166
|
+
canvas: a,
|
|
1167
|
+
for: o
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
function Ut(e) {
|
|
1172
|
+
let { name: t, data: n, error: r, configId: i, display: a, view: o, look: s, context: c, source: l, size: u, minEv: d, maxEv: f, canvas: p, for: m } = e;
|
|
1173
|
+
return Wt({
|
|
1174
|
+
name: t,
|
|
1175
|
+
half: n,
|
|
1176
|
+
error: r,
|
|
1177
|
+
ocio: {
|
|
1178
|
+
display: a,
|
|
1179
|
+
view: o,
|
|
1180
|
+
look: s ?? null,
|
|
1181
|
+
context: c ?? null,
|
|
1182
|
+
source: l,
|
|
1183
|
+
configId: i,
|
|
1184
|
+
size: u,
|
|
1185
|
+
minEv: d,
|
|
1186
|
+
maxEv: f,
|
|
1187
|
+
canvas: p ?? "srgb",
|
|
1188
|
+
for: m ?? null
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
function Wt({ name: e, half: t, error: n, ocio: r }) {
|
|
1193
|
+
let { size: i, minEv: a, maxEv: o } = r, s = zt(t, i);
|
|
1194
|
+
return {
|
|
1195
|
+
name: e,
|
|
1196
|
+
source: "ocio",
|
|
1197
|
+
error: n,
|
|
1198
|
+
ocio: r,
|
|
1199
|
+
table: {
|
|
1200
|
+
data: t,
|
|
1201
|
+
size: i,
|
|
1202
|
+
texture: s
|
|
1203
|
+
},
|
|
1204
|
+
tsl: It({
|
|
1205
|
+
texture: s,
|
|
1206
|
+
size: i,
|
|
1207
|
+
minEv: a,
|
|
1208
|
+
maxEv: o
|
|
1209
|
+
}),
|
|
1210
|
+
dispose: () => s.dispose()
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
function X(e) {
|
|
1214
|
+
return ee(Lt(e));
|
|
872
1215
|
}
|
|
873
|
-
function
|
|
874
|
-
let o =
|
|
1216
|
+
function Gt({ display: e = null, look: n = null, context: r = null, source: i = null, size: a = 65 } = {}) {
|
|
1217
|
+
let o = F();
|
|
875
1218
|
if (!o) throw Error("load an OCIO config first");
|
|
876
1219
|
let s = e ?? o.defaultDisplay, c = o.viewsByDisplay[s] ?? [], l = [], u = [];
|
|
877
1220
|
for (let e of c) {
|
|
@@ -883,7 +1226,7 @@ function ut({ display: e = null, look: n = null, context: r = null, source: i =
|
|
|
883
1226
|
continue;
|
|
884
1227
|
}
|
|
885
1228
|
try {
|
|
886
|
-
l.push(
|
|
1229
|
+
l.push(X({
|
|
887
1230
|
display: s,
|
|
888
1231
|
view: e.name,
|
|
889
1232
|
look: n,
|
|
@@ -895,7 +1238,7 @@ function ut({ display: e = null, look: n = null, context: r = null, source: i =
|
|
|
895
1238
|
u.push({
|
|
896
1239
|
view: e.name,
|
|
897
1240
|
reason: n.message
|
|
898
|
-
}),
|
|
1241
|
+
}), wt?.warn(t.VIEW_TRANSFORM_BAKE_FAILED, `could not bake "${e.name}" (${s}): ${n.message}`, {
|
|
899
1242
|
display: s,
|
|
900
1243
|
view: e.name
|
|
901
1244
|
});
|
|
@@ -906,38 +1249,38 @@ function ut({ display: e = null, look: n = null, context: r = null, source: i =
|
|
|
906
1249
|
skipped: u
|
|
907
1250
|
};
|
|
908
1251
|
}
|
|
909
|
-
function
|
|
910
|
-
let t =
|
|
911
|
-
t && (t.texture.dispose(),
|
|
1252
|
+
function Kt(e) {
|
|
1253
|
+
let t = q.get(e);
|
|
1254
|
+
t && (t.texture.dispose(), q.delete(e));
|
|
912
1255
|
}
|
|
913
|
-
function
|
|
1256
|
+
function qt(e = null) {
|
|
914
1257
|
for (let t of d.values()) t.source === "ocio" && !e?.has(t.id) && t.table?.texture?.dispose?.();
|
|
915
|
-
for (let [t, n] of
|
|
1258
|
+
for (let [t, n] of q) e?.has(t) || (n.texture.dispose(), q.delete(t));
|
|
916
1259
|
}
|
|
917
1260
|
//#endregion
|
|
918
1261
|
//#region src/Color/BakedViews.js
|
|
919
|
-
var
|
|
1262
|
+
var Jt = [
|
|
920
1263
|
82,
|
|
921
1264
|
90,
|
|
922
1265
|
86,
|
|
923
1266
|
84
|
|
924
|
-
],
|
|
925
|
-
async function
|
|
1267
|
+
], Yt = "rayzee-baked-view", Xt = 15360;
|
|
1268
|
+
async function Zt(e, t) {
|
|
926
1269
|
return new Uint8Array(await new Response(new Blob([e]).stream().pipeThrough(t)).arrayBuffer());
|
|
927
1270
|
}
|
|
928
|
-
async function
|
|
1271
|
+
async function Qt(e, t = {}) {
|
|
929
1272
|
let n = e?.table?.data;
|
|
930
1273
|
if (e?.source !== "ocio" || !(n instanceof Uint16Array)) throw Error("only a baked OCIO view can be saved");
|
|
931
1274
|
let { size: r, minEv: i, maxEv: a } = e.ocio, o = r * r * r;
|
|
932
1275
|
if (n.length !== o * 4) throw Error(`table holds ${n.length} values, expected ${o * 4}`);
|
|
933
1276
|
let s = new Uint8Array(o * 6);
|
|
934
1277
|
for (let e = 0; e < 3; e++) for (let t = 0; t < o; t++) {
|
|
935
|
-
if (e === 0 && n[t * 4 + 3] !==
|
|
1278
|
+
if (e === 0 && n[t * 4 + 3] !== Xt) throw Error("table alpha is not 1");
|
|
936
1279
|
let i = n[t * 4 + e] - (t % r ? n[(t - 1) * 4 + e] : 0) & 65535;
|
|
937
1280
|
s[e * o + t] = i >> 8, s[3 * o + e * o + t] = i & 255;
|
|
938
1281
|
}
|
|
939
|
-
let { display: c, view: l, look: u, context: d, source: f, configId: p } = e.ocio,
|
|
940
|
-
format:
|
|
1282
|
+
let { display: c, view: l, look: u, context: d, source: f, configId: p, canvas: m, emulated: h, for: g } = e.ocio, _ = new TextEncoder().encode(JSON.stringify({
|
|
1283
|
+
format: Yt,
|
|
941
1284
|
version: 1,
|
|
942
1285
|
name: e.name,
|
|
943
1286
|
configId: p,
|
|
@@ -950,15 +1293,20 @@ async function _t(e, t = {}) {
|
|
|
950
1293
|
minEv: i,
|
|
951
1294
|
maxEv: a,
|
|
952
1295
|
error: e.error ?? null,
|
|
1296
|
+
...h || g || m && m !== "srgb" ? {
|
|
1297
|
+
canvas: m,
|
|
1298
|
+
emulated: !!h
|
|
1299
|
+
} : {},
|
|
1300
|
+
...g ? { for: g } : {},
|
|
953
1301
|
...t
|
|
954
|
-
})),
|
|
955
|
-
return
|
|
1302
|
+
})), v = new Uint8Array(8 + _.length + s.length);
|
|
1303
|
+
return v.set(Jt, 0), new DataView(v.buffer).setUint32(4, _.length, !0), v.set(_, 8), v.set(s, 8 + _.length), await Zt(v, new CompressionStream("gzip"));
|
|
956
1304
|
}
|
|
957
|
-
async function
|
|
958
|
-
let t = await
|
|
959
|
-
if (t.length < 8 ||
|
|
1305
|
+
async function $t(e) {
|
|
1306
|
+
let t = await Zt(e, new DecompressionStream("gzip"));
|
|
1307
|
+
if (t.length < 8 || Jt.some((e, n) => t[n] !== e)) throw Error("not a baked view file");
|
|
960
1308
|
let n = new DataView(t.buffer, t.byteOffset).getUint32(4, !0), r = JSON.parse(new TextDecoder().decode(t.subarray(8, 8 + n)));
|
|
961
|
-
if (r.format !==
|
|
1309
|
+
if (r.format !== Yt || r.version !== 1) throw Error(`unsupported baked view ${r.format} v${r.version}`);
|
|
962
1310
|
let { size: i, minEv: a, maxEv: o } = r;
|
|
963
1311
|
if (!Number.isInteger(i) || i < 2 || i > 129 || !(a < o)) throw Error("baked view has a bad table shape");
|
|
964
1312
|
let s = i * i * i, c = t.subarray(8 + n);
|
|
@@ -968,13 +1316,13 @@ async function vt(e) {
|
|
|
968
1316
|
let t = 0;
|
|
969
1317
|
for (let n = 0; n < s; n++) n % i === 0 && (t = 0), t = t + (c[e * s + n] << 8 | c[3 * s + e * s + n]) & 65535, l[n * 4 + e] = t;
|
|
970
1318
|
}
|
|
971
|
-
for (let e = 0; e < s; e++) l[e * 4 + 3] =
|
|
1319
|
+
for (let e = 0; e < s; e++) l[e * 4 + 3] = Xt;
|
|
972
1320
|
return {
|
|
973
1321
|
...r,
|
|
974
1322
|
data: l
|
|
975
1323
|
};
|
|
976
1324
|
}
|
|
977
|
-
async function
|
|
1325
|
+
async function en({ builtin: e, text: t, files: n = [], configPath: r = "config.ocio" } = {}) {
|
|
978
1326
|
if (e) return `builtin:${e}`;
|
|
979
1327
|
let i = globalThis.crypto?.subtle;
|
|
980
1328
|
if (!i) return null;
|
|
@@ -983,35 +1331,35 @@ async function yt({ builtin: e, text: t, files: n = [], configPath: r = "config.
|
|
|
983
1331
|
}
|
|
984
1332
|
//#endregion
|
|
985
1333
|
//#region src/Color/InputColorSpaces.js
|
|
986
|
-
var
|
|
987
|
-
function
|
|
988
|
-
return
|
|
1334
|
+
var Z = [], Q = 0;
|
|
1335
|
+
function tn() {
|
|
1336
|
+
return Q;
|
|
989
1337
|
}
|
|
990
|
-
function
|
|
991
|
-
|
|
1338
|
+
function nn() {
|
|
1339
|
+
Q++;
|
|
992
1340
|
}
|
|
993
|
-
function
|
|
994
|
-
|
|
1341
|
+
function rn(e, t) {
|
|
1342
|
+
Z.unshift({
|
|
995
1343
|
match: e,
|
|
996
1344
|
colorSpace: t
|
|
997
|
-
}),
|
|
1345
|
+
}), Q++;
|
|
998
1346
|
}
|
|
999
|
-
function
|
|
1000
|
-
|
|
1347
|
+
function an() {
|
|
1348
|
+
Z.length !== 0 && (Z.length = 0, Q++);
|
|
1001
1349
|
}
|
|
1002
|
-
function
|
|
1003
|
-
return
|
|
1350
|
+
function on() {
|
|
1351
|
+
return Z.map((e) => ({
|
|
1004
1352
|
match: String(e.match),
|
|
1005
1353
|
colorSpace: e.colorSpace
|
|
1006
1354
|
}));
|
|
1007
1355
|
}
|
|
1008
|
-
function
|
|
1356
|
+
function sn(e) {
|
|
1009
1357
|
if (!e) return null;
|
|
1010
|
-
for (let t of
|
|
1358
|
+
for (let t of Z) if (t.match instanceof RegExp ? t.match.test(e) : e.includes(t.match)) return t.colorSpace;
|
|
1011
1359
|
return null;
|
|
1012
1360
|
}
|
|
1013
|
-
function
|
|
1014
|
-
return
|
|
1361
|
+
function cn() {
|
|
1362
|
+
return F()?.fileRules.map((e) => ({
|
|
1015
1363
|
index: e.index,
|
|
1016
1364
|
name: e.name,
|
|
1017
1365
|
colorSpace: e.colorSpace,
|
|
@@ -1020,24 +1368,24 @@ function Et() {
|
|
|
1020
1368
|
regex: e.regex
|
|
1021
1369
|
})) ?? [];
|
|
1022
1370
|
}
|
|
1023
|
-
function
|
|
1024
|
-
let t =
|
|
1371
|
+
function ln(e) {
|
|
1372
|
+
let t = F();
|
|
1025
1373
|
if (!t) return null;
|
|
1026
1374
|
let n = (e) => t.roles.find((t) => t.name === e)?.colorSpace ?? null;
|
|
1027
|
-
return e === me ? n("data") : e ===
|
|
1375
|
+
return e === me ? n("data") : e === _e ? n("texture_paint") ?? n("color_picking") ?? t.colorSpaces.find((e) => /^srgb\b/i.test(e.name) && !/display/i.test(e.name))?.name ?? null : e === fe ? t.colorSpaces.find((e) => /^lin(ear)?[\s_-]*(rec\.?\s*)?709/i.test(e.name))?.name ?? t.colorSpaces.find((e) => /^linear.*srgb/i.test(e.name))?.name ?? n("scene_linear") : null;
|
|
1028
1376
|
}
|
|
1029
|
-
function
|
|
1030
|
-
if (!
|
|
1031
|
-
let n =
|
|
1377
|
+
function $(e, { threeColorSpace: t = null } = {}) {
|
|
1378
|
+
if (!F()) return null;
|
|
1379
|
+
let n = sn(e);
|
|
1032
1380
|
if (n) return {
|
|
1033
1381
|
colorSpace: n,
|
|
1034
1382
|
via: "override",
|
|
1035
1383
|
rule: null
|
|
1036
1384
|
};
|
|
1037
|
-
let r =
|
|
1385
|
+
let r = P();
|
|
1038
1386
|
if (r && e) {
|
|
1039
1387
|
let t = r.matchFileRule(e);
|
|
1040
|
-
if (t && !t.isDefaultRule &&
|
|
1388
|
+
if (t && !t.isDefaultRule && K(t.colorSpace)) return {
|
|
1041
1389
|
colorSpace: t.colorSpace,
|
|
1042
1390
|
via: "rule",
|
|
1043
1391
|
rule: {
|
|
@@ -1046,16 +1394,16 @@ function Ot(e, { threeColorSpace: t = null } = {}) {
|
|
|
1046
1394
|
}
|
|
1047
1395
|
};
|
|
1048
1396
|
}
|
|
1049
|
-
let i =
|
|
1397
|
+
let i = ln(t);
|
|
1050
1398
|
if (i) return {
|
|
1051
1399
|
colorSpace: i,
|
|
1052
1400
|
via: "three",
|
|
1053
1401
|
rule: null
|
|
1054
1402
|
};
|
|
1055
|
-
let a =
|
|
1403
|
+
let a = P();
|
|
1056
1404
|
if (a && e) {
|
|
1057
1405
|
let t = a.matchFileRule(e);
|
|
1058
|
-
if (t &&
|
|
1406
|
+
if (t && K(t.colorSpace)) return {
|
|
1059
1407
|
colorSpace: t.colorSpace,
|
|
1060
1408
|
via: "rule",
|
|
1061
1409
|
rule: {
|
|
@@ -1067,33 +1415,48 @@ function Ot(e, { threeColorSpace: t = null } = {}) {
|
|
|
1067
1415
|
}
|
|
1068
1416
|
return null;
|
|
1069
1417
|
}
|
|
1070
|
-
function
|
|
1418
|
+
function un(e) {
|
|
1071
1419
|
if (!e) return !1;
|
|
1072
1420
|
if (e.colorSpace === me) return !0;
|
|
1073
1421
|
let t = e.userData?.ocioColorSpace;
|
|
1074
|
-
return !!(t &&
|
|
1422
|
+
return !!(t && ct(t));
|
|
1075
1423
|
}
|
|
1076
|
-
function
|
|
1424
|
+
function dn(e, t) {
|
|
1077
1425
|
return t ?? e.userData?.sourcePath ?? (e.name || null) ?? e.image?.src ?? null;
|
|
1078
1426
|
}
|
|
1079
|
-
function
|
|
1080
|
-
if (!
|
|
1427
|
+
function fn(e, t = null) {
|
|
1428
|
+
if (!F() || !e) return null;
|
|
1081
1429
|
let n = e.userData?.ocioColorSpace;
|
|
1082
|
-
return n ?
|
|
1430
|
+
return n ? K(n) ? {
|
|
1083
1431
|
colorSpace: n,
|
|
1084
1432
|
via: "tag",
|
|
1085
1433
|
rule: null
|
|
1086
|
-
} : null :
|
|
1434
|
+
} : null : un(e) ? null : $(dn(e, t), { threeColorSpace: e.colorSpace });
|
|
1087
1435
|
}
|
|
1088
|
-
function
|
|
1089
|
-
return
|
|
1436
|
+
function pn(e, t = null) {
|
|
1437
|
+
return fn(e, t)?.colorSpace ?? null;
|
|
1090
1438
|
}
|
|
1091
1439
|
//#endregion
|
|
1092
1440
|
//#region src/Color/ColorManagement.js
|
|
1093
|
-
function
|
|
1441
|
+
function mn(e) {
|
|
1094
1442
|
return w(e) ?? "srgb";
|
|
1095
1443
|
}
|
|
1096
|
-
|
|
1444
|
+
function hn(e) {
|
|
1445
|
+
return e?.source === "ocio" ? e.ocio.canvas ?? mn(e.ocio.display) : "srgb";
|
|
1446
|
+
}
|
|
1447
|
+
var gn = 4;
|
|
1448
|
+
function _n(e, t) {
|
|
1449
|
+
return JSON.stringify([
|
|
1450
|
+
e.configId,
|
|
1451
|
+
e.display,
|
|
1452
|
+
e.view,
|
|
1453
|
+
e.look ?? null,
|
|
1454
|
+
e.source,
|
|
1455
|
+
e.context ?? null,
|
|
1456
|
+
t
|
|
1457
|
+
]);
|
|
1458
|
+
}
|
|
1459
|
+
var vn = [
|
|
1097
1460
|
"Linear Rec.709 (sRGB)",
|
|
1098
1461
|
"lin_rec709_srgb",
|
|
1099
1462
|
"lin_rec709",
|
|
@@ -1103,19 +1466,19 @@ var Pt = [
|
|
|
1103
1466
|
"Utility - Linear - Rec.709",
|
|
1104
1467
|
"Linear BT.709",
|
|
1105
1468
|
"linrec709"
|
|
1106
|
-
],
|
|
1107
|
-
function
|
|
1469
|
+
], yn = /^(lin(ear)?[\s_-]*(rec\.?\s*|bt\.?\s*)?709|linear[\s_-]*\(?srgb\)?$|utility - linear - (srgb|rec\.?709))/i;
|
|
1470
|
+
function bn(e) {
|
|
1108
1471
|
if (!e) return null;
|
|
1109
1472
|
let t = e.colorSpaces.filter((e) => !e.isData), n = (e) => [e.name, ...e.aliases ?? []];
|
|
1110
|
-
for (let e of
|
|
1473
|
+
for (let e of vn) {
|
|
1111
1474
|
let r = t.find((t) => n(t).some((t) => t.toLowerCase() === e.toLowerCase()));
|
|
1112
1475
|
if (r) return r.name;
|
|
1113
1476
|
}
|
|
1114
|
-
return t.find((e) => n(e).some((e) =>
|
|
1477
|
+
return t.find((e) => n(e).some((e) => yn.test(e)))?.name ?? null;
|
|
1115
1478
|
}
|
|
1116
|
-
var
|
|
1479
|
+
var xn = class {
|
|
1117
1480
|
constructor({ issues: e = null, renderer: t = null } = {}) {
|
|
1118
|
-
this._issues = e, this._renderer = t, this._listeners = /* @__PURE__ */ new Map(), this._workingSpace = null, this._activeView = null, this._exportSpace = null, this._context = null, this._lastUsed = /* @__PURE__ */ new Map(), this._useClock = 0, this._lastBuiltin =
|
|
1481
|
+
this._issues = e, this._renderer = t, this._listeners = /* @__PURE__ */ new Map(), this._workingSpace = null, this._activeView = null, this._exportSpace = null, this._context = null, this._lastUsed = /* @__PURE__ */ new Map(), this._useClock = 0, this._lastBuiltin = y, this._fingerprint = null, this._hdrOutput = !1, this._canvasView = null, this._canvasReason = null, this._bakedCanvasViews = /* @__PURE__ */ new Map(), this._recentCanvasViews = /* @__PURE__ */ new Map(), Tt(e), this._offRegistry = te(() => {
|
|
1119
1482
|
this._renderer && v(this._renderer), this._emit("transforms");
|
|
1120
1483
|
}), o(this);
|
|
1121
1484
|
}
|
|
@@ -1130,23 +1493,23 @@ var Lt = class {
|
|
|
1130
1493
|
});
|
|
1131
1494
|
}
|
|
1132
1495
|
static async listBuiltinConfigs() {
|
|
1133
|
-
return await
|
|
1496
|
+
return await Ie();
|
|
1134
1497
|
}
|
|
1135
1498
|
async loadConfig({ adoptWorkingSpace: e = !1, registerViews: n = !0, display: r = null, lutSize: i, ...a } = {}) {
|
|
1136
|
-
await
|
|
1137
|
-
let o =
|
|
1499
|
+
await Fe();
|
|
1500
|
+
let o = en(a).catch(() => null), s = await this._bakedViewsFrom(a.builtin ?? a.id ?? null, o), c;
|
|
1138
1501
|
try {
|
|
1139
|
-
c = await
|
|
1502
|
+
c = await Le(a);
|
|
1140
1503
|
} catch (e) {
|
|
1141
1504
|
throw this._issues?.warn(t.COLOR_CONFIG_LOAD_FAILED, `colour config failed to load; the previous one stays in effect: ${e.message}`, {
|
|
1142
1505
|
builtin: a.builtin ?? null,
|
|
1143
1506
|
configPath: a.configPath ?? null
|
|
1144
1507
|
}), e;
|
|
1145
1508
|
}
|
|
1146
|
-
this._releaseViews(new Set(s.filter((e) => e.ocio.baked.ocioVersion === c.ocioVersion).map((e) => e.id))), this._fingerprint = o,
|
|
1509
|
+
this._releaseViews(new Set(s.filter((e) => e.ocio.baked.ocioVersion === c.ocioVersion).map((e) => e.id))), this._fingerprint = o, nn(), Ye(), this._context = null;
|
|
1147
1510
|
let l = this._workingSpace;
|
|
1148
|
-
if (e ? this._workingSpace = c.sceneLinear : l && !
|
|
1149
|
-
let e = r ?? c.defaultDisplay, { added: t, skipped: n } =
|
|
1511
|
+
if (e ? this._workingSpace = c.sceneLinear : l && !K(l) && (this._workingSpace = null), bn(F()) || this._issues?.warn(t.COLOR_CONFIG_LOAD_FAILED, `"${c.id}" names no linear Rec.709 space, so until a working space is adopted its views treat the render as ${c.sceneLinear} — colours will be off by that primaries change`, { sceneLinear: c.sceneLinear }), this._publishWorkingMatrix(), this._emit("config", c), n) {
|
|
1512
|
+
let e = r ?? c.defaultDisplay, { added: t, skipped: n } = Gt({
|
|
1150
1513
|
display: e,
|
|
1151
1514
|
context: this._context,
|
|
1152
1515
|
source: this.workingSpace,
|
|
@@ -1161,15 +1524,15 @@ var Lt = class {
|
|
|
1161
1524
|
skipped: n
|
|
1162
1525
|
});
|
|
1163
1526
|
}
|
|
1164
|
-
return (this._workingSpace ?? null) !== (l ?? null) && this._emit("workingSpace", this.workingSpace), c;
|
|
1527
|
+
return (this._workingSpace ?? null) !== (l ?? null) && this._emit("workingSpace", this.workingSpace), this._updateCanvasView(), c;
|
|
1165
1528
|
}
|
|
1166
1529
|
unloadConfig() {
|
|
1167
|
-
this.workingSpaceAdopted && this._issues?.warn(t.COLOR_CONFIG_LOAD_FAILED, `unloaded while rendering in ${this._workingSpace}; the environment stays converted into it — use app.unloadColorConfig(), which reverts the scene first`, { workingSpace: this._workingSpace }), this._releaseViews(),
|
|
1530
|
+
this.workingSpaceAdopted && this._issues?.warn(t.COLOR_CONFIG_LOAD_FAILED, `unloaded while rendering in ${this._workingSpace}; the environment stays converted into it — use app.unloadColorConfig(), which reverts the scene first`, { workingSpace: this._workingSpace }), this._releaseViews(), Re(), Ye(), an(), nn(), this._fingerprint = null, this._workingSpace = null, this._activeView = null, this._exportSpace = null, this._context = null, n(null), this._applyRendererOutputColorSpace(), this._updateCanvasView(), this._emit("config", null), this._emit("workingSpace", this.workingSpace);
|
|
1168
1531
|
}
|
|
1169
1532
|
_releaseViews(e = null) {
|
|
1170
|
-
|
|
1533
|
+
qt(e), g(e);
|
|
1171
1534
|
for (let t of this._lastUsed.keys()) e?.has(t) || this._lastUsed.delete(t);
|
|
1172
|
-
this._renderer &&
|
|
1535
|
+
this._renderer && b(this._renderer.toneMapping) === null && (this._renderer.toneMapping = b(this._lastBuiltin) ? this._lastBuiltin : y, this._activeView = null, this._applyRendererOutputColorSpace(), this._updateCanvasView());
|
|
1173
1536
|
}
|
|
1174
1537
|
async _bakedViewsFrom(e, t) {
|
|
1175
1538
|
let n = [...d.values()].filter((t) => t.ocio?.baked && e !== null && t.ocio.configId === e);
|
|
@@ -1178,44 +1541,59 @@ var Lt = class {
|
|
|
1178
1541
|
return r ? n.filter((e) => e.ocio.baked.fingerprint === r) : [];
|
|
1179
1542
|
}
|
|
1180
1543
|
async loadBakedView(e, { expect: t = null } = {}) {
|
|
1181
|
-
let n = await
|
|
1544
|
+
let n = await $t(e);
|
|
1182
1545
|
for (let [e, r] of Object.entries(t ?? {})) if ((n[e] ?? null) !== (r ?? null)) throw Error(`baked view has ${e} "${n[e]}", expected "${r}"`);
|
|
1183
|
-
let r =
|
|
1546
|
+
let r = I();
|
|
1184
1547
|
if (r && (r.id !== n.configId || await this._fingerprint !== n.fingerprint)) throw Error(`baked view is from "${n.configId}", not the loaded "${r.id}"`);
|
|
1548
|
+
if (n.for) {
|
|
1549
|
+
let e = _n({
|
|
1550
|
+
...n,
|
|
1551
|
+
...n.for
|
|
1552
|
+
}, n.canvas ?? "srgb"), t = this._bakedCanvasViews.get(e);
|
|
1553
|
+
return this._bakedCanvasViews.set(e, Ut(n)), t && t !== this._canvasView?.table && t.dispose(), this._updateCanvasView(), [...d.values()].find((e) => e.source === "ocio" && e.ocio.display === n.for.display && e.ocio.view === n.for.view && (e.ocio.look ?? null) === (n.look ?? null)) ?? null;
|
|
1554
|
+
}
|
|
1185
1555
|
let i = [...d.values()].find((e) => e.source === "ocio" && e.ocio.display === n.display && e.ocio.view === n.view && (e.ocio.look ?? null) === (n.look ?? null));
|
|
1186
|
-
return i || this._makeRoomForTable(),
|
|
1187
|
-
}
|
|
1188
|
-
async saveBakedView(e) {
|
|
1189
|
-
let
|
|
1190
|
-
if (
|
|
1191
|
-
let
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1556
|
+
return i || this._makeRoomForTable(), ee(Rt(n, i?.id ?? null));
|
|
1557
|
+
}
|
|
1558
|
+
async saveBakedView(e, { hdr: t = !1 } = {}) {
|
|
1559
|
+
let n = b(e);
|
|
1560
|
+
if (n?.source !== "ocio") throw Error(`no OCIO view with id ${e}`);
|
|
1561
|
+
let r = I(), i = {
|
|
1562
|
+
configId: r?.id ?? n.ocio.configId,
|
|
1563
|
+
fingerprint: (r ? await this._fingerprint : null) ?? n.ocio.baked?.fingerprint ?? null,
|
|
1564
|
+
ocioVersion: r?.ocioVersion ?? n.ocio.baked?.ocioVersion ?? null
|
|
1565
|
+
};
|
|
1566
|
+
if (!t) return await Qt(n, i);
|
|
1567
|
+
let a = hn(n), o = _n(n.ocio, a), s = this._canvasView?.key === o ? this._canvasView.table : this._bakedCanvasViews.get(o) ?? this._recentCanvasViews.get(o), c = s ? null : r && je(r, n.ocio.display, n.ocio.view);
|
|
1568
|
+
if (!s && !c) throw Error(`"${n.name}" has no HDR version${r ? " in this config" : " without its config loaded"}`);
|
|
1569
|
+
let l = s ?? this._buildCanvasView(n, c, a);
|
|
1570
|
+
try {
|
|
1571
|
+
return await Qt(l, i);
|
|
1572
|
+
} finally {
|
|
1573
|
+
l !== s && l.dispose();
|
|
1574
|
+
}
|
|
1197
1575
|
}
|
|
1198
1576
|
get hasConfig() {
|
|
1199
|
-
return
|
|
1577
|
+
return N();
|
|
1200
1578
|
}
|
|
1201
1579
|
describe() {
|
|
1202
|
-
return
|
|
1580
|
+
return I();
|
|
1203
1581
|
}
|
|
1204
1582
|
get workingSpace() {
|
|
1205
|
-
return this._workingSpace ? this._workingSpace :
|
|
1583
|
+
return this._workingSpace ? this._workingSpace : N() ? this.nativeLinearSpace ?? I()?.sceneLinear ?? "Linear Rec.709 (sRGB)" : c;
|
|
1206
1584
|
}
|
|
1207
1585
|
get workingSpaceAdopted() {
|
|
1208
1586
|
return this._workingSpace !== null;
|
|
1209
1587
|
}
|
|
1210
1588
|
setWorkingSpace(e) {
|
|
1211
1589
|
if (e !== null) {
|
|
1212
|
-
if (!
|
|
1213
|
-
if (!
|
|
1590
|
+
if (!N()) throw Error("load an OCIO config before choosing a working space");
|
|
1591
|
+
if (!K(e)) throw Error(`config has no colour space "${e}"`);
|
|
1214
1592
|
}
|
|
1215
|
-
(this._workingSpace ?? null) !== (e ?? null) && (this._workingSpace = e,
|
|
1593
|
+
(this._workingSpace ?? null) !== (e ?? null) && (this._workingSpace = e, Ge(), this._publishWorkingMatrix(), this._rebakeViews(), this._emit("workingSpace", this.workingSpace));
|
|
1216
1594
|
}
|
|
1217
1595
|
matrixToWorking(e) {
|
|
1218
|
-
return
|
|
1596
|
+
return N() ? st(e, this.workingSpace, { context: this._context }) : null;
|
|
1219
1597
|
}
|
|
1220
1598
|
listViews() {
|
|
1221
1599
|
return p();
|
|
@@ -1224,19 +1602,19 @@ var Lt = class {
|
|
|
1224
1602
|
return this._activeView;
|
|
1225
1603
|
}
|
|
1226
1604
|
setActiveView(e) {
|
|
1227
|
-
let t =
|
|
1605
|
+
let t = b(e);
|
|
1228
1606
|
if (!t) throw Error(`no view transform with id ${e}`);
|
|
1229
1607
|
return this._isStale(t) && (t = this._rebakeView(t) ?? t), this._activeView = t.source === "ocio" ? {
|
|
1230
1608
|
...t.ocio,
|
|
1231
1609
|
id: t.id,
|
|
1232
1610
|
name: t.name
|
|
1233
|
-
} : null, this._lastUsed.set(e, ++this._useClock), t.source === "builtin" && (this._lastBuiltin = e), this._renderer && (this._renderer.toneMapping = e), this._applyRendererOutputColorSpace(), this._emit("view", t), t;
|
|
1611
|
+
} : null, this._lastUsed.set(e, ++this._useClock), t.source === "builtin" && (this._lastBuiltin = e), this._renderer && (this._renderer.toneMapping = e), this._applyRendererOutputColorSpace(), this._updateCanvasView(), this._emit("view", t), t;
|
|
1234
1612
|
}
|
|
1235
1613
|
setView({ display: e, view: t, look: n = null, size: r } = {}) {
|
|
1236
|
-
if (!
|
|
1614
|
+
if (!N()) throw Error("load an OCIO config first");
|
|
1237
1615
|
let i = [...d.values()].find((i) => i.source === "ocio" && i.ocio.display === e && i.ocio.view === t && (i.ocio.look ?? null) === (n ?? null) && (!r || i.ocio.size === r));
|
|
1238
1616
|
i || this._makeRoomForTable();
|
|
1239
|
-
let a = i ??
|
|
1617
|
+
let a = i ?? X({
|
|
1240
1618
|
display: e,
|
|
1241
1619
|
view: t,
|
|
1242
1620
|
look: n,
|
|
@@ -1244,12 +1622,12 @@ var Lt = class {
|
|
|
1244
1622
|
source: this.workingSpace,
|
|
1245
1623
|
...r ? { size: r } : {}
|
|
1246
1624
|
});
|
|
1247
|
-
return this.setActiveView(a.id),
|
|
1625
|
+
return this.setActiveView(a.id), b(a.id);
|
|
1248
1626
|
}
|
|
1249
1627
|
_makeRoomForTable() {
|
|
1250
1628
|
if (f() < 12) return;
|
|
1251
1629
|
let e = this._renderer?.toneMapping ?? this._activeView?.id ?? null, t = [...d.values()].filter((t) => t.source === "ocio" && t.id !== e).sort((e, t) => (this._lastUsed.get(e.id) ?? 0) - (this._lastUsed.get(t.id) ?? 0))[0];
|
|
1252
|
-
t && (
|
|
1630
|
+
t && (Kt(t.id), h(t.id), this._lastUsed.delete(t.id));
|
|
1253
1631
|
}
|
|
1254
1632
|
setLook(e) {
|
|
1255
1633
|
if (!this._activeView) throw Error("no OCIO view is active");
|
|
@@ -1260,17 +1638,17 @@ var Lt = class {
|
|
|
1260
1638
|
}
|
|
1261
1639
|
setContext(e) {
|
|
1262
1640
|
let t = e && Object.keys(e).length ? { ...e } : null;
|
|
1263
|
-
JSON.stringify(t) !== JSON.stringify(this._context) && (this._context = t,
|
|
1641
|
+
JSON.stringify(t) !== JSON.stringify(this._context) && (this._context = t, N() && (this._context && P()?.invalidateContext(this._context), Ge(), this._rebakeViews()), this._emit("context", this._context));
|
|
1264
1642
|
}
|
|
1265
1643
|
get context() {
|
|
1266
1644
|
return this._context;
|
|
1267
1645
|
}
|
|
1268
1646
|
_isStale(e) {
|
|
1269
|
-
return e.source !== "ocio" || !
|
|
1647
|
+
return e.source !== "ocio" || !N() ? !1 : e.ocio.source !== this.workingSpace || JSON.stringify(e.ocio.context ?? null) !== JSON.stringify(this._context ?? null);
|
|
1270
1648
|
}
|
|
1271
1649
|
_rebakeView(e) {
|
|
1272
1650
|
try {
|
|
1273
|
-
let t =
|
|
1651
|
+
let t = X({
|
|
1274
1652
|
id: e.id,
|
|
1275
1653
|
display: e.ocio.display,
|
|
1276
1654
|
view: e.ocio.view,
|
|
@@ -1287,64 +1665,158 @@ var Lt = class {
|
|
|
1287
1665
|
}
|
|
1288
1666
|
}
|
|
1289
1667
|
_rebakeViews() {
|
|
1290
|
-
let e = this._renderer?.toneMapping ?? this._activeView?.id ?? null, t = e === null ? null :
|
|
1668
|
+
let e = this._renderer?.toneMapping ?? this._activeView?.id ?? null, t = e === null ? null : b(e);
|
|
1291
1669
|
if (!t || !this._isStale(t)) return;
|
|
1292
1670
|
let n = this._rebakeView(t);
|
|
1293
1671
|
n && (this._activeView = {
|
|
1294
1672
|
...n.ocio,
|
|
1295
1673
|
id: n.id,
|
|
1296
1674
|
name: n.name
|
|
1297
|
-
});
|
|
1675
|
+
}), this._updateCanvasView();
|
|
1298
1676
|
}
|
|
1299
1677
|
attachRenderer(e) {
|
|
1300
|
-
this._renderer = e,
|
|
1678
|
+
this._renderer = e, b(e.toneMapping)?.source === "builtin" && (this._lastBuiltin = e.toneMapping);
|
|
1301
1679
|
let t = v(e);
|
|
1302
|
-
return this._applyRendererOutputColorSpace(), t;
|
|
1680
|
+
return this._applyRendererOutputColorSpace(), this._updateCanvasView(), t;
|
|
1303
1681
|
}
|
|
1304
1682
|
_applyRendererOutputColorSpace() {
|
|
1305
1683
|
if (!this._renderer) return;
|
|
1306
|
-
let e =
|
|
1307
|
-
this._renderer.outputColorSpace = e?.outputEncoded ? fe :
|
|
1684
|
+
let e = b(this._renderer.toneMapping);
|
|
1685
|
+
this._renderer.outputColorSpace = e?.outputEncoded ? fe : _e, this._applyCanvasColorSpace(hn(e));
|
|
1308
1686
|
}
|
|
1309
1687
|
_applyCanvasColorSpace(e) {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1688
|
+
this._canvasColorSpace = e;
|
|
1689
|
+
let n = (this._renderer?.domElement)?.getContext?.("webgpu");
|
|
1690
|
+
if (!n?.configure) return;
|
|
1691
|
+
if (!n.__rayzeeConfigure) {
|
|
1692
|
+
let e = n.configure.bind(n);
|
|
1693
|
+
n.__rayzeeConfigure = e, n.configure = (t) => e({
|
|
1694
|
+
...t,
|
|
1695
|
+
colorSpace: n.__rayzeeColorSpace ?? t.colorSpace
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1698
|
+
n.__rayzeeColorSpace = e;
|
|
1699
|
+
let r = n.getConfiguration?.();
|
|
1700
|
+
if (!(!r || r.colorSpace === e)) try {
|
|
1701
|
+
n.configure({
|
|
1702
|
+
...r,
|
|
1703
|
+
colorSpace: e
|
|
1704
|
+
});
|
|
1705
|
+
} catch (n) {
|
|
1706
|
+
this._issues?.warn(t.VIEW_TRANSFORM_DISPLAY_MISMATCH, `the canvas could not be set to ${e}: ${n.message}`, { colorSpace: e });
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
setHdrOutput(e) {
|
|
1710
|
+
!!e !== this._hdrOutput && (this._hdrOutput = !!e, this._updateCanvasView());
|
|
1711
|
+
}
|
|
1712
|
+
get hdrOutput() {
|
|
1713
|
+
return this._hdrOutput;
|
|
1714
|
+
}
|
|
1715
|
+
get canvasColorSpace() {
|
|
1716
|
+
return this._canvasColorSpace ?? "srgb";
|
|
1717
|
+
}
|
|
1718
|
+
displayFit(e) {
|
|
1719
|
+
return N() ? Nt(e).fit : w(e);
|
|
1720
|
+
}
|
|
1721
|
+
get canvasTransform() {
|
|
1722
|
+
return this._canvasView?.table?.tsl ?? null;
|
|
1723
|
+
}
|
|
1724
|
+
_canvasOnScreen() {
|
|
1725
|
+
let e = this._renderer?.domElement;
|
|
1726
|
+
return typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas;
|
|
1727
|
+
}
|
|
1728
|
+
_canvasPlan() {
|
|
1729
|
+
let e = this._renderer ? b(this._renderer.toneMapping) : null;
|
|
1730
|
+
if (!e || !this._hdrOutput) return { reason: null };
|
|
1731
|
+
if (e.source !== "ocio") return e.id === he ? {
|
|
1732
|
+
key: "none",
|
|
1733
|
+
table: null,
|
|
1734
|
+
hdr: !0
|
|
1735
|
+
} : { reason: "no-hdr-version" };
|
|
1736
|
+
let t = I();
|
|
1737
|
+
if (T(t, e.ocio.display)) return {
|
|
1738
|
+
key: "own",
|
|
1739
|
+
table: null,
|
|
1740
|
+
hdr: !0
|
|
1741
|
+
};
|
|
1742
|
+
let n = hn(e), r = _n(e.ocio, n), i = this._bakedCanvasViews.get(r);
|
|
1743
|
+
if (i) return {
|
|
1744
|
+
key: r,
|
|
1745
|
+
table: i,
|
|
1746
|
+
hdr: !0
|
|
1747
|
+
};
|
|
1748
|
+
let a = t && je(t, e.ocio.display, e.ocio.view);
|
|
1749
|
+
return a ? {
|
|
1750
|
+
key: r,
|
|
1751
|
+
target: a,
|
|
1752
|
+
canvas: n,
|
|
1753
|
+
view: e,
|
|
1754
|
+
hdr: !0
|
|
1755
|
+
} : { reason: t ? "no-hdr-version" : "needs-config" };
|
|
1756
|
+
}
|
|
1757
|
+
_buildCanvasView(e, t, n) {
|
|
1758
|
+
let { look: r, context: i, source: a, size: o, display: s, view: c } = e.ocio;
|
|
1759
|
+
return Ht({
|
|
1760
|
+
...t,
|
|
1761
|
+
look: r,
|
|
1762
|
+
context: i,
|
|
1763
|
+
source: a,
|
|
1764
|
+
size: o,
|
|
1765
|
+
canvas: n,
|
|
1766
|
+
for: {
|
|
1767
|
+
display: s,
|
|
1768
|
+
view: c
|
|
1326
1769
|
}
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
_updateCanvasView() {
|
|
1773
|
+
let e = this._canvasPlan(), n = this._canvasView, r = e.table ?? (e.key && e.key === n?.key ? n.table : null) ?? this._recentCanvasViews.get(e.key) ?? null;
|
|
1774
|
+
if (e.target && !r) try {
|
|
1775
|
+
r = this._buildCanvasView(e.view, e.target, e.canvas);
|
|
1776
|
+
} catch (n) {
|
|
1777
|
+
this._issues?.warn(t.VIEW_TRANSFORM_BAKE_FAILED, `could not bake how the screen shows "${e.view.name}": ${n.message}`, { ...e.target }), this._setCanvasView(null, "bake-failed");
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
e.target && this._rememberCanvasView(e.key, r), this._setCanvasView(e.key ? {
|
|
1781
|
+
key: e.key,
|
|
1782
|
+
table: r,
|
|
1783
|
+
hdr: e.hdr
|
|
1784
|
+
} : null, e.reason ?? null);
|
|
1785
|
+
}
|
|
1786
|
+
_rememberCanvasView(e, t) {
|
|
1787
|
+
let n = this._recentCanvasViews;
|
|
1788
|
+
for (n.delete(e), n.set(e, t); n.size > gn;) {
|
|
1789
|
+
let [e, r] = n.entries().next().value;
|
|
1790
|
+
n.delete(e), r !== this._canvasView?.table && r !== t && r.dispose();
|
|
1327
1791
|
}
|
|
1328
1792
|
}
|
|
1793
|
+
_setCanvasView(e, t) {
|
|
1794
|
+
let n = this._canvasView, r = new Set([...this._bakedCanvasViews.values(), ...this._recentCanvasViews.values()]);
|
|
1795
|
+
n?.table && n.table !== e?.table && !r.has(n.table) && n.table.dispose();
|
|
1796
|
+
let i = !!e?.hdr && this._canvasOnScreen(), a = t ?? (e?.hdr && !i ? "no-screen" : null), o = (n?.table ?? null) !== (e?.table ?? null) || !!n?.hdr != !!e?.hdr || this._canvasReason !== a;
|
|
1797
|
+
this._canvasView = e, this._canvasReason = a;
|
|
1798
|
+
let s = this._renderer?.backend, c = i ? de : void 0;
|
|
1799
|
+
s?.parameters && s.parameters.outputType !== c && (s.parameters.outputType = c, s.updateSize?.()), o && this._emit("canvas", this.canvasTransform);
|
|
1800
|
+
}
|
|
1329
1801
|
resolveInput(e, t) {
|
|
1330
|
-
return
|
|
1802
|
+
return $(e, t);
|
|
1331
1803
|
}
|
|
1332
1804
|
textureSpace(e, t) {
|
|
1333
|
-
return
|
|
1805
|
+
return pn(e, t);
|
|
1334
1806
|
}
|
|
1335
1807
|
resolveTexture(e, t) {
|
|
1336
|
-
return
|
|
1808
|
+
return fn(e, t);
|
|
1337
1809
|
}
|
|
1338
1810
|
describeTextureSpace(e) {
|
|
1339
1811
|
let t = e?.userData ?? {}, n = t.ocioColorSpace ?? t.__rayzeeColorSpaceChoice ?? null, r = null, i = t.__rayzeeOriginalColorSpace ?? e?.colorSpace;
|
|
1340
|
-
return
|
|
1812
|
+
return N() && (r = fn({
|
|
1341
1813
|
...e,
|
|
1342
1814
|
name: e?.name,
|
|
1343
1815
|
image: e?.image,
|
|
1344
1816
|
colorSpace: i,
|
|
1345
1817
|
userData: {}
|
|
1346
1818
|
})), r ||= {
|
|
1347
|
-
colorSpace: i ===
|
|
1819
|
+
colorSpace: i === _e ? "sRGB" : "Linear",
|
|
1348
1820
|
via: "three"
|
|
1349
1821
|
}, {
|
|
1350
1822
|
choice: n,
|
|
@@ -1352,29 +1824,29 @@ var Lt = class {
|
|
|
1352
1824
|
};
|
|
1353
1825
|
}
|
|
1354
1826
|
get inputKey() {
|
|
1355
|
-
return
|
|
1827
|
+
return N() ? `${I()?.id}|${this.workingSpace}|${tn()}|${JSON.stringify(this._context)}` : "-";
|
|
1356
1828
|
}
|
|
1357
1829
|
overrideInput(e, t) {
|
|
1358
|
-
|
|
1830
|
+
rn(e, t);
|
|
1359
1831
|
}
|
|
1360
1832
|
fileRules() {
|
|
1361
|
-
return
|
|
1833
|
+
return cn();
|
|
1362
1834
|
}
|
|
1363
1835
|
toWorkingPixels(e, t) {
|
|
1364
|
-
return !
|
|
1836
|
+
return !N() || !t ? e : U(e, t, this.workingSpace, { context: this._context });
|
|
1365
1837
|
}
|
|
1366
1838
|
get nativeLinearSpace() {
|
|
1367
|
-
return
|
|
1839
|
+
return bn(F());
|
|
1368
1840
|
}
|
|
1369
1841
|
_publishWorkingMatrix() {
|
|
1370
1842
|
let e = s();
|
|
1371
|
-
e !== null && e !== this || n(
|
|
1843
|
+
e !== null && e !== this || n(N() ? this.primariesMatrixToWorking() : null, this.workingSpace);
|
|
1372
1844
|
}
|
|
1373
1845
|
primariesMatrixToWorking() {
|
|
1374
|
-
if (!
|
|
1846
|
+
if (!N() || !this.workingSpaceAdopted) return null;
|
|
1375
1847
|
let e = this.nativeLinearSpace;
|
|
1376
1848
|
if (!e || e === this.workingSpace) return null;
|
|
1377
|
-
let t =
|
|
1849
|
+
let t = st(e, this.workingSpace, { context: this._context });
|
|
1378
1850
|
return t ? [
|
|
1379
1851
|
1,
|
|
1380
1852
|
0,
|
|
@@ -1394,17 +1866,17 @@ var Lt = class {
|
|
|
1394
1866
|
return r(e, t, n);
|
|
1395
1867
|
}
|
|
1396
1868
|
convertTexturePixels(e, { space: n = null } = {}) {
|
|
1397
|
-
if (!
|
|
1869
|
+
if (!N()) return !1;
|
|
1398
1870
|
let r = e?.image?.data;
|
|
1399
1871
|
if (!r) return !1;
|
|
1400
1872
|
let i = this.nativeLinearSpace, a = e.userData?.__rayzeeColorSpace ?? n ?? i, o = this.workingSpaceAdopted ? this.workingSpace : i;
|
|
1401
1873
|
if (!a || !o || a === o) return !1;
|
|
1402
1874
|
let s = !1;
|
|
1403
|
-
if (r instanceof Float32Array)
|
|
1875
|
+
if (r instanceof Float32Array) U(r, a, o, { context: this._context }), s = !0;
|
|
1404
1876
|
else if (r instanceof Uint16Array) {
|
|
1405
|
-
let e =
|
|
1406
|
-
|
|
1407
|
-
} else if (r instanceof Uint8Array || r instanceof Uint8ClampedArray)
|
|
1877
|
+
let e = mt(r);
|
|
1878
|
+
U(e, a, o, { context: this._context }), r.set(pt(e)), s = !0;
|
|
1879
|
+
} else if (r instanceof Uint8Array || r instanceof Uint8ClampedArray) nt(r, a, o, {
|
|
1408
1880
|
context: this._context,
|
|
1409
1881
|
inputEncoding: "srgb",
|
|
1410
1882
|
outputEncoding: "srgb"
|
|
@@ -1416,47 +1888,47 @@ var Lt = class {
|
|
|
1416
1888
|
return e.userData = e.userData ?? {}, e.userData.__rayzeeColorSpace = o, e.needsUpdate = !0, s;
|
|
1417
1889
|
}
|
|
1418
1890
|
convertTextureBytes(e, { space: t = null, encoding: n = "srgb" } = {}) {
|
|
1419
|
-
if (!
|
|
1420
|
-
if (t) return t === this.workingSpace ? !1 : (
|
|
1891
|
+
if (!N()) return !1;
|
|
1892
|
+
if (t) return t === this.workingSpace ? !1 : (nt(e, t, this.workingSpace, {
|
|
1421
1893
|
context: this._context,
|
|
1422
1894
|
inputEncoding: "raw",
|
|
1423
1895
|
outputEncoding: n
|
|
1424
1896
|
}), !0);
|
|
1425
1897
|
let r = this.primariesMatrixToWorking();
|
|
1426
|
-
return r ? (
|
|
1898
|
+
return r ? (ot(e, r, n), !0) : !1;
|
|
1427
1899
|
}
|
|
1428
1900
|
toWorkingColor(e, t) {
|
|
1429
|
-
return !
|
|
1901
|
+
return !N() || !t ? [
|
|
1430
1902
|
e[0],
|
|
1431
1903
|
e[1],
|
|
1432
1904
|
e[2]
|
|
1433
|
-
] :
|
|
1905
|
+
] : Xe(e, t, this.workingSpace, { context: this._context });
|
|
1434
1906
|
}
|
|
1435
1907
|
convert(e, t, n) {
|
|
1436
|
-
return
|
|
1908
|
+
return Xe(e, t, n, { context: this._context });
|
|
1437
1909
|
}
|
|
1438
1910
|
get exportSpace() {
|
|
1439
1911
|
return this._exportSpace;
|
|
1440
1912
|
}
|
|
1441
1913
|
setExportSpace(e) {
|
|
1442
1914
|
if (e != null) {
|
|
1443
|
-
if (!
|
|
1444
|
-
if (!
|
|
1915
|
+
if (!N()) throw Error("load an OCIO config before choosing an export space");
|
|
1916
|
+
if (!K(e)) throw Error(`config has no colour space "${e}"`);
|
|
1445
1917
|
}
|
|
1446
1918
|
this._exportSpace = e ?? null, this._emit("export", this._exportSpace);
|
|
1447
1919
|
}
|
|
1448
1920
|
exportPixels(e, t = void 0) {
|
|
1449
1921
|
let n = t === void 0 ? this._exportSpace : t;
|
|
1450
|
-
return !n || !
|
|
1922
|
+
return !n || !N() ? {
|
|
1451
1923
|
rgba: e,
|
|
1452
1924
|
colorSpace: this.workingSpace
|
|
1453
|
-
} : (
|
|
1925
|
+
} : (U(e, this.workingSpace, n, { context: this._context }), {
|
|
1454
1926
|
rgba: e,
|
|
1455
1927
|
colorSpace: n
|
|
1456
1928
|
});
|
|
1457
1929
|
}
|
|
1458
1930
|
status() {
|
|
1459
|
-
let e =
|
|
1931
|
+
let e = I(), t = this._renderer ? b(this._renderer.toneMapping) : null, n = !!this._canvasView?.hdr && this._canvasOnScreen();
|
|
1460
1932
|
return {
|
|
1461
1933
|
config: e,
|
|
1462
1934
|
workingSpace: this.workingSpace,
|
|
@@ -1471,18 +1943,31 @@ var Lt = class {
|
|
|
1471
1943
|
exportSpace: this._exportSpace,
|
|
1472
1944
|
views: p(),
|
|
1473
1945
|
registryVersion: _(),
|
|
1474
|
-
bakeError: t?.error ?? null
|
|
1946
|
+
bakeError: t?.error ?? null,
|
|
1947
|
+
canvasColorSpace: this.canvasColorSpace,
|
|
1948
|
+
hdr: {
|
|
1949
|
+
on: this._hdrOutput,
|
|
1950
|
+
showing: n,
|
|
1951
|
+
view: n ? this._canvasView.table?.name ?? t?.name ?? null : null,
|
|
1952
|
+
reason: this._canvasReason
|
|
1953
|
+
}
|
|
1475
1954
|
};
|
|
1476
1955
|
}
|
|
1477
1956
|
dispose() {
|
|
1478
|
-
this._offRegistry?.(), this._listeners.clear(), this._releaseViews()
|
|
1957
|
+
this._offRegistry?.(), this._listeners.clear(), this._releaseViews();
|
|
1958
|
+
for (let e of new Set([
|
|
1959
|
+
this._canvasView?.table,
|
|
1960
|
+
...this._bakedCanvasViews.values(),
|
|
1961
|
+
...this._recentCanvasViews.values()
|
|
1962
|
+
])) e?.dispose();
|
|
1963
|
+
this._canvasView = null, this._bakedCanvasViews.clear(), this._recentCanvasViews.clear(), Tt(null), this._renderer = null, this._issues = null, s() === this && (n(null), a(null));
|
|
1479
1964
|
}
|
|
1480
1965
|
static resetAll() {
|
|
1481
|
-
a(null), n(null),
|
|
1966
|
+
a(null), n(null), qt(), u(), Ye(), an(), He();
|
|
1482
1967
|
}
|
|
1483
1968
|
};
|
|
1484
|
-
function
|
|
1485
|
-
return
|
|
1969
|
+
function Sn() {
|
|
1970
|
+
return N();
|
|
1486
1971
|
}
|
|
1487
1972
|
//#endregion
|
|
1488
|
-
export {
|
|
1973
|
+
export { Ze as A, Xe as C, K as D, st as E, Ee as F, je as M, T as N, ct as O, Ae as P, ot as S, U as T, Ht as _, an as a, vt as b, on as c, pn as d, Ct as f, X as g, Gt as h, Sn as i, w as j, Qe as k, $ as l, xt as m, mn as n, un as o, St as p, bn as r, cn as s, xn as t, rn as u, Lt as v, nt as w, bt as x, ft as y };
|