rayzee 8.6.0 → 8.6.1
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 +1 -53
- package/dist/{DLSSNeural-BhBCBgKf.js → NeuralRetouch-CYOJ21Wn.js} +31 -31
- package/dist/{DLSSSuperRes-BCA7F_k5.js → NeuralSuperRes-Dc6jRYke.js} +23 -23
- package/dist/{ToneMapGPU-BzcLheoR.js → ToneMapGPU-BVE852iN.js} +2 -2
- package/dist/rayzee.es.js +49 -39
- package/dist/rayzee.umd.js +5 -5
- package/package.json +1 -1
- package/src/AssetConfig.js +6 -5
- package/src/Passes/OIDNDenoiser.js +13 -5
- package/src/index.js +3 -3
- package/src/managers/DenoisingManager.js +60 -44
- package/src/{dlss/DLSSNeural.js → neural/NeuralRetouch.js} +42 -41
- package/src/{dlss/DLSSSuperRes.js → neural/NeuralSuperRes.js} +27 -26
package/README.md
CHANGED
|
@@ -288,11 +288,6 @@ configureAssets({
|
|
|
288
288
|
oidnWeightsBaseUrl: '/oidn-tzas/',
|
|
289
289
|
upscalerModelBaseUrl: '/upscaler-onnx/',
|
|
290
290
|
|
|
291
|
-
// DLSS. The runtime is a plain script the host must serve — it installs
|
|
292
|
-
// `globalThis.DLSSRuntime` as a side effect and cannot be imported.
|
|
293
|
-
dlssRuntimeUrl: '/dlss/dlss-runtime.js',
|
|
294
|
-
dlssAssetBaseUrl: '/dlss/',
|
|
295
|
-
|
|
296
291
|
// OpenColorIO runtime (~6 MB of WebAssembly) — the engine never names the package, so a host
|
|
297
292
|
// that loads colour configs supplies it, bundled or served. Unset, colour management stays inert.
|
|
298
293
|
ocioRuntimeFactory: () => import('@bb-studio/ocio'), // or: ocioRuntimeUrl: '/vendor/ocio/index.js'
|
|
@@ -636,10 +631,8 @@ engine.denoisingManager.setOIDNQuality('high')
|
|
|
636
631
|
engine.denoisingManager.setStrategy('oidn') // OIDN owns the live view; see below
|
|
637
632
|
engine.denoisingManager.continuousDenoiseInterval = 250 // cap refreshes at 4/sec (default 8 = uncapped)
|
|
638
633
|
engine.denoisingManager.setUpscalerEnabled(true)
|
|
639
|
-
engine.denoisingManager.
|
|
640
|
-
engine.denoisingManager.setUpscalerScaleFactor(2) // ESRGAN only; DLSS is fixed at 2x
|
|
634
|
+
engine.denoisingManager.setUpscalerScaleFactor(2) // 2 or 4
|
|
641
635
|
engine.denoisingManager.setUpscalerQuality('high') // ESRGAN only
|
|
642
|
-
engine.denoisingManager.setNeuralRendering(true, { intensity: 1, colorStrength: 0 })
|
|
643
636
|
```
|
|
644
637
|
|
|
645
638
|
### engine.interactionManager
|
|
@@ -1260,51 +1253,6 @@ engine.addEventListener(EngineEvents.UPSCALING_END, () => console.log('Upsc
|
|
|
1260
1253
|
|
|
1261
1254
|
**Chaining with OIDN:** Upscaling and OIDN **can** run together — on render completion, OIDN runs first, then its denoised output is fed into the upscaler. Enable both; no manual coordination required.
|
|
1262
1255
|
|
|
1263
|
-
### The DLSS passes
|
|
1264
|
-
|
|
1265
|
-
Two further neural passes, ported from NVIDIA's DLSS weights. Both run once when a render finishes
|
|
1266
|
-
and both need a denoised frame — on raw Monte-Carlo noise they measurably lose to a plain resize, so
|
|
1267
|
-
enable OIDN alongside them.
|
|
1268
|
-
|
|
1269
|
-
Unlike the ONNX upscaler these are **not fetched from a CDN**: `dlss-runtime.js` installs
|
|
1270
|
-
`globalThis.DLSSRuntime` as a side effect and cannot be imported, so the host serves it and points
|
|
1271
|
-
`configureAssets` at it (see above). It lives at `app/public/dlss/` in this repo, and the local edits
|
|
1272
|
-
it carries are written up in `app/public/dlss/PATCHES.md` — re-vendoring it without re-applying them
|
|
1273
|
-
breaks the retouch pass with an explanatory throw.
|
|
1274
|
-
|
|
1275
|
-
```js
|
|
1276
|
-
// Super resolution, as a second AI Upscaler backend
|
|
1277
|
-
engine.denoisingManager.setUpscalerEnabled(true);
|
|
1278
|
-
engine.denoisingManager.setUpscalerBackend('dlss');
|
|
1279
|
-
|
|
1280
|
-
// The retouch pass — appearance, not resolution. Independent of the upscaler.
|
|
1281
|
-
engine.denoisingManager.setNeuralRendering(true, {
|
|
1282
|
-
intensity: 1, // 0..1 how much of the pass reaches the image
|
|
1283
|
-
localTone: 1, // 0..2 local light shaping; 1 is neutral
|
|
1284
|
-
localStructure: 1, // 0..2 fine surface detail; 1 is neutral
|
|
1285
|
-
colorStrength: 0, // 0..1 0 keeps the render's chroma, 1 takes the model's
|
|
1286
|
-
});
|
|
1287
|
-
```
|
|
1288
|
-
|
|
1289
|
-
The chain is **denoise → retouch (at render size) → super resolution (2x) → tone map**, scene-referred
|
|
1290
|
-
throughout. The retouch pass runs *before* the upscale deliberately: it sees a quarter of the pixels
|
|
1291
|
-
there, and above `DLSS_NR_MAX_PIXELS` (4.19 MP) it takes minutes and then loses every GPU device in
|
|
1292
|
-
the page. `DenoisingManager` skips it above that size rather than letting it run.
|
|
1293
|
-
|
|
1294
|
-
| | Super resolution | Retouch |
|
|
1295
|
-
|---|---|---|
|
|
1296
|
-
| What it changes | Resolution, fixed 2x | Appearance only |
|
|
1297
|
-
| Weights | 3.2 MB | 141 MB, fetched on first use |
|
|
1298
|
-
| Cost (1.9M-tri interior, warm) | 260 ms at 1024²→2048², 947 ms at 2048²→4096² | ~6 s at 2048² |
|
|
1299
|
-
| Against a native render | Ties Real-ESRGAN on accuracy, 3x faster, sharper than native | Close to a no-op on path-traced images |
|
|
1300
|
-
|
|
1301
|
-
Exported for building UI against: `SR_SCALE`, `SR_MAX_INPUT`, `DLSS_NR_DEFAULTS`, `DLSS_NR_RANGES`,
|
|
1302
|
-
`DLSS_NR_MAX_PIXELS`, and `renderUpscaled( app, { outputWidth, outputHeight, samples } )` — the
|
|
1303
|
-
offline entry point that drives a half-size render, denoise and upscale in one call.
|
|
1304
|
-
|
|
1305
|
-
⚠️ Each model brings **its own `GPUDevice`**, built by the runtime and not shareable. With both on,
|
|
1306
|
-
the page holds three: the renderer's and one each.
|
|
1307
|
-
|
|
1308
1256
|
## Troubleshooting
|
|
1309
1257
|
|
|
1310
1258
|
**OIDN: `Cannot find module './tza'` (webpack)**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
|
|
2
|
-
import { S as t, t as n, y as r } from "./ToneMapGPU-
|
|
3
|
-
//#region src/
|
|
2
|
+
import { S as t, t as n, y as r } from "./ToneMapGPU-BVE852iN.js";
|
|
3
|
+
//#region src/neural/NeuralRetouch.js
|
|
4
4
|
var i = /* @__PURE__ */ e({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
NeuralRetouch: () => m,
|
|
6
|
+
RETOUCH_COLOR_STRENGTH: () => 0,
|
|
7
|
+
RETOUCH_DEFAULTS: () => a,
|
|
8
|
+
RETOUCH_MAX_PIXELS: () => c,
|
|
9
|
+
RETOUCH_RANGES: () => l,
|
|
10
10
|
enhanceFrame: () => g
|
|
11
11
|
}), a = Object.freeze({
|
|
12
12
|
enabled: !0,
|
|
@@ -29,7 +29,7 @@ function o(e = {}) {
|
|
|
29
29
|
colorStrength: t
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
var s = t("
|
|
32
|
+
var s = t("neural"), c = 2048 * 2048, l = Object.freeze({
|
|
33
33
|
intensity: [0, 1],
|
|
34
34
|
localTone: [0, 2],
|
|
35
35
|
localStructure: [0, 2],
|
|
@@ -39,16 +39,16 @@ var s = t("dlss"), c = 2048 * 2048, l = Object.freeze({
|
|
|
39
39
|
}), u = null;
|
|
40
40
|
function d() {
|
|
41
41
|
if (u) return u;
|
|
42
|
-
let {
|
|
43
|
-
return globalThis.
|
|
44
|
-
if (globalThis.
|
|
42
|
+
let { neuralRuntimeUrl: e, neuralAssetBaseUrl: t } = r();
|
|
43
|
+
return t ? (globalThis.__NEURAL_ASSET_BASE__ = t, u = new Promise((t, n) => {
|
|
44
|
+
if (globalThis.NeuralRuntime?.getSrNrChain) return t(globalThis.NeuralRuntime.getSrNrChain());
|
|
45
45
|
let r = document.createElement("script");
|
|
46
46
|
r.src = e, r.onload = () => {
|
|
47
|
-
let e = globalThis.
|
|
48
|
-
if (!e) return n(/* @__PURE__ */ Error("
|
|
47
|
+
let e = globalThis.NeuralRuntime?.getSrNrChain;
|
|
48
|
+
if (!e) return n(/* @__PURE__ */ Error("Neural runtime loaded but exposed no retouch entry"));
|
|
49
49
|
t(e());
|
|
50
|
-
}, r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load the
|
|
51
|
-
}), u;
|
|
50
|
+
}, r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load the neural runtime from ${e}`)), document.head.appendChild(r);
|
|
51
|
+
}), u) : Promise.reject(/* @__PURE__ */ Error("No neural model location: set neuralAssetBaseUrl with configureAssets()"));
|
|
52
52
|
}
|
|
53
53
|
var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1) var<storage, read_write> dst: array<u32>;\n\n@compute @workgroup_size(8, 8)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let size = textureDimensions(src);\n if ( gid.x >= size.x || gid.y >= size.y ) { return; }\n let c = textureLoad(src, vec2<i32>(gid.xy), 0);\n let r = u32(clamp(c.r, 0.0, 1.0) * 255.0 + 0.5);\n let g = u32(clamp(c.g, 0.0, 1.0) * 255.0 + 0.5);\n let b = u32(clamp(c.b, 0.0, 1.0) * 255.0 + 0.5);\n dst[gid.y * size.x + gid.x] = r | (g << 8u) | (b << 16u) | (255u << 24u);\n}\n", p = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1) var<storage, read_write> dst: array<u32>;\n\n@compute @workgroup_size(8, 8)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let size = textureDimensions(src);\n if ( gid.x >= size.x || gid.y >= size.y ) { return; }\n let c = textureLoad(src, vec2<i32>(gid.xy), 0);\n let a = (gid.y * size.x + gid.x) * 2u;\n dst[a] = pack2x16float(c.rg);\n dst[a + 1u] = pack2x16float(vec2<f32>(c.b, 1.0));\n}\n", m = class e {
|
|
54
54
|
constructor(e, t) {
|
|
@@ -64,8 +64,8 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
64
64
|
return this.chain.pipeline.geometry.validHeight;
|
|
65
65
|
}
|
|
66
66
|
static async create({ width: t, height: n, canvas: r = null, settings: i = {}, onProgress: a = () => {} }) {
|
|
67
|
-
if (!Number.isInteger(t) || !Number.isInteger(n) || t < 1 || n < 1) throw Error("
|
|
68
|
-
if (t * n > 4194304) throw Error(`
|
|
67
|
+
if (!Number.isInteger(t) || !Number.isInteger(n) || t < 1 || n < 1) throw Error("NeuralRetouch.create: width and height must be positive integers");
|
|
68
|
+
if (t * n > 4194304) throw Error(`NeuralRetouch.create: ${t}x${n} is ${(t * n / 1e6).toFixed(1)} MP, above the ${(c / 1e6).toFixed(1)} MP this pass survives. Past it the run takes minutes and then loses every GPU device in the page.`);
|
|
69
69
|
let s = r ?? document.createElement("canvas");
|
|
70
70
|
r || (s.style.cssText = "position:fixed;left:-10000px;top:0;pointer-events:none");
|
|
71
71
|
let l = new e(await (await d()).create(s, t, n, a, o(i).runtime), s);
|
|
@@ -74,21 +74,21 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
74
74
|
_allocate() {
|
|
75
75
|
let { validWidth: e, validHeight: t } = this.chain.pipeline.geometry;
|
|
76
76
|
this.source = this.device.createBuffer({
|
|
77
|
-
label: "rayzee:
|
|
77
|
+
label: "rayzee:retouch-source",
|
|
78
78
|
size: e * t * 8,
|
|
79
79
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
80
80
|
}), this.staging = new Uint16Array(e * t * 4);
|
|
81
81
|
let n = e * t * 4;
|
|
82
82
|
this._readbackStorage = this.device.createBuffer({
|
|
83
|
-
label: "rayzee:
|
|
83
|
+
label: "rayzee:retouch-readback",
|
|
84
84
|
size: n,
|
|
85
85
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC
|
|
86
86
|
}), this._readbackMap = this.device.createBuffer({
|
|
87
|
-
label: "rayzee:
|
|
87
|
+
label: "rayzee:retouch-readback-map",
|
|
88
88
|
size: n,
|
|
89
89
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
90
90
|
}), this._readbackPipeline = this.device.createComputePipeline({
|
|
91
|
-
label: "rayzee:
|
|
91
|
+
label: "rayzee:retouch-readback",
|
|
92
92
|
layout: "auto",
|
|
93
93
|
compute: {
|
|
94
94
|
module: this.device.createShaderModule({ code: f }),
|
|
@@ -97,15 +97,15 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
97
97
|
});
|
|
98
98
|
let r = e * t * 8;
|
|
99
99
|
this._hdrStorage = this.device.createBuffer({
|
|
100
|
-
label: "rayzee:
|
|
100
|
+
label: "rayzee:retouch-hdr",
|
|
101
101
|
size: r,
|
|
102
102
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC
|
|
103
103
|
}), this._hdrMap = this.device.createBuffer({
|
|
104
|
-
label: "rayzee:
|
|
104
|
+
label: "rayzee:retouch-hdr-map",
|
|
105
105
|
size: r,
|
|
106
106
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
107
107
|
}), this._hdrPipeline = this.device.createComputePipeline({
|
|
108
|
-
label: "rayzee:
|
|
108
|
+
label: "rayzee:retouch-hdr",
|
|
109
109
|
layout: "auto",
|
|
110
110
|
compute: {
|
|
111
111
|
module: this.device.createShaderModule({ code: p }),
|
|
@@ -115,7 +115,7 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
115
115
|
}
|
|
116
116
|
async _packHDR(e, t, n = !1) {
|
|
117
117
|
let r = this.chain.pipeline.slots[this.slot]?.hdrOutput;
|
|
118
|
-
if (!r) throw Error("
|
|
118
|
+
if (!r) throw Error("NeuralRetouch: the runtime has no scene-referred output. Either no frame has been produced yet, or neural-runtime.js was re-vendored without its `rayzee-patch` edits.");
|
|
119
119
|
let i = this.device.createBindGroup({
|
|
120
120
|
layout: this._hdrPipeline.getBindGroupLayout(0),
|
|
121
121
|
entries: [{
|
|
@@ -125,7 +125,7 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
125
125
|
binding: 1,
|
|
126
126
|
resource: { buffer: this._hdrStorage }
|
|
127
127
|
}]
|
|
128
|
-
}), a = this.device.createCommandEncoder({ label: "rayzee:
|
|
128
|
+
}), a = this.device.createCommandEncoder({ label: "rayzee:retouch-hdr" }), o = a.beginComputePass();
|
|
129
129
|
o.setPipeline(this._hdrPipeline), o.setBindGroup(0, i), o.dispatchWorkgroups(Math.ceil(e / 8), Math.ceil(t / 8)), o.end(), n && a.copyBufferToBuffer(this._hdrStorage, 0, this._hdrMap, 0, e * t * 8), this.device.queue.submit([a.finish()]);
|
|
130
130
|
}
|
|
131
131
|
async readOutputHDR() {
|
|
@@ -140,7 +140,7 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
140
140
|
}
|
|
141
141
|
async readOutputToned(e) {
|
|
142
142
|
let { validWidth: t, validHeight: r } = this.chain.pipeline.geometry;
|
|
143
|
-
return await this._packHDR(t, r), this._toneMapper ??= new n(this.device, "rayzee:
|
|
143
|
+
return await this._packHDR(t, r), this._toneMapper ??= new n(this.device, "rayzee:retouch-tonemap"), this._toneMapper.ensureSize(t, r), {
|
|
144
144
|
rgba8: await this._toneMapper.toRGBA8(this._hdrStorage, {
|
|
145
145
|
exposure: e.exposure ?? 1,
|
|
146
146
|
toneMapping: e.toneMapping ?? 0,
|
|
@@ -152,7 +152,7 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
152
152
|
}
|
|
153
153
|
async readOutput() {
|
|
154
154
|
let { validWidth: e, validHeight: t } = this.chain.pipeline.geometry, n = this.chain.pipeline.slots[this.slot]?.output;
|
|
155
|
-
if (!n) throw Error("
|
|
155
|
+
if (!n) throw Error("NeuralRetouch.readOutput: the pass has not produced a frame yet");
|
|
156
156
|
let r = this.device.createBindGroup({
|
|
157
157
|
layout: this._readbackPipeline.getBindGroupLayout(0),
|
|
158
158
|
entries: [{
|
|
@@ -162,7 +162,7 @@ var f = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1
|
|
|
162
162
|
binding: 1,
|
|
163
163
|
resource: { buffer: this._readbackStorage }
|
|
164
164
|
}]
|
|
165
|
-
}), i = this.device.createCommandEncoder({ label: "rayzee:
|
|
165
|
+
}), i = this.device.createCommandEncoder({ label: "rayzee:retouch-readback" }), a = i.beginComputePass();
|
|
166
166
|
a.setPipeline(this._readbackPipeline), a.setBindGroup(0, r), a.dispatchWorkgroups(Math.ceil(e / 8), Math.ceil(t / 8)), a.end(), i.copyBufferToBuffer(this._readbackStorage, 0, this._readbackMap, 0, e * t * 4), this.device.queue.submit([i.finish()]), await this._readbackMap.mapAsync(GPUMapMode.READ);
|
|
167
167
|
let o = new Uint8ClampedArray(this._readbackMap.getMappedRange().slice(0));
|
|
168
168
|
return this._readbackMap.unmap(), o;
|
|
@@ -187,9 +187,9 @@ async function g({ source: e, settings: t = {}, instance: n = null, exposure: r
|
|
|
187
187
|
onProgress: a
|
|
188
188
|
});
|
|
189
189
|
let { runtime: c, colorStrength: l } = o(t), u = s.staging;
|
|
190
|
-
if (!e.half || e.half.length !== u.length) throw Error(`
|
|
190
|
+
if (!e.half || e.half.length !== u.length) throw Error(`NeuralRetouch: expected ${u.length} packed halfs, got ${e.half?.length}`);
|
|
191
191
|
u.set(e.half), s.device.queue.writeBuffer(s.source, 0, u), s.chain.pipeline.paperWhite = 1 / Math.min(Math.max(r, 1 / h), h), s.chain.pipeline.colorStrength = l;
|
|
192
|
-
let d = performance.now(), f = s.device.createCommandEncoder({ label: "rayzee:
|
|
192
|
+
let d = performance.now(), f = s.device.createCommandEncoder({ label: "rayzee:retouch" });
|
|
193
193
|
await s.chain.encode(f, s.slot, { buffer: s.source }, c, () => {}, { reset: !0 }), s.device.queue.submit([f.finish()]), await s.device.queue.onSubmittedWorkDone();
|
|
194
194
|
let p = i ? await s.readOutputToned(i) : await s.readOutputHDR();
|
|
195
195
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
|
|
2
|
-
import { S as t, t as n, y as r } from "./ToneMapGPU-
|
|
2
|
+
import { S as t, t as n, y as r } from "./ToneMapGPU-BVE852iN.js";
|
|
3
3
|
//#region src/EngineEvents.js
|
|
4
4
|
var i = {
|
|
5
5
|
RENDER_COMPLETE: "engine:renderComplete",
|
|
@@ -35,26 +35,26 @@ var i = {
|
|
|
35
35
|
ISSUE: "engine:issue",
|
|
36
36
|
SCENE_METADATA_APPLIED: "engine:sceneMetadataApplied"
|
|
37
37
|
}, a = /* @__PURE__ */ e({
|
|
38
|
-
|
|
38
|
+
NeuralSuperRes: () => g,
|
|
39
39
|
SR_MAX_INPUT: () => c,
|
|
40
40
|
SR_SCALE: () => 2,
|
|
41
41
|
presentRGBA8: () => b,
|
|
42
42
|
readDenoisedHalf: () => h,
|
|
43
43
|
releaseDenoisedReader: () => m,
|
|
44
44
|
renderUpscaled: () => v
|
|
45
|
-
}), o = 2, s = t("
|
|
45
|
+
}), o = 2, s = t("neural"), c = 2048, l = null;
|
|
46
46
|
function u() {
|
|
47
47
|
if (l) return l;
|
|
48
|
-
let {
|
|
49
|
-
return globalThis.
|
|
50
|
-
if (globalThis.
|
|
48
|
+
let { neuralRuntimeUrl: e, neuralAssetBaseUrl: t } = r();
|
|
49
|
+
return t ? (globalThis.__NEURAL_ASSET_BASE__ = t, l = new Promise((t, n) => {
|
|
50
|
+
if (globalThis.NeuralRuntime?.getNativeSR) return t(globalThis.NeuralRuntime.getNativeSR());
|
|
51
51
|
let r = document.createElement("script");
|
|
52
52
|
r.src = e, r.onload = () => {
|
|
53
|
-
let e = globalThis.
|
|
54
|
-
if (!e) return n(/* @__PURE__ */ Error("
|
|
53
|
+
let e = globalThis.NeuralRuntime?.getNativeSR;
|
|
54
|
+
if (!e) return n(/* @__PURE__ */ Error("Neural runtime loaded but exposed no super-resolution entry"));
|
|
55
55
|
t(e());
|
|
56
|
-
}, r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load the
|
|
57
|
-
}), l;
|
|
56
|
+
}, r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load the neural runtime from ${e}`)), document.head.appendChild(r);
|
|
57
|
+
}), l) : Promise.reject(/* @__PURE__ */ Error("No neural model location: set neuralAssetBaseUrl with configureAssets()"));
|
|
58
58
|
}
|
|
59
59
|
var d = "\n@group(0) @binding(0) var src: texture_2d<f32>;\n@group(0) @binding(1) var<storage, read_write> dst: array<u32>;\n\n@compute @workgroup_size(8, 8)\nfn main( @builtin(global_invocation_id) gid: vec3<u32> ) {\n let size = textureDimensions( src );\n if ( gid.x >= size.x || gid.y >= size.y ) { return; }\n let c = textureLoad( src, vec2<i32>( gid.xy ), 0 ).rgb;\n let a = ( gid.y * size.x + gid.x ) * 2u;\n dst[ a ] = pack2x16float( c.rg );\n dst[ a + 1u ] = pack2x16float( vec2<f32>( c.b, 1.0 ) );\n}\n", f = null;
|
|
60
60
|
function p(e, t, n) {
|
|
@@ -65,21 +65,21 @@ function p(e, t, n) {
|
|
|
65
65
|
width: t,
|
|
66
66
|
height: n,
|
|
67
67
|
storage: e.createBuffer({
|
|
68
|
-
label: "rayzee:
|
|
68
|
+
label: "rayzee:neural-sr-pack",
|
|
69
69
|
size: r,
|
|
70
70
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC
|
|
71
71
|
}),
|
|
72
72
|
map: e.createBuffer({
|
|
73
|
-
label: "rayzee:
|
|
73
|
+
label: "rayzee:neural-sr-pack-map",
|
|
74
74
|
size: r,
|
|
75
75
|
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
|
|
76
76
|
}),
|
|
77
77
|
pipeline: e.createComputePipeline({
|
|
78
|
-
label: "rayzee:
|
|
78
|
+
label: "rayzee:neural-sr-pack",
|
|
79
79
|
layout: "auto",
|
|
80
80
|
compute: {
|
|
81
81
|
module: e.createShaderModule({
|
|
82
|
-
label: "rayzee:
|
|
82
|
+
label: "rayzee:neural-sr-pack",
|
|
83
83
|
code: d
|
|
84
84
|
}),
|
|
85
85
|
entryPoint: "main"
|
|
@@ -92,7 +92,7 @@ function m() {
|
|
|
92
92
|
}
|
|
93
93
|
async function h(e) {
|
|
94
94
|
let t = e?._outGPUTexture;
|
|
95
|
-
if (!t) throw Error("
|
|
95
|
+
if (!t) throw Error("NeuralSuperRes: no denoised frame — enable OIDN and finish a render first");
|
|
96
96
|
let n = e.gpuDevice, { width: r, height: i } = e._outTexSize, a = p(n, r, i), o = n.createBindGroup({
|
|
97
97
|
layout: a.pipeline.getBindGroupLayout(0),
|
|
98
98
|
entries: [{
|
|
@@ -102,7 +102,7 @@ async function h(e) {
|
|
|
102
102
|
binding: 1,
|
|
103
103
|
resource: { buffer: a.storage }
|
|
104
104
|
}]
|
|
105
|
-
}), s = n.createCommandEncoder({ label: "rayzee:
|
|
105
|
+
}), s = n.createCommandEncoder({ label: "rayzee:neural-sr-pack" }), c = s.beginComputePass();
|
|
106
106
|
c.setPipeline(a.pipeline), c.setBindGroup(0, o), c.dispatchWorkgroups(Math.ceil(r / 8), Math.ceil(i / 8)), c.end(), s.copyBufferToBuffer(a.storage, 0, a.map, 0, r * i * 8), n.queue.submit([s.finish()]), await a.map.mapAsync(GPUMapMode.READ);
|
|
107
107
|
let l = new Uint16Array(a.map.getMappedRange().slice(0));
|
|
108
108
|
return a.map.unmap(), {
|
|
@@ -131,8 +131,8 @@ var g = class e {
|
|
|
131
131
|
return this.sr.geometry.outputHeight;
|
|
132
132
|
}
|
|
133
133
|
static async create({ width: t, height: n, onProgress: r = () => {} } = {}) {
|
|
134
|
-
if (!Number.isInteger(t) || !Number.isInteger(n) || t < 1 || n < 1) throw Error("
|
|
135
|
-
if (t > 2048 || n > 2048) throw Error(`
|
|
134
|
+
if (!Number.isInteger(t) || !Number.isInteger(n) || t < 1 || n < 1) throw Error("NeuralSuperRes.create: width and height must be positive integers");
|
|
135
|
+
if (t > 2048 || n > 2048) throw Error(`NeuralSuperRes.create: input capped at ${c}px per side (${c * 2}px output), got ${t}x${n}. Above that the runtime's history plane exceeds maxTextureDimension2D and it fails later with an unrelated bind-group error.`);
|
|
136
136
|
let i = await u(), a = document.createElement("canvas");
|
|
137
137
|
a.style.cssText = "position:fixed;left:-10000px;top:0;pointer-events:none", document.body.appendChild(a);
|
|
138
138
|
let o;
|
|
@@ -155,11 +155,11 @@ var g = class e {
|
|
|
155
155
|
this._color = new Uint16Array(e * t * 4), this._depth = new Float32Array(e * t), this._motion = new Uint16Array(e * t * 2);
|
|
156
156
|
}
|
|
157
157
|
async _run(e) {
|
|
158
|
-
if (this.disposed) throw Error("
|
|
158
|
+
if (this.disposed) throw Error("NeuralSuperRes: disposed");
|
|
159
159
|
let t = this.inputWidth, n = this.inputHeight;
|
|
160
|
-
if (e.width !== t || e.height !== n) throw Error(`
|
|
160
|
+
if (e.width !== t || e.height !== n) throw Error(`NeuralSuperRes: expected a ${t}x${n} source, got ${e.width}x${e.height}`);
|
|
161
161
|
let r = this._color;
|
|
162
|
-
if (!e.half || e.half.length !== r.length) throw Error(`
|
|
162
|
+
if (!e.half || e.half.length !== r.length) throw Error(`NeuralSuperRes: expected ${r.length} packed halfs from readDenoisedHalf, got ${e.half?.length}`);
|
|
163
163
|
r.set(e.half), this._depth.fill(.5), this._motion.fill(0);
|
|
164
164
|
let i = performance.now(), a = await this.sr.render(this.slot, {
|
|
165
165
|
color: r,
|
|
@@ -175,7 +175,7 @@ var g = class e {
|
|
|
175
175
|
}
|
|
176
176
|
async upscaleToRGBA8(e, t = {}) {
|
|
177
177
|
let { result: r, ms: i } = await this._run(e), { outputWidth: a, outputHeight: o } = this.geometry;
|
|
178
|
-
this._toneMapper ??= new n(this.sr.device, "rayzee:
|
|
178
|
+
this._toneMapper ??= new n(this.sr.device, "rayzee:neural-sr-tonemap"), this._toneMapper.ensureSize(a, o);
|
|
179
179
|
let s = performance.now();
|
|
180
180
|
return {
|
|
181
181
|
rgba8: await this._toneMapper.toRGBA8(r.hdr.buffer ?? r.hdr, {
|
|
@@ -211,7 +211,7 @@ function _(e, t, n) {
|
|
|
211
211
|
e.addEventListener(i.DENOISING_END, l);
|
|
212
212
|
let u = setInterval(() => {
|
|
213
213
|
c && s(!0);
|
|
214
|
-
}, 200), d = setTimeout(() => s(!1, /* @__PURE__ */ Error("
|
|
214
|
+
}, 200), d = setTimeout(() => s(!1, /* @__PURE__ */ Error("NeuralSuperRes: timed out waiting for the render to finish")), n);
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
async function v(e, { outputWidth: t, outputHeight: n, samples: r = 64, upscaler: i = null, timeoutMs: a = 6e5, present: o = !0, onProgress: s = () => {} } = {}) {
|
|
@@ -108,8 +108,8 @@ var D = {
|
|
|
108
108
|
ocioRuntimeUrl: null,
|
|
109
109
|
ocioWasmUrl: null,
|
|
110
110
|
upscalerModelBaseUrl: "https://huggingface.co/notaneimu/onnx-image-models/resolve/main/",
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
neuralRuntimeUrl: "/neural/neural-runtime.js",
|
|
112
|
+
neuralAssetBaseUrl: null,
|
|
113
113
|
cacheNamespace: "rayzee"
|
|
114
114
|
};
|
|
115
115
|
function O(e) {
|
package/dist/rayzee.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as e, i as t, n, r } from "./
|
|
2
|
-
import { C as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, u as C, v as w, w as T, x as E, y as D } from "./ToneMapGPU-
|
|
3
|
-
import { i as O, n as k, r as A } from "./
|
|
1
|
+
import { a as e, i as t, n, r } from "./NeuralSuperRes-Dc6jRYke.js";
|
|
2
|
+
import { C as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, l as g, m as _, n as v, o as y, p as b, r as x, s as S, u as C, v as w, w as T, x as E, y as D } from "./ToneMapGPU-BVE852iN.js";
|
|
3
|
+
import { i as O, n as k, r as A } from "./NeuralRetouch-CYOJ21Wn.js";
|
|
4
4
|
import { ContextNode as ee, ExternalTexture as te, LinearSRGBColorSpace as j, MeshBasicNodeMaterial as ne, NodeMaterial as re, QuadMesh as ie, ReadbackBuffer as ae, RectAreaLightNode as oe, RenderTarget as se, SRGBColorSpace as ce, StorageInstancedBufferAttribute as le, StorageTexture as ue, TextureNode as de, WebGPUBackend as fe, WebGPURenderer as pe } from "three/webgpu";
|
|
5
5
|
import { Break as me, Fn as M, If as N, Loop as he, Return as ge, TWO_PI as _e, abs as P, acos as ve, array as ye, atan as be, atomicAdd as xe, atomicLoad as Se, atomicStore as Ce, attributeArray as we, bool as Te, clamp as F, cos as Ee, cross as De, cubeTexture as Oe, dot as I, exp as ke, exp2 as Ae, float as L, floatBitsToUint as je, floor as Me, fract as Ne, instanceIndex as Pe, int as R, ivec2 as z, ivec3 as Fe, length as Ie, lessThan as Le, localId as Re, log as ze, log2 as Be, mat3 as Ve, max as B, min as He, mix as V, mod as Ue, normalize as H, notEqual as We, packHalf2x16 as Ge, packSnorm2x16 as Ke, packUnorm2x16 as qe, pow as Je, reflect as Ye, refract as Xe, round as Ze, sampler as Qe, saturate as $e, screenCoordinate as et, select as U, sign as tt, sin as nt, smoothstep as rt, sqrt as it, storage as at, struct as ot, subgroupAdd as st, subgroupBroadcast as ct, subgroupExclusiveAdd as lt, tan as ut, texture as dt, texture3DLoad as ft, textureLoad as W, textureSize as pt, textureStore as mt, uint as G, uintBitsToFloat as ht, uniform as K, uniformArray as gt, unpackHalf2x16 as _t, unpackSnorm2x16 as vt, unpackUnorm2x16 as yt, uv as bt, uvec2 as xt, uvec4 as St, vec2 as q, vec3 as J, vec4 as Y, wgslFn as Ct, workgroupArray as wt, workgroupBarrier as Tt, workgroupId as Et } from "three/tsl";
|
|
6
6
|
import { ACESFilmicToneMapping as Dt, AddEquation as Ot, AnimationMixer as kt, BackSide as At, Box2 as jt, Box3 as Mt, BufferAttribute as Nt, BufferGeometry as Pt, ByteType as Ft, CircleGeometry as It, ClampToEdgeWrapping as Lt, Color as Rt, CustomBlending as zt, Data3DTexture as Bt, DataArrayTexture as Vt, DataTexture as Ht, DataUtils as Ut, DirectionalLight as Wt, DirectionalLightHelper as Gt, DoubleSide as Kt, EquirectangularReflectionMapping as qt, EventDispatcher as Jt, Float32BufferAttribute as Yt, FloatType as Xt, FrontSide as Zt, Group as Qt, HalfFloatType as $t, InstancedMesh as en, IntType as tn, LinearFilter as X, LinearSRGBColorSpace as nn, LoadingManager as rn, LoopOnce as an, LoopRepeat as on, MathUtils as sn, Matrix3 as cn, Matrix4 as ln, Mesh as un, MeshBasicMaterial as dn, MeshPhysicalMaterial as fn, MeshStandardMaterial as pn, NearestFilter as mn, NoBlending as hn, NoColorSpace as gn, NoToneMapping as _n, Object3D as vn, OneFactor as yn, PerspectiveCamera as bn, PointLight as xn, PointLightHelper as Sn, Points as Cn, PointsMaterial as wn, Quaternion as Tn, RGBAFormat as En, RGBFormat as Dn, RGFormat as On, Raycaster as kn, RectAreaLight as An, RedFormat as jn, RenderTarget as Mn, RepeatWrapping as Nn, SRGBColorSpace as Pn, Scene as Fn, ShortType as In, SphereGeometry as Ln, SpotLight as Rn, SpotLightHelper as zn, Texture as Bn, TextureLoader as Vn, Timer as Hn, Uint32BufferAttribute as Un, UnsignedByteType as Wn, UnsignedIntType as Gn, UnsignedShortType as Kn, Vector2 as qn, Vector3 as Jn, Vector4 as Yn } from "three";
|
|
@@ -37634,7 +37634,12 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
37634
37634
|
for (let e = 0; e < n; e++) a.copyBufferToBuffer(l, e * s, r, e * o, o);
|
|
37635
37635
|
}
|
|
37636
37636
|
};
|
|
37637
|
-
u(r.color, this._gpuInputBuffers.color), u(r.albedo, this._gpuInputBuffers.albedo), u(r.normal, this._gpuInputBuffers.normal), i.queue.submit([a.finish()]), this._computeInputScale(i, t * n), this._applyColorScale(i, t * n)
|
|
37637
|
+
u(r.color, this._gpuInputBuffers.color), u(r.albedo, this._gpuInputBuffers.albedo), u(r.normal, this._gpuInputBuffers.normal), i.queue.submit([a.finish()]), this._computeInputScale(i, t * n), this._applyColorScale(i, t * n), !e && !this._hasOutput && this._unpackToTexture(this._gpuInputBuffers.color, t, {
|
|
37638
|
+
x: 0,
|
|
37639
|
+
y: 0,
|
|
37640
|
+
width: t,
|
|
37641
|
+
height: n
|
|
37642
|
+
}, !1);
|
|
37638
37643
|
let d = {
|
|
37639
37644
|
color: {
|
|
37640
37645
|
data: this._gpuInputBuffers.color,
|
|
@@ -37859,28 +37864,28 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
37859
37864
|
height: 0
|
|
37860
37865
|
};
|
|
37861
37866
|
}
|
|
37862
|
-
_unpackToTexture(e, t, n) {
|
|
37863
|
-
let
|
|
37864
|
-
if (!
|
|
37865
|
-
let { x:
|
|
37866
|
-
if (this._ensureOutputTexture(
|
|
37867
|
-
let
|
|
37867
|
+
_unpackToTexture(e, t, n, r = !0) {
|
|
37868
|
+
let i = this.gpuDevice;
|
|
37869
|
+
if (!i || !this._ensureScalePipelines(i)) return;
|
|
37870
|
+
let { x: a, y: o, width: s, height: c } = n;
|
|
37871
|
+
if (this._ensureOutputTexture(i, this._renderWidth, this._renderHeight), !this._outGPUTexture) return;
|
|
37872
|
+
let l = i.createBuffer({
|
|
37868
37873
|
label: "oidn-unpack-params",
|
|
37869
37874
|
size: uS,
|
|
37870
37875
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
37871
37876
|
});
|
|
37872
37877
|
try {
|
|
37873
|
-
|
|
37878
|
+
i.queue.writeBuffer(l, 0, new Uint32Array([
|
|
37874
37879
|
t,
|
|
37875
|
-
i,
|
|
37876
37880
|
a,
|
|
37877
37881
|
o,
|
|
37878
37882
|
s,
|
|
37883
|
+
c,
|
|
37879
37884
|
0,
|
|
37880
37885
|
0,
|
|
37881
37886
|
0
|
|
37882
37887
|
]));
|
|
37883
|
-
let n =
|
|
37888
|
+
let n = i.createBindGroup({
|
|
37884
37889
|
label: "oidn-output-unpack",
|
|
37885
37890
|
layout: this._unpackPipeline.getBindGroupLayout(0),
|
|
37886
37891
|
entries: [
|
|
@@ -37890,7 +37895,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
37890
37895
|
},
|
|
37891
37896
|
{
|
|
37892
37897
|
binding: 1,
|
|
37893
|
-
resource: { buffer:
|
|
37898
|
+
resource: { buffer: l }
|
|
37894
37899
|
},
|
|
37895
37900
|
{
|
|
37896
37901
|
binding: 2,
|
|
@@ -37905,10 +37910,10 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
37905
37910
|
resource: this._outGPUTexture.createView()
|
|
37906
37911
|
}
|
|
37907
37912
|
]
|
|
37908
|
-
}),
|
|
37909
|
-
|
|
37913
|
+
}), u = i.createCommandEncoder({ label: "oidn-output-unpack" }), d = u.beginComputePass({ label: "oidn-output-unpack" });
|
|
37914
|
+
d.setPipeline(this._unpackPipeline), d.setBindGroup(0, n), d.dispatchWorkgroups(Math.ceil(s / lS), Math.ceil(c / lS), 1), d.end(), i.queue.submit([u.finish()]), r && (this._hasOutput = !0);
|
|
37910
37915
|
} finally {
|
|
37911
|
-
|
|
37916
|
+
l.destroy();
|
|
37912
37917
|
}
|
|
37913
37918
|
}
|
|
37914
37919
|
_executeWithAbortGPU(e, t = !1) {
|
|
@@ -38312,9 +38317,9 @@ var yS = {
|
|
|
38312
38317
|
async dispose() {
|
|
38313
38318
|
this.abort(), this._cleanupPendingWorkerHandlers(), this._worker &&= (this._worker.postMessage({ type: "dispose" }), this._worker.terminate(), null), this._currentModelUrl = null, this._backupCanvas = null, this._upscaledAlpha = null, this.state.abortController = null, this._hdrStagingBuffer?.destroy(), this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0, console.log("AIUpscaler disposed");
|
|
38314
38319
|
}
|
|
38315
|
-
}, xS = a("
|
|
38320
|
+
}, xS = a("neural"), SS = 120, CS = 2, wS = 1, TS = 0, ES = 300, DS = 5, OS = 3, kS = 3, AS = class extends Jt {
|
|
38316
38321
|
constructor({ renderer: e, mainCanvas: t, stages: n, pipeline: r, getExposure: i, getSaturation: a }) {
|
|
38317
|
-
super(), this.renderer = e, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, this.denoiser = null, this.upscaler = null, this.upscalerBackend = "esrgan", this.
|
|
38322
|
+
super(), this.renderer = e, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, this.denoiser = null, this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null, this.neuralRendering = !1, this.neuralRenderingSettings = {}, this._retouch = null, this._superResModule = null, this._neuralPostBusy = !1, this._finalQuality = Z.oidnQuality, this.finalDenoise = Z.enableOIDN, this.continuousDenoise = Z.continuousDenoise, this.continuousDenoiseInterval = Z.continuousDenoiseInterval, this._lastCadenceAt = -Infinity, this._lastCadenceSamples = 0, this._failedRefreshes = 0, this._cadenceSuspended = !1, this._movingDenoiseMs = [], this._movingHopeless = !1, this._holdWhileMoving = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._pendingCloseDenoise = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
|
|
38318
38323
|
}
|
|
38319
38324
|
_createUpscalerCanvas(e) {
|
|
38320
38325
|
let t = e.parentNode;
|
|
@@ -38354,7 +38359,12 @@ var yS = {
|
|
|
38354
38359
|
type: e.DENOISING_END,
|
|
38355
38360
|
continuous: !!t.continuous
|
|
38356
38361
|
});
|
|
38357
|
-
}, this.
|
|
38362
|
+
}, this._denoiserTileHandler = (e) => {
|
|
38363
|
+
if (e.continuous) return;
|
|
38364
|
+
this._publishOutput();
|
|
38365
|
+
let t = this.pipeline?.context;
|
|
38366
|
+
this._stages.compositor && t && this._stages.compositor.render(t);
|
|
38367
|
+
}, this.denoiser.addEventListener("start", this._denoiserStartHandler), this.denoiser.addEventListener("end", this._denoiserEndHandler), this.denoiser.addEventListener("tileProgress", this._denoiserTileHandler);
|
|
38358
38368
|
}
|
|
38359
38369
|
setupUpscaler() {
|
|
38360
38370
|
if (!this.upscalerCanvas) return;
|
|
@@ -38488,8 +38498,8 @@ var yS = {
|
|
|
38488
38498
|
this._lastCadenceSamples = 0;
|
|
38489
38499
|
}
|
|
38490
38500
|
setUpscalerBackend(e) {
|
|
38491
|
-
let t = e === "
|
|
38492
|
-
t !== this.upscalerBackend && (this.upscalerBackend = t, this._restoreRenderDisplay(), t !== "
|
|
38501
|
+
let t = e === "neural" ? "neural" : "esrgan";
|
|
38502
|
+
t !== this.upscalerBackend && (this.upscalerBackend = t, this._restoreRenderDisplay(), t !== "neural" && this._releaseNeuralUpscaler());
|
|
38493
38503
|
}
|
|
38494
38504
|
_restoreRenderDisplay() {
|
|
38495
38505
|
let e = this.upscalerCanvas && this.upscalerCanvas.style.display !== "none";
|
|
@@ -38499,20 +38509,20 @@ var yS = {
|
|
|
38499
38509
|
height: this._lastRenderHeight
|
|
38500
38510
|
}), !!e;
|
|
38501
38511
|
}
|
|
38502
|
-
|
|
38503
|
-
this.
|
|
38512
|
+
_releaseNeuralUpscaler() {
|
|
38513
|
+
this._neuralUpscaler?.dispose(), this._neuralUpscaler = null, this._superResModule?.releaseDenoisedReader();
|
|
38504
38514
|
}
|
|
38505
38515
|
setNeuralRendering(e, t = null) {
|
|
38506
38516
|
this.neuralRendering = !!e, t && (this.neuralRenderingSettings = {
|
|
38507
38517
|
...this.neuralRenderingSettings,
|
|
38508
38518
|
...t
|
|
38509
|
-
}), this.neuralRendering || (this.
|
|
38519
|
+
}), this.neuralRendering || (this._releaseNeuralRetouch(), this._restoreRenderDisplay());
|
|
38510
38520
|
}
|
|
38511
|
-
|
|
38512
|
-
this.
|
|
38521
|
+
_releaseNeuralRetouch() {
|
|
38522
|
+
this._retouch?.dispose(), this._retouch = null;
|
|
38513
38523
|
}
|
|
38514
38524
|
async _runNeuralPost(t) {
|
|
38515
|
-
let n = this.upscaler?.enabled && this.upscalerBackend === "
|
|
38525
|
+
let n = this.upscaler?.enabled && this.upscalerBackend === "neural", r = this.neuralRendering;
|
|
38516
38526
|
if (!(!n && !r) && !this._neuralPostBusy) {
|
|
38517
38527
|
if (!this.upscalerCanvas) {
|
|
38518
38528
|
xS.warn("neural pass skipped: the engine has no overlay canvas to present on");
|
|
@@ -38524,16 +38534,16 @@ var yS = {
|
|
|
38524
38534
|
}
|
|
38525
38535
|
this._neuralPostBusy = !0, this.dispatchEvent({ type: e.UPSCALING_START });
|
|
38526
38536
|
try {
|
|
38527
|
-
let e = await import("./
|
|
38528
|
-
this.
|
|
38529
|
-
let i = r ? await import("./
|
|
38530
|
-
if (r && !s && (xS.warn(`Neural rendering skipped: the render is ${(o / 1e6).toFixed(1)} MP, above the ${(i.
|
|
38537
|
+
let e = await import("./NeuralSuperRes-Dc6jRYke.js").then((e) => e.t);
|
|
38538
|
+
this._superResModule = e;
|
|
38539
|
+
let i = r ? await import("./NeuralRetouch-CYOJ21Wn.js").then((e) => e.t) : null, a = this.denoiser?._outTexSize, o = (a?.width ?? 0) * (a?.height ?? 0), s = r && o <= i.RETOUCH_MAX_PIXELS;
|
|
38540
|
+
if (r && !s && (xS.warn(`Neural rendering skipped: the render is ${(o / 1e6).toFixed(1)} MP, above the ${(i.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (n ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !n && !s) return;
|
|
38531
38541
|
let c = {
|
|
38532
38542
|
exposure: this._getEffectiveExposure(),
|
|
38533
38543
|
toneMapping: this._getToneMapping(),
|
|
38534
38544
|
saturation: this._getSaturation?.() ?? 1
|
|
38535
38545
|
}, l = await e.readDenoisedHalf(this.denoiser);
|
|
38536
|
-
n && (this.
|
|
38546
|
+
n && (this._neuralUpscaler && (this._neuralUpscaler.inputWidth !== l.width || this._neuralUpscaler.inputHeight !== l.height) && this._releaseNeuralUpscaler(), this._neuralUpscaler ||= await e.NeuralSuperRes.create({
|
|
38537
38547
|
width: l.width,
|
|
38538
38548
|
height: l.height
|
|
38539
38549
|
}));
|
|
@@ -38542,13 +38552,13 @@ var yS = {
|
|
|
38542
38552
|
let e = await i.enhanceFrame({
|
|
38543
38553
|
source: u,
|
|
38544
38554
|
settings: this.neuralRenderingSettings,
|
|
38545
|
-
instance: this.
|
|
38555
|
+
instance: this._retouch,
|
|
38546
38556
|
exposure: c.exposure,
|
|
38547
38557
|
tone: n ? null : c
|
|
38548
38558
|
});
|
|
38549
|
-
this.
|
|
38559
|
+
this._retouch = e.instance, u = e;
|
|
38550
38560
|
}
|
|
38551
|
-
if (n && (u = await this.
|
|
38561
|
+
if (n && (u = await this._neuralUpscaler.upscaleToRGBA8(u, c)), !t()) {
|
|
38552
38562
|
this.dropDisplay();
|
|
38553
38563
|
return;
|
|
38554
38564
|
}
|
|
@@ -38572,7 +38582,7 @@ var yS = {
|
|
|
38572
38582
|
this._cleanupCompletionListener();
|
|
38573
38583
|
let n = this.finalDenoise ? "final" : this.continuousDenoise ? "refresh" : null, r = () => {
|
|
38574
38584
|
if (this.denoiser?.removeEventListener("end", r), this._pendingStartUpscaler = null, e()) {
|
|
38575
|
-
if (n && this._onDisplayRefresh?.(), this.neuralRendering || this.upscaler?.enabled && this.upscalerBackend === "
|
|
38585
|
+
if (n && this._onDisplayRefresh?.(), this.neuralRendering || this.upscaler?.enabled && this.upscalerBackend === "neural") {
|
|
38576
38586
|
this._runNeuralPost(e);
|
|
38577
38587
|
return;
|
|
38578
38588
|
}
|
|
@@ -38602,7 +38612,7 @@ var yS = {
|
|
|
38602
38612
|
this._unpublishOutput(), this._restoreRenderDisplay();
|
|
38603
38613
|
}
|
|
38604
38614
|
dispose() {
|
|
38605
|
-
this._cleanupCompletionListener(), this.
|
|
38615
|
+
this._cleanupCompletionListener(), this._releaseNeuralUpscaler(), this._releaseNeuralRetouch(), this._unpublishOutput(), this.denoiser &&= (this._denoiserStartHandler && this.denoiser.removeEventListener("start", this._denoiserStartHandler), this._denoiserEndHandler && this.denoiser.removeEventListener("end", this._denoiserEndHandler), this._denoiserTileHandler && this.denoiser.removeEventListener("tileProgress", this._denoiserTileHandler), this.denoiser.dispose(), null), this.upscaler && (this._upscalerResChangedHandler && this.upscaler.removeEventListener("resolution_changed", this._upscalerResChangedHandler), this._upscalerStartHandler && this.upscaler.removeEventListener("start", this._upscalerStartHandler), this._upscalerProgressHandler && this.upscaler.removeEventListener("progress", this._upscalerProgressHandler), this._upscalerEndHandler && this.upscaler.removeEventListener("end", this._upscalerEndHandler), this.upscaler.dispose(), this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null), this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this.upscalerCanvas?.parentNode && (this.upscalerCanvas.parentNode.removeChild(this.upscalerCanvas), this.upscalerCanvas = null);
|
|
38606
38616
|
}
|
|
38607
38617
|
setOverlayManager(e) {
|
|
38608
38618
|
this._overlayManager = e;
|
|
@@ -40370,4 +40380,4 @@ var $S = class {
|
|
|
40370
40380
|
}
|
|
40371
40381
|
};
|
|
40372
40382
|
//#endregion
|
|
40373
|
-
export { Ni as AF_DEFAULTS, Ti as ASVGF_QUALITY_PRESETS, Mi as AUTO_FOCUS_MODES, BS as AnimationManager, Gi as BVH_LEAF_MARKERS, ji as CAMERA_PRESETS, ki as CAMERA_RANGES, Ix as CameraManager, Uc as ColorManagement, $s as DEFAULT_LUT_SIZE, Qs as DEFAULT_MAX_EV, Zs as DEFAULT_MIN_EV, oa as DEFAULT_TEXTURE_MATRIX, Fc as DEFAULT_WORKING_SPACE,
|
|
40383
|
+
export { Ni as AF_DEFAULTS, Ti as ASVGF_QUALITY_PRESETS, Mi as AUTO_FOCUS_MODES, BS as AnimationManager, Gi as BVH_LEAF_MARKERS, ji as CAMERA_PRESETS, ki as CAMERA_RANGES, Ix as CameraManager, Uc as ColorManagement, $s as DEFAULT_LUT_SIZE, Qs as DEFAULT_MAX_EV, Zs as DEFAULT_MIN_EV, oa as DEFAULT_TEXTURE_MATRIX, Fc as DEFAULT_WORKING_SPACE, AS as DenoisingManager, Z as ENGINE_DEFAULTS, e as EngineEvents, Da as EngineIssueError, Rx as GoboManager, Yx as IESManager, ca as INTERACTIVE_RENDER_CONFIG, Ta as ISSUE_CODES, Ea as ISSUE_SEVERITY, iy as InteractionManager, Oa as IssueLog, l as LOG_LEVELS, Lx as LightManager, E as Logger, Bi as MATERIAL_DEFAULTS, Ra as MATERIAL_VALUE_SOURCE, Si as MAX_RESERVABLE_RENDER_SIZE, Ep as MAX_SCENE_BYTES, x as MAX_TABLE_TRANSFORMS, ua as MEMORY_CONSTANTS, jp as MemoryLedger, Ei as NRD_DEFAULTS, yi as NRD_HIT_DIST_A, bi as NRD_HIT_DIST_B, Di as NRD_PRESET_KEYS, Oi as NRD_QUALITY_PRESETS, h as OCIO_VIEW_BASE, zS as OverlayManager, sa as PRODUCTION_RENDER_CONFIG, YS as PathTracerApp, Hv as PipelineContext, gi as RENDER_PROFILES, k as RETOUCH_DEFAULTS, A as RETOUCH_MAX_PIXELS, O as RETOUCH_RANGES, ey as RenderPipeline, cy as RenderSettings, $r as RenderStage, Tp as SAFE_SCENE_BYTES, oy as SETTING_SOURCE, Ai as SKY_PRESETS, n as SR_MAX_INPUT, r as SR_SCALE, Qr as StageExecutionMode, Ji as TEXTURE_CONSTANTS, Pi as TRIANGLE_DATA_LAYOUT, HS as TransformManager, c as VIEW_TRANSFORMS, Mh as VRAMTracker, $S as VideoRenderManager, uc as addAllOcioViews, lc as addOcioView, y as addViewTransform, Fs as applyMatrixRGBA8, Hs as bakeLut, Ah as bufferBytes, oc as buildOcioView, S as buildToneMapWGSL, zc as canvasColorSpaceFor, ZS as captureHeadless, Yv as clearBindingAuditFindings, Tc as clearInputOverrides, w as configureAssets, Ss as convertColor, As as convertEncodedRGBA8, Cs as convertPixelsF32, a as createLogger, Ha as deriveAlphaMode, JS as describeAdapter, Uo as displayCanvasFit, kp as estimateSceneBytes, Is as extractMatrix, Tx as extractSceneMetadata, Hc as findNativeLinearSpace, i as fmt, Lc as getActiveColorManagement, D as getAssetConfig, Jv as getBindingAuditFindings, g as getRegistryVersion, _i as getRenderProfile, C as getViewTransform, Rs as hasColorSpace, Wc as isColorManaged, Ls as isDataSpace, jc as isDataTexture, Es as linearToSrgb, Oc as listFileRules, Ec as listInputOverrides, d as listViewTransforms, Js as makeCpuSampler, Xs as measureBakeError, b as onRegistryChange, QS as openHeadless, wx as parseSceneMetadata, Ap as probeAddressSpace, p as removeViewTransform, XS as renderHeadless, t as renderUpscaled, Ac as resolveInputSpace, Rc as setActiveColorManagement, qv as setBindingAudit, wc as setInputOverride, Ts as srgbToLinear, jh as textureBytes, Pc as textureInputSpace };
|