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
|
@@ -1,552 +0,0 @@
|
|
|
1
|
-
import { ACESFilmicToneMapping as e, AgXToneMapping as t, CineonToneMapping as n, LinearToneMapping as r, NeutralToneMapping as i, NoToneMapping as a, ReinhardToneMapping as o } from "three";
|
|
2
|
-
//#region src/utils/Logger.js
|
|
3
|
-
var s = {
|
|
4
|
-
silent: 0,
|
|
5
|
-
error: 1,
|
|
6
|
-
warn: 2,
|
|
7
|
-
info: 3,
|
|
8
|
-
debug: 4
|
|
9
|
-
}, c = "info", l = "rayzeeLogLevel", u = "rayzeeLogNamespaces", d = "color:#7c8494", f = "color:inherit", p = null, m = null;
|
|
10
|
-
function h(e) {
|
|
11
|
-
try {
|
|
12
|
-
return globalThis.localStorage?.getItem(e) ?? null;
|
|
13
|
-
} catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function g(e, t) {
|
|
18
|
-
try {
|
|
19
|
-
t === null ? globalThis.localStorage?.removeItem(e) : globalThis.localStorage?.setItem(e, t);
|
|
20
|
-
} catch {}
|
|
21
|
-
}
|
|
22
|
-
function _() {
|
|
23
|
-
if (p !== null) return p;
|
|
24
|
-
let e = globalThis.__RAYZEE_LOG_LEVEL__;
|
|
25
|
-
return e !== void 0 && e in s ? (p = s[e], p) : (p = s[h(l)] ?? s[c], p);
|
|
26
|
-
}
|
|
27
|
-
function v() {
|
|
28
|
-
if (m !== null) return m;
|
|
29
|
-
let e = globalThis.__RAYZEE_LOG_NS__ ?? h(u);
|
|
30
|
-
return m = e ? String(e).split(",").map((e) => e.trim()).filter(Boolean) : [], m;
|
|
31
|
-
}
|
|
32
|
-
function y(e, t) {
|
|
33
|
-
if (t < s.debug) return !0;
|
|
34
|
-
let n = v();
|
|
35
|
-
return n.length === 0 || n.some((t) => e === t || e.startsWith(`${t}:`));
|
|
36
|
-
}
|
|
37
|
-
function b(e, t, n) {
|
|
38
|
-
if (e > _() || !y(t, e)) return;
|
|
39
|
-
let r = e === s.error ? console.error : e === s.warn ? console.warn : console.log, i = `[${t}]`;
|
|
40
|
-
typeof n[0] == "string" ? r(`%c${i}%c ${n[0]}`, d, f, ...n.slice(1)) : r(`%c${i}`, d, ...n);
|
|
41
|
-
}
|
|
42
|
-
var x = {
|
|
43
|
-
n: (e) => Number(e).toLocaleString("en-US"),
|
|
44
|
-
ms: (e) => e < 10 ? `${Number(e).toFixed(1)} ms` : `${Math.round(e)} ms`,
|
|
45
|
-
mb: (e) => {
|
|
46
|
-
let t = e / (1024 * 1024);
|
|
47
|
-
return t < 10 ? `${t.toFixed(1)} MB` : `${Math.round(t)} MB`;
|
|
48
|
-
},
|
|
49
|
-
px: (e, t) => `${e}×${t}`,
|
|
50
|
-
count: (e, t, n = `${t}s`) => `${x.n(e)} ${Number(e) === 1 ? t : n}`,
|
|
51
|
-
list: (e) => e.filter(Boolean).join(" · ")
|
|
52
|
-
}, S = {
|
|
53
|
-
levels: s,
|
|
54
|
-
setLevel(e) {
|
|
55
|
-
return e in s ? (globalThis.__RAYZEE_LOG_LEVEL__ = e, p = s[e], g(l, e === c ? null : e), e) : (console.warn(`[log] unknown level '${e}' — expected one of ${Object.keys(s).join(", ")}`), this.getLevel());
|
|
56
|
-
},
|
|
57
|
-
getLevel() {
|
|
58
|
-
let e = _();
|
|
59
|
-
return Object.keys(s).find((t) => s[t] === e);
|
|
60
|
-
},
|
|
61
|
-
isEnabled(e) {
|
|
62
|
-
return (s[e] ?? s.debug) <= _();
|
|
63
|
-
},
|
|
64
|
-
only(...e) {
|
|
65
|
-
let t = e.flat().filter(Boolean);
|
|
66
|
-
return m = t, globalThis.__RAYZEE_LOG_NS__ = t.join(","), g(u, t.length ? t.join(",") : null), t.length && this.setLevel("debug"), t;
|
|
67
|
-
},
|
|
68
|
-
refresh() {
|
|
69
|
-
return p = null, m = null, this.getLevel();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
function C(e) {
|
|
73
|
-
return {
|
|
74
|
-
namespace: e,
|
|
75
|
-
error: (...t) => b(s.error, e, t),
|
|
76
|
-
warn: (...t) => b(s.warn, e, t),
|
|
77
|
-
info: (...t) => b(s.info, e, t),
|
|
78
|
-
debug: (...t) => b(s.debug, e, t),
|
|
79
|
-
isEnabled: (e) => S.isEnabled(e),
|
|
80
|
-
summary(t, n = []) {
|
|
81
|
-
let r = n.filter(Boolean);
|
|
82
|
-
if (r.length === 0 || !console.groupCollapsed) {
|
|
83
|
-
b(s.info, e, [t]), r.forEach((t) => b(s.debug, e, [t]));
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
s.info > _() || ((_() >= s.debug && console.group ? console.group : console.groupCollapsed)(`%c[${e}]%c ${t}`, d, f), r.forEach((e) => console.log(e)), console.groupEnd());
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
var w = /* @__PURE__ */ new Set();
|
|
91
|
-
function T(e, t, ...n) {
|
|
92
|
-
w.has(t) || (w.add(t), e.warn(...n));
|
|
93
|
-
}
|
|
94
|
-
function E() {
|
|
95
|
-
return S.getLevel();
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/AssetConfig.js
|
|
99
|
-
var D = {
|
|
100
|
-
ortRuntimeUrl: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs",
|
|
101
|
-
ortWasmPaths: "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/",
|
|
102
|
-
dracoDecoderPath: "https://www.gstatic.com/draco/v1/decoders/",
|
|
103
|
-
ktx2TranscoderPath: "https://cdn.jsdelivr.net/npm/three@0.183.2/examples/jsm/libs/basis/",
|
|
104
|
-
oidnWeightsBaseUrl: "https://assets.rayzee.atulmourya.com/oidn/denoiser-0.0.11/",
|
|
105
|
-
ocioRuntimeFactory: null,
|
|
106
|
-
ocioRuntimeUrl: null,
|
|
107
|
-
ocioWasmUrl: null,
|
|
108
|
-
upscalerModelBaseUrl: "https://huggingface.co/notaneimu/onnx-image-models/resolve/main/",
|
|
109
|
-
neuralRuntimeUrl: "/neural/neural-runtime.js",
|
|
110
|
-
neuralAssetBaseUrl: null,
|
|
111
|
-
cacheNamespace: "rayzee",
|
|
112
|
-
storage: "auto"
|
|
113
|
-
}, O = /* @__PURE__ */ new Set();
|
|
114
|
-
function k(e) {
|
|
115
|
-
if (e) {
|
|
116
|
-
Object.assign(D, e);
|
|
117
|
-
for (let t of Object.keys(e)) O.add(t);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function A(e) {
|
|
121
|
-
return O.has(e);
|
|
122
|
-
}
|
|
123
|
-
function j() {
|
|
124
|
-
return { ...D };
|
|
125
|
-
}
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/Color/BuiltinViews.js
|
|
128
|
-
var M = (e) => Math.min(Math.max(e, 0), 1);
|
|
129
|
-
function ee(e, t, n, r, i) {
|
|
130
|
-
i[0] = M(e), i[1] = M(t), i[2] = M(n);
|
|
131
|
-
}
|
|
132
|
-
function te(e, t, n, r, i) {
|
|
133
|
-
i[0] = M(e * r), i[1] = M(t * r), i[2] = M(n * r);
|
|
134
|
-
}
|
|
135
|
-
function ne(e, t, n, r, i) {
|
|
136
|
-
e *= r, t *= r, n *= r, i[0] = M(e / (e + 1)), i[1] = M(t / (t + 1)), i[2] = M(n / (n + 1));
|
|
137
|
-
}
|
|
138
|
-
function re(e, t, n, r, i) {
|
|
139
|
-
e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
|
|
140
|
-
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
141
|
-
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
142
|
-
}
|
|
143
|
-
function ie(e, t, n, r, i) {
|
|
144
|
-
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
145
|
-
let a = .59719 * e + .35458 * t + .04823 * n, o = .076 * e + .90834 * t + .01566 * n, s = .0284 * e + .13383 * t + .83777 * n, c = (e) => (e * (e + .0245786) - 90537e-9) / (e * (.983729 * e + .432951) + .238081);
|
|
146
|
-
a = c(a), o = c(o), s = c(s), i[0] = M(1.60475 * a - .53108 * o - .07367 * s), i[1] = M(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = M(-.00327 * a - .07276 * o + 1.07602 * s);
|
|
147
|
-
}
|
|
148
|
-
function N(e, t, n, r, i) {
|
|
149
|
-
e *= r, t *= r, n *= r;
|
|
150
|
-
let a = .6274 * e + .3293 * t + .0433 * n, o = .0691 * e + .9195 * t + .0113 * n, s = .0164 * e + .088 * t + .8956 * n, c = .856627153315983 * a + .0951212405381588 * o + .0482516061458583 * s, l = .137318972929847 * a + .761241990602591 * o + .101439036467562 * s, u = .11189821299995 * a + .0767994186031903 * o + .811302368396859 * s, d = -12.47393, f = 4.026069 - d;
|
|
151
|
-
c = M((Math.log2(Math.max(c, 1e-10)) - d) / f), l = M((Math.log2(Math.max(l, 1e-10)) - d) / f), u = M((Math.log2(Math.max(u, 1e-10)) - d) / f);
|
|
152
|
-
let p = (e) => {
|
|
153
|
-
let t = e * e, n = t * t;
|
|
154
|
-
return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
|
|
155
|
-
};
|
|
156
|
-
c = p(c), l = p(l), u = p(u);
|
|
157
|
-
let m = 1.1271005818144368 * c - .11060664309660323 * l - .016493938717834573 * u, h = -.1413297634984383 * c + 1.157823702216272 * l - .016493938717834257 * u, g = -.14132976349843826 * c - .11060664309660294 * l + 1.2519364065950405 * u;
|
|
158
|
-
m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = M(1.6605 * m - .5876 * h - .0728 * g), i[1] = M(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = M(-.0182 * m - .1006 * h + 1.1187 * g);
|
|
159
|
-
}
|
|
160
|
-
function P(e, t, n, r, i) {
|
|
161
|
-
let a = .76;
|
|
162
|
-
e *= r, t *= r, n *= r;
|
|
163
|
-
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
164
|
-
e -= s, t -= s, n -= s;
|
|
165
|
-
let c = Math.max(e, Math.max(t, n));
|
|
166
|
-
if (c < a) {
|
|
167
|
-
i[0] = e, i[1] = t, i[2] = n;
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
let l = 1 - a, u = 1 - l * l / (c + l - a), d = u / c;
|
|
171
|
-
e *= d, t *= d, n *= d;
|
|
172
|
-
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
173
|
-
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
174
|
-
}
|
|
175
|
-
var F = [
|
|
176
|
-
{
|
|
177
|
-
id: a,
|
|
178
|
-
name: "None",
|
|
179
|
-
wgslConst: "TM_NONE",
|
|
180
|
-
cpu: ee,
|
|
181
|
-
wgsl: null,
|
|
182
|
-
call: null,
|
|
183
|
-
appliesExposure: !1
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
id: r,
|
|
187
|
-
name: "Linear",
|
|
188
|
-
wgslConst: "TM_LINEAR",
|
|
189
|
-
cpu: te,
|
|
190
|
-
wgsl: null,
|
|
191
|
-
call: null
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: o,
|
|
195
|
-
name: "Reinhard",
|
|
196
|
-
wgslConst: "TM_REINHARD",
|
|
197
|
-
cpu: ne,
|
|
198
|
-
wgsl: "\nfn tm_reinhard( c: vec3<f32> ) -> vec3<f32> {\n return clamp( c / ( c + vec3<f32>( 1.0 ) ), vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) );\n}\n",
|
|
199
|
-
call: "tm_reinhard( c )"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
id: n,
|
|
203
|
-
name: "Cineon",
|
|
204
|
-
wgslConst: "TM_CINEON",
|
|
205
|
-
cpu: re,
|
|
206
|
-
wgsl: "\nfn tm_cineon( c0: vec3<f32> ) -> vec3<f32> {\n let c = max( c0 - vec3<f32>( 0.004 ), vec3<f32>( 0.0 ) );\n let v = ( c * ( 6.2 * c + vec3<f32>( 0.5 ) ) ) / ( c * ( 6.2 * c + vec3<f32>( 1.7 ) ) + vec3<f32>( 0.06 ) );\n return pow( max( v, vec3<f32>( 0.0 ) ), vec3<f32>( 2.2 ) );\n}\n",
|
|
207
|
-
call: "tm_cineon( c )"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
id: e,
|
|
211
|
-
name: "ACES Filmic",
|
|
212
|
-
wgslConst: "TM_ACES",
|
|
213
|
-
cpu: ie,
|
|
214
|
-
wgsl: "\nfn tm_aces( c0: vec3<f32> ) -> vec3<f32> {\n let c = c0 / 0.6;\n let m_in = mat3x3<f32>(\n vec3<f32>( 0.59719, 0.07600, 0.02840 ),\n vec3<f32>( 0.35458, 0.90834, 0.13383 ),\n vec3<f32>( 0.04823, 0.01566, 0.83777 ) );\n let v = m_in * c;\n let a = v * ( v + vec3<f32>( 0.0245786 ) ) - vec3<f32>( 0.000090537 );\n let b = v * ( 0.983729 * v + vec3<f32>( 0.4329510 ) ) + vec3<f32>( 0.238081 );\n let m_out = mat3x3<f32>(\n vec3<f32>( 1.60475, -0.10208, -0.00327 ),\n vec3<f32>( -0.53108, 1.10813, -0.07276 ),\n vec3<f32>( -0.07367, -0.00605, 1.07602 ) );\n return clamp( m_out * ( a / b ), vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) );\n}\n",
|
|
215
|
-
call: "tm_aces( c )"
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: t,
|
|
219
|
-
name: "AgX",
|
|
220
|
-
wgslConst: "TM_AGX",
|
|
221
|
-
cpu: N,
|
|
222
|
-
wgsl: "\nfn tm_agx( c0: vec3<f32> ) -> vec3<f32> {\n let m_in = mat3x3<f32>(\n vec3<f32>( 0.6274, 0.0691, 0.0164 ),\n vec3<f32>( 0.3293, 0.9195, 0.0880 ),\n vec3<f32>( 0.0433, 0.0113, 0.8956 ) );\n let m_agx = mat3x3<f32>(\n vec3<f32>( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3<f32>( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3<f32>( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) );\n\n var v = m_agx * ( m_in * c0 );\n\n let minEv = -12.47393;\n let maxEv = 4.026069;\n v = clamp( ( log2( max( v, vec3<f32>( 1e-10 ) ) ) - vec3<f32>( minEv ) ) / ( maxEv - minEv ),\n vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) );\n\n let x2 = v * v;\n let x4 = x2 * x2;\n v = 15.5 * x4 * x2 - 40.14 * x4 * v + 31.96 * x4 - 6.868 * x2 * v + 0.4298 * x2 + 0.1191 * v\n - vec3<f32>( 0.00232 );\n\n let m_out = mat3x3<f32>(\n vec3<f32>( 1.1271005818144368, -0.1413297634984383, -0.14132976349843826 ),\n vec3<f32>( -0.11060664309660323, 1.157823702216272, -0.11060664309660294 ),\n vec3<f32>( -0.016493938717834573, -0.016493938717834257, 1.2519364065950405 ) );\n let o = pow( max( m_out * v, vec3<f32>( 0.0 ) ), vec3<f32>( 2.2 ) );\n\n let m_srgb = mat3x3<f32>(\n vec3<f32>( 1.6605, -0.1246, -0.0182 ),\n vec3<f32>( -0.5876, 1.1329, -0.1006 ),\n vec3<f32>( -0.0728, -0.0083, 1.1187 ) );\n return clamp( m_srgb * o, vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) );\n}\n",
|
|
223
|
-
call: "tm_agx( c )"
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: i,
|
|
227
|
-
name: "Neutral",
|
|
228
|
-
wgslConst: "TM_NEUTRAL",
|
|
229
|
-
cpu: P,
|
|
230
|
-
wgsl: "\nfn tm_neutral( c0: vec3<f32> ) -> vec3<f32> {\n let startCompression = 0.8 - 0.04;\n let desaturation = 0.15;\n\n let x = min( c0.r, min( c0.g, c0.b ) );\n var offset = 0.04;\n if ( x < 0.08 ) { offset = x - 6.25 * x * x; }\n var c = c0 - vec3<f32>( offset );\n\n let peak = max( c.r, max( c.g, c.b ) );\n if ( peak < startCompression ) { return c; }\n\n let d = 1.0 - startCompression;\n let newPeak = 1.0 - d * d / ( peak + d - startCompression );\n c = c * ( newPeak / peak );\n let gFactor = 1.0 - 1.0 / ( desaturation * ( peak - newPeak ) + 1.0 );\n return mix( c, vec3<f32>( newPeak ), gFactor );\n}\n",
|
|
231
|
-
call: "tm_neutral( c )"
|
|
232
|
-
}
|
|
233
|
-
].map((e) => ({
|
|
234
|
-
source: "builtin",
|
|
235
|
-
outputEncoded: !1,
|
|
236
|
-
appliesExposure: !0,
|
|
237
|
-
...e
|
|
238
|
-
})), I = 200, L = 12, R = [...F], z = new Map(R.map((e) => [e.id, e])), B = 1, V = /* @__PURE__ */ new Set();
|
|
239
|
-
function H() {
|
|
240
|
-
B++;
|
|
241
|
-
for (let e of V) e();
|
|
242
|
-
}
|
|
243
|
-
var U = z;
|
|
244
|
-
function W() {
|
|
245
|
-
return B;
|
|
246
|
-
}
|
|
247
|
-
function G(e) {
|
|
248
|
-
return V.add(e), () => V.delete(e);
|
|
249
|
-
}
|
|
250
|
-
function K(e) {
|
|
251
|
-
return z.get(e) ?? null;
|
|
252
|
-
}
|
|
253
|
-
function q() {
|
|
254
|
-
return R.map((e) => ({
|
|
255
|
-
id: e.id,
|
|
256
|
-
name: e.name,
|
|
257
|
-
source: e.source,
|
|
258
|
-
display: e.ocio?.display ?? null,
|
|
259
|
-
view: e.ocio?.view ?? null,
|
|
260
|
-
look: e.ocio?.look ?? null
|
|
261
|
-
}));
|
|
262
|
-
}
|
|
263
|
-
function J() {
|
|
264
|
-
return R.filter((e) => e.table).length;
|
|
265
|
-
}
|
|
266
|
-
function ae() {
|
|
267
|
-
let e = 200;
|
|
268
|
-
for (; z.has(e);) e++;
|
|
269
|
-
return e;
|
|
270
|
-
}
|
|
271
|
-
function oe(e) {
|
|
272
|
-
if (typeof e?.id != "number") throw Error("view transform needs a numeric id");
|
|
273
|
-
if (typeof e.cpu != "function") throw Error(`view transform ${e.id} needs a cpu function`);
|
|
274
|
-
if (!e.name) throw Error(`view transform ${e.id} needs a name`);
|
|
275
|
-
if (!/^TM_[A-Z0-9_]+$/.test(e.wgslConst ?? "")) throw Error(`view transform ${e.id} needs a wgslConst like TM_SOMETHING`);
|
|
276
|
-
let t = z.get(e.id);
|
|
277
|
-
if (!t && e.table && J() >= 12) throw Error(`cannot register "${e.name}": 12 table-backed view transforms already registered, and WebGPU only guarantees 16 sampled textures per stage. Remove one first.`);
|
|
278
|
-
let n = {
|
|
279
|
-
source: "custom",
|
|
280
|
-
outputEncoded: !1,
|
|
281
|
-
appliesExposure: !0,
|
|
282
|
-
...e
|
|
283
|
-
};
|
|
284
|
-
return t ? R[R.indexOf(t)] = n : R.push(n), z.set(n.id, n), H(), n;
|
|
285
|
-
}
|
|
286
|
-
function se(e) {
|
|
287
|
-
let t = z.get(e);
|
|
288
|
-
return t ? (R.splice(R.indexOf(t), 1), z.delete(e), H(), !0) : !1;
|
|
289
|
-
}
|
|
290
|
-
function ce(e = null) {
|
|
291
|
-
let t = R.filter((t) => t.source === "ocio" && !e?.has(t.id)).map((e) => e.id);
|
|
292
|
-
if (t.length === 0) return 0;
|
|
293
|
-
for (let e of t) {
|
|
294
|
-
let t = z.get(e);
|
|
295
|
-
R.splice(R.indexOf(t), 1), z.delete(e);
|
|
296
|
-
}
|
|
297
|
-
return H(), t.length;
|
|
298
|
-
}
|
|
299
|
-
function le(e) {
|
|
300
|
-
let t = e?.library;
|
|
301
|
-
if (!t?.addToneMapping) return 0;
|
|
302
|
-
let n = 0;
|
|
303
|
-
for (let e of R) e.tsl && (t.toneMappingNodes?.delete(e.id), t.addToneMapping(e.tsl, e.id), n++);
|
|
304
|
-
return n;
|
|
305
|
-
}
|
|
306
|
-
function Y({ group: e = 0, firstBinding: t = 3 } = {}) {
|
|
307
|
-
let n = [], r = t, i = [], a = [];
|
|
308
|
-
for (let t of R) {
|
|
309
|
-
if (t.table) {
|
|
310
|
-
let a = `${t.wgslConst.toLowerCase()}_tex`;
|
|
311
|
-
i.push(`@group(${e}) @binding(${r}) var ${a}: texture_3d<f32>;`), n.push({
|
|
312
|
-
index: r,
|
|
313
|
-
transform: t,
|
|
314
|
-
texName: a
|
|
315
|
-
}), r += 1;
|
|
316
|
-
}
|
|
317
|
-
t.wgsl && a.push(t.wgsl);
|
|
318
|
-
}
|
|
319
|
-
let o = R.map((e) => `const ${e.wgslConst}: u32 = ${e.id}u;`).join("\n"), s = R.filter((e) => e.call).map((e) => `\tif ( mode == ${e.wgslConst} ) { return ${e.call}; }`).join("\n"), c = R.filter((e) => e.outputEncoded).map((e) => e.wgslConst), l = c.length ? c.map((e) => `mode == ${e}`).join(" || ") : "false", u = R.filter((e) => !e.appliesExposure).map((e) => e.wgslConst), d = u.length ? u.map((e) => `mode == ${e}`).join(" || ") : "false";
|
|
320
|
-
return {
|
|
321
|
-
wgsl: `
|
|
322
|
-
${o}
|
|
323
|
-
|
|
324
|
-
${i.join("\n")}
|
|
325
|
-
|
|
326
|
-
${a.join("\n")}
|
|
327
|
-
|
|
328
|
-
// Three.js clamps the fragment output with max(0) before tone mapping, so the curves never see a
|
|
329
|
-
// negative channel. The saturation grade drives channels below zero on much of a typical frame,
|
|
330
|
-
// and AgX/Neutral mix negatives across channels instead of clipping them.
|
|
331
|
-
fn rayzee_tone_curve( color: vec3<f32>, mode: u32 ) -> vec3<f32> {
|
|
332
|
-
let c = max( color, vec3<f32>( 0.0 ) );
|
|
333
|
-
${s}
|
|
334
|
-
return clamp( c, vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) );
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/** True when the curve already returned display-encoded colour. */
|
|
338
|
-
fn rayzee_output_encoded( mode: u32 ) -> bool {
|
|
339
|
-
return ${l};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
fn rayzee_tone_map( linearRGB: vec3<f32>, mode: u32, exposure: f32, saturation: f32 ) -> vec3<f32> {
|
|
343
|
-
// Three.js returns early for NoToneMapping without applying exposure, so a readback that
|
|
344
|
-
// applied it would paint brighter than the viewport it replaces.
|
|
345
|
-
var c = linearRGB * select( exposure, 1.0, ${d} );
|
|
346
|
-
if ( saturation != 1.0 ) {
|
|
347
|
-
let luma = vec3<f32>( dot( c, vec3<f32>( 0.2126, 0.7152, 0.0722 ) ) );
|
|
348
|
-
c = luma + ( c - luma ) * saturation;
|
|
349
|
-
}
|
|
350
|
-
return rayzee_tone_curve( c, mode );
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
fn rayzee_linear_to_srgb( c: vec3<f32> ) -> vec3<f32> {
|
|
354
|
-
return select(
|
|
355
|
-
1.055 * pow( max( c, vec3<f32>( 0.0 ) ), vec3<f32>( 1.0 / 2.4 ) ) - vec3<f32>( 0.055 ),
|
|
356
|
-
12.92 * c,
|
|
357
|
-
c <= vec3<f32>( 0.0031308 ) );
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/** The transfer step, skipped for a curve that already encoded its own output. */
|
|
361
|
-
fn rayzee_encode( mapped: vec3<f32>, mode: u32 ) -> vec3<f32> {
|
|
362
|
-
if ( rayzee_output_encoded( mode ) ) { return clamp( mapped, vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) ); }
|
|
363
|
-
return rayzee_linear_to_srgb( mapped );
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
fn rayzee_to_u8( srgb: vec3<f32> ) -> vec3<u32> {
|
|
367
|
-
return vec3<u32>( clamp( round( srgb * 255.0 + vec3<f32>( 0.5 ) ), vec3<f32>( 0.0 ), vec3<f32>( 255.0 ) ) );
|
|
368
|
-
}
|
|
369
|
-
`,
|
|
370
|
-
bindings: n
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
function X() {
|
|
374
|
-
R.length = 0, R.push(...F), z.clear();
|
|
375
|
-
for (let e of R) z.set(e.id, e);
|
|
376
|
-
H();
|
|
377
|
-
}
|
|
378
|
-
var ue = a, de = 0, fe = 3;
|
|
379
|
-
function Z() {
|
|
380
|
-
let { wgsl: e, bindings: t } = Y({
|
|
381
|
-
group: de,
|
|
382
|
-
firstBinding: fe
|
|
383
|
-
});
|
|
384
|
-
return {
|
|
385
|
-
wgsl: e,
|
|
386
|
-
bindings: t,
|
|
387
|
-
version: W()
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
Z().wgsl;
|
|
391
|
-
var pe = {
|
|
392
|
-
packed: "\n@group(0) @binding(0) var<storage, read> src: array<u32>;\n\nfn rayzee_source( x: u32, y: u32 ) -> vec4<f32> {\n let a = ( y * params.width + x ) * 2u;\n return vec4<f32>( unpack2x16float( src[ a ] ), unpack2x16float( src[ a + 1u ] ) );\n}",
|
|
393
|
-
texture: "\n@group(0) @binding(0) var src: texture_2d<f32>;\n\nfn rayzee_source( x: u32, y: u32 ) -> vec4<f32> {\n return textureLoad( src, vec2<u32>( x, y ), 0 );\n}"
|
|
394
|
-
}, me = {
|
|
395
|
-
rgba8: "\n@group(0) @binding(1) var<storage, read_write> dst: array<u32>;\n\nfn rayzee_store( i: u32, linear: vec4<f32>, mapped: vec3<f32> ) {\n let b8 = rayzee_to_u8( rayzee_encode( mapped, params.mode ) );\n var a8 = 255u;\n if ( params.alpha == 1u ) { a8 = rayzee_to_u8( vec3<f32>( linear.a ) ).x; }\n dst[ i ] = b8.x | ( b8.y << 8u ) | ( b8.z << 16u ) | ( a8 << 24u );\n}",
|
|
396
|
-
planar: "\n@group(0) @binding(1) var<storage, read_write> dst: array<f32>;\n\nfn rayzee_store( i: u32, linear: vec4<f32>, mapped: vec3<f32> ) {\n var c = clamp( mapped, vec3<f32>( 0.0 ), vec3<f32>( 1.0 ) );\n if ( ! rayzee_output_encoded( params.mode ) ) {\n let m = max( mapped, vec3<f32>( 0.0 ) );\n c = select( pow( m, vec3<f32>( 1.0 / 2.2 ) ), vec3<f32>( 0.0 ), m <= vec3<f32>( 0.0 ) );\n }\n let n = params.width * params.height;\n dst[ i ] = c.r;\n dst[ n + i ] = c.g;\n dst[ 2u * n + i ] = c.b;\n dst[ 3u * n + i ] = linear.a;\n}"
|
|
397
|
-
}, Q = {
|
|
398
|
-
rgba8: 4,
|
|
399
|
-
planar: 16
|
|
400
|
-
}, he = (e, t, n) => `
|
|
401
|
-
struct Params {
|
|
402
|
-
width: u32,
|
|
403
|
-
height: u32,
|
|
404
|
-
mode: u32,
|
|
405
|
-
flipY: u32,
|
|
406
|
-
exposure: f32,
|
|
407
|
-
saturation: f32,
|
|
408
|
-
alpha: u32,
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
@group(0) @binding(2) var<uniform> params: Params;
|
|
412
|
-
${pe[t]}
|
|
413
|
-
|
|
414
|
-
${e}
|
|
415
|
-
${me[n]}
|
|
416
|
-
|
|
417
|
-
@compute @workgroup_size(8, 8)
|
|
418
|
-
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
419
|
-
if ( gid.x >= params.width || gid.y >= params.height ) { return; }
|
|
420
|
-
|
|
421
|
-
var srcY = gid.y;
|
|
422
|
-
if ( params.flipY == 1u ) { srcY = params.height - 1u - gid.y; }
|
|
423
|
-
|
|
424
|
-
let linear = rayzee_source( gid.x, srcY );
|
|
425
|
-
rayzee_store( gid.y * params.width + gid.x, linear, rayzee_tone_map( linear.rgb, params.mode, params.exposure, params.saturation ) );
|
|
426
|
-
}
|
|
427
|
-
`, $ = 32, ge = class {
|
|
428
|
-
constructor(e, t = "rayzee:tonemap", { input: n = "packed", output: r = "rgba8" } = {}) {
|
|
429
|
-
this.device = e, this.label = t, this.input = n, this.output = r, this.width = 0, this.height = 0, this._pipeline = null, this._storage = null, this._map = null, this._params = null, this._paramData = new ArrayBuffer($), this._paramU32 = new Uint32Array(this._paramData), this._paramF32 = new Float32Array(this._paramData), this._shaderVersion = -1, this._bindings = [], this._tables = /* @__PURE__ */ new Map(), this.disposed = !1;
|
|
430
|
-
}
|
|
431
|
-
_ensurePipeline() {
|
|
432
|
-
let { wgsl: e, bindings: t, version: n } = Z();
|
|
433
|
-
this._pipeline && this._shaderVersion === n || (this._bindings = t, this._shaderVersion = n, this._pipeline = this.device.createComputePipeline({
|
|
434
|
-
label: this.label,
|
|
435
|
-
layout: "auto",
|
|
436
|
-
compute: {
|
|
437
|
-
module: this.device.createShaderModule({
|
|
438
|
-
label: this.label,
|
|
439
|
-
code: he(e, this.input, this.output)
|
|
440
|
-
}),
|
|
441
|
-
entryPoint: "main"
|
|
442
|
-
}
|
|
443
|
-
}));
|
|
444
|
-
}
|
|
445
|
-
_ensureTables() {
|
|
446
|
-
let e = /* @__PURE__ */ new Set();
|
|
447
|
-
for (let { index: t, transform: n } of this._bindings) {
|
|
448
|
-
let { data: r, size: i } = n.table;
|
|
449
|
-
e.add(t);
|
|
450
|
-
let a = this._tables.get(t);
|
|
451
|
-
if (a && a.data === r) continue;
|
|
452
|
-
a?.texture.destroy();
|
|
453
|
-
let o = this.device.createTexture({
|
|
454
|
-
label: `${this.label}-${n.wgslConst}`,
|
|
455
|
-
size: [
|
|
456
|
-
i,
|
|
457
|
-
i,
|
|
458
|
-
i
|
|
459
|
-
],
|
|
460
|
-
dimension: "3d",
|
|
461
|
-
format: "rgba16float",
|
|
462
|
-
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST
|
|
463
|
-
});
|
|
464
|
-
this.device.queue.writeTexture({ texture: o }, r, {
|
|
465
|
-
bytesPerRow: i * 8,
|
|
466
|
-
rowsPerImage: i
|
|
467
|
-
}, [
|
|
468
|
-
i,
|
|
469
|
-
i,
|
|
470
|
-
i
|
|
471
|
-
]), this._tables.set(t, {
|
|
472
|
-
texture: o,
|
|
473
|
-
data: r,
|
|
474
|
-
view: o.createView()
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
for (let [t, n] of this._tables) e.has(t) || (n.texture.destroy(), this._tables.delete(t));
|
|
478
|
-
}
|
|
479
|
-
ensureSize(e, t) {
|
|
480
|
-
if (this._ensurePipeline(), this._ensureTables(), this.width === e && this.height === t && this._storage) return;
|
|
481
|
-
this._releaseBuffers();
|
|
482
|
-
let n = e * t * Q[this.output];
|
|
483
|
-
this._storage = this.device.createBuffer({
|
|
484
|
-
label: `${this.label}-out`,
|
|
485
|
-
size: n,
|
|
486
|
-
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC
|
|
487
|
-
}), this._map = this.device.createBuffer({
|
|
488
|
-
label: `${this.label}-map`,
|
|
489
|
-
size: n,
|
|
490
|
-
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
491
|
-
}), this._params = this.device.createBuffer({
|
|
492
|
-
label: `${this.label}-params`,
|
|
493
|
-
size: $,
|
|
494
|
-
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
495
|
-
}), this.width = e, this.height = t;
|
|
496
|
-
}
|
|
497
|
-
async toRGBA8(e, t) {
|
|
498
|
-
return new Uint8ClampedArray(await this._run(e, t));
|
|
499
|
-
}
|
|
500
|
-
async toPlanar(e, t) {
|
|
501
|
-
return new Float32Array(await this._run(e, t));
|
|
502
|
-
}
|
|
503
|
-
async _run(e, { exposure: t = 1, toneMapping: n = 0, saturation: r = 1, flipY: i = !1, preserveAlpha: a = !1 } = {}) {
|
|
504
|
-
if (this.disposed) throw Error("PackedToneMapper: disposed");
|
|
505
|
-
if (!this._storage) throw Error("PackedToneMapper: call ensureSize() first");
|
|
506
|
-
this._ensurePipeline(), this._ensureTables();
|
|
507
|
-
let { width: o, height: s } = this, c = o * s * Q[this.output];
|
|
508
|
-
this._paramU32[0] = o, this._paramU32[1] = s, this._paramU32[2] = n >>> 0, this._paramU32[3] = +!!i, this._paramF32[4] = t, this._paramF32[5] = r, this._paramU32[6] = +!!a, this.device.queue.writeBuffer(this._params, 0, this._paramData);
|
|
509
|
-
let l = [...this._tables.entries()].map(([e, t]) => ({
|
|
510
|
-
binding: e,
|
|
511
|
-
resource: t.view
|
|
512
|
-
})), u = this.device.createBindGroup({
|
|
513
|
-
layout: this._pipeline.getBindGroupLayout(0),
|
|
514
|
-
entries: [
|
|
515
|
-
...l,
|
|
516
|
-
{
|
|
517
|
-
binding: 0,
|
|
518
|
-
resource: this.input === "texture" ? e.createView() : {
|
|
519
|
-
buffer: e,
|
|
520
|
-
size: o * s * 8
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
binding: 1,
|
|
525
|
-
resource: { buffer: this._storage }
|
|
526
|
-
},
|
|
527
|
-
{
|
|
528
|
-
binding: 2,
|
|
529
|
-
resource: { buffer: this._params }
|
|
530
|
-
}
|
|
531
|
-
]
|
|
532
|
-
}), d = this.device.createCommandEncoder({ label: this.label }), f = d.beginComputePass();
|
|
533
|
-
f.setPipeline(this._pipeline), f.setBindGroup(0, u), f.dispatchWorkgroups(Math.ceil(o / 8), Math.ceil(s / 8)), f.end(), d.copyBufferToBuffer(this._storage, 0, this._map, 0, c), this.device.queue.submit([d.finish()]), await this._map.mapAsync(GPUMapMode.READ);
|
|
534
|
-
let p = this._map.getMappedRange().slice(0);
|
|
535
|
-
return this._map.unmap(), p;
|
|
536
|
-
}
|
|
537
|
-
release() {
|
|
538
|
-
this._releaseBuffers(), this.width = this.height = 0;
|
|
539
|
-
}
|
|
540
|
-
_releaseBuffers() {
|
|
541
|
-
this._storage?.destroy(), this._map?.destroy(), this._params?.destroy(), this._storage = null, this._map = null, this._params = null;
|
|
542
|
-
}
|
|
543
|
-
dispose() {
|
|
544
|
-
if (!this.disposed) {
|
|
545
|
-
this.disposed = !0, this._releaseBuffers();
|
|
546
|
-
for (let e of this._tables.values()) e.texture.destroy();
|
|
547
|
-
this._tables.clear(), this._pipeline = null;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
//#endregion
|
|
552
|
-
export { C, E, S, T, X as _, U as a, A as b, J as c, q as d, ae as f, se as g, ce as h, I as i, W as l, le as m, ue as n, oe as o, G as p, L as r, Y as s, ge as t, K as u, k as v, x as w, s as x, j as y };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
-
let r = {};
|
|
4
|
-
for (var i in t) e(r, i, {
|
|
5
|
-
get: t[i],
|
|
6
|
-
enumerable: !0
|
|
7
|
-
});
|
|
8
|
-
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
-
};
|
|
10
|
-
//#endregion
|
|
11
|
-
export { t };
|