rayzee 9.3.2 → 9.4.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 +8 -3
- package/dist/{NeuralRetouch-CYgkQY8Z.js → NeuralRetouch-vkdXXyK2.js} +1 -1
- package/dist/{NeuralSuperRes-PkgDLQcD.js → NeuralSuperRes-FVqRJKQV.js} +1 -1
- package/dist/{ToneMapGPU-B6XIe3DU.js → ToneMapGPU-DKQM1pMd.js} +86 -78
- package/dist/rayzee.es.js +3600 -3370
- package/dist/rayzee.umd.js +124 -95
- package/package.json +1 -1
- package/src/EngineIssues.js +1 -0
- package/src/Passes/AIUpscaler.js +58 -141
- package/src/Passes/OIDNDenoiser.js +92 -65
- package/src/PathTracerApp.js +27 -15
- package/src/Processor/BVHRefitter.js +64 -0
- package/src/Processor/SceneProcessor.js +27 -5
- package/src/Processor/TextureCreator.js +170 -6
- package/src/Processor/ToneMapGPU.js +64 -15
- package/src/Processor/Workers/BVHRefitWorker.js +5 -2
- package/src/Processor/Workers/TexturesWorker.js +98 -12
- package/src/Stages/PathTracer.js +13 -2
- package/src/Stages/PathTracerStage.js +48 -46
- package/src/Storage/StorageManager.js +43 -5
- package/src/managers/AnimationManager.js +36 -5
- package/src/managers/GoboManager.js +9 -0
- package/src/managers/UniformManager.js +30 -7
package/README.md
CHANGED
|
@@ -831,6 +831,7 @@ surface** — pin a version and branch on the strings; they are never renamed or
|
|
|
831
831
|
| `refit.shared_geometry` | a deform was asked for on a mesh that shares its triangles, and was skipped |
|
|
832
832
|
| `denoiser.unavailable` | a requested denoise or upscale produced nothing — the denoiser was not built, OIDN was off while accumulating, or the pass needs a canvas in a document |
|
|
833
833
|
| `output.source_fallback` | `renderToBuffer( { source: 'display' } )` found no denoised picture and returned the raw accumulation |
|
|
834
|
+
| `output.tonemap_fallback` | `renderToBuffer`'s `'srgb'` bytes were tone-mapped on the CPU, not the GPU — the picture is the same within a level, only slower (a warning: strict does not throw) |
|
|
834
835
|
| `light.placeholder_skipped` | a `RectAreaLightPlaceholder` node lacked `userData.name` or `userData.type: 'RectAreaLight'`, so no light was made for it |
|
|
835
836
|
|
|
836
837
|
`asset.unreachable` also covers what the engine fetches for itself: OIDN weights, IES profiles and
|
|
@@ -1045,7 +1046,9 @@ it back with `renderToBuffer( { source: 'display' } )`. Driving it yourself is t
|
|
|
1045
1046
|
`'display'` was asked for, a denoiser is in use, and nothing had published — so a strict host cannot
|
|
1046
1047
|
ship a noisy image by mistake. Its `'srgb'` bytes are tone-mapped on the GPU — 9 ms at 4096×2160,
|
|
1047
1048
|
where the CPU pass it replaced took 1.4 s on an M-series Mac and 10 s on a cloud host — and match the
|
|
1048
|
-
canvas to within one level (it rounds half a level up); `'linear'` is exact.
|
|
1049
|
+
canvas to within one level (it rounds half a level up); `'linear'` is exact. When the GPU pass is
|
|
1050
|
+
unavailable or fails, the CPU does it instead: the result's `toneMappedOn` says `'cpu'` rather than
|
|
1051
|
+
`'gpu'`, and `output.tonemap_fallback` is recorded with the reason.
|
|
1049
1052
|
|
|
1050
1053
|
Constructing `PathTracerApp` yourself instead: pass `strict: true`; storage is then off unless you
|
|
1051
1054
|
set it. Outside Chrome, pass `hostMemoryGB`.
|
|
@@ -1053,8 +1056,10 @@ set it. Outside Chrome, pass `hostMemoryGB`.
|
|
|
1053
1056
|
**Provenance.** `engine.getProvenance()` — also `frame.provenance` from `captureHeadless` — is plain
|
|
1054
1057
|
JSON naming what produced the image: engine and three.js versions, the profile by name *and* by
|
|
1055
1058
|
value, the adapter, every live setting with its source, the colour pipeline, the render size and
|
|
1056
|
-
samples, and whether it ran headless, strict, deterministic or lockstepped.
|
|
1057
|
-
|
|
1059
|
+
samples, and whether it ran headless, strict, deterministic or lockstepped. `mode.lockstep` says
|
|
1060
|
+
whether the current image was traced in lockstep, so it stays true after `renderUntilComplete` turns
|
|
1061
|
+
lockstep back off. Store it beside each render and "what made this?" has an answer without rendering
|
|
1062
|
+
again.
|
|
1058
1063
|
|
|
1059
1064
|
**Pinning a look.** A change to what a render looks like when a host sets nothing — a default
|
|
1060
1065
|
setting, a mode preset, a profile's values, light units — is released as a **major**, with the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
|
|
2
|
-
import { C as t, t as n, y as r } from "./ToneMapGPU-
|
|
2
|
+
import { C as t, t as n, y as r } from "./ToneMapGPU-DKQM1pMd.js";
|
|
3
3
|
//#region src/neural/NeuralRetouch.js
|
|
4
4
|
var i = /* @__PURE__ */ e({
|
|
5
5
|
NeuralRetouch: () => m,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CAFD8bLK.js";
|
|
2
|
-
import { C as t, t as n, y as r } from "./ToneMapGPU-
|
|
2
|
+
import { C as t, t as n, y as r } from "./ToneMapGPU-DKQM1pMd.js";
|
|
3
3
|
//#region src/EngineEvents.js
|
|
4
4
|
var i = {
|
|
5
5
|
RENDER_COMPLETE: "engine:renderComplete",
|
|
@@ -140,12 +140,12 @@ function re(e, t, n, r, i) {
|
|
|
140
140
|
let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
|
|
141
141
|
i[0] = a(e), i[1] = a(t), i[2] = a(n);
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function ie(e, t, n, r, i) {
|
|
144
144
|
e = e * r / .6, t = t * r / .6, n = n * r / .6;
|
|
145
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
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
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function N(e, t, n, r, i) {
|
|
149
149
|
e *= r, t *= r, n *= r;
|
|
150
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
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);
|
|
@@ -157,7 +157,7 @@ function P(e, t, n, r, i) {
|
|
|
157
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
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
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function P(e, t, n, r, i) {
|
|
161
161
|
let a = .76;
|
|
162
162
|
e *= r, t *= r, n *= r;
|
|
163
163
|
let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
|
|
@@ -172,7 +172,7 @@ function F(e, t, n, r, i) {
|
|
|
172
172
|
let f = 1 - 1 / (.15 * (c - u) + 1);
|
|
173
173
|
i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
|
|
174
174
|
}
|
|
175
|
-
var
|
|
175
|
+
var F = [
|
|
176
176
|
{
|
|
177
177
|
id: a,
|
|
178
178
|
name: "None",
|
|
@@ -210,7 +210,7 @@ var I = [
|
|
|
210
210
|
id: e,
|
|
211
211
|
name: "ACES Filmic",
|
|
212
212
|
wgslConst: "TM_ACES",
|
|
213
|
-
cpu:
|
|
213
|
+
cpu: ie,
|
|
214
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
215
|
call: "tm_aces( c )"
|
|
216
216
|
},
|
|
@@ -218,7 +218,7 @@ var I = [
|
|
|
218
218
|
id: t,
|
|
219
219
|
name: "AgX",
|
|
220
220
|
wgslConst: "TM_AGX",
|
|
221
|
-
cpu:
|
|
221
|
+
cpu: N,
|
|
222
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
223
|
call: "tm_agx( c )"
|
|
224
224
|
},
|
|
@@ -226,7 +226,7 @@ var I = [
|
|
|
226
226
|
id: i,
|
|
227
227
|
name: "Neutral",
|
|
228
228
|
wgslConst: "TM_NEUTRAL",
|
|
229
|
-
cpu:
|
|
229
|
+
cpu: P,
|
|
230
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
231
|
call: "tm_neutral( c )"
|
|
232
232
|
}
|
|
@@ -235,23 +235,23 @@ var I = [
|
|
|
235
235
|
outputEncoded: !1,
|
|
236
236
|
appliesExposure: !0,
|
|
237
237
|
...e
|
|
238
|
-
})),
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
for (let e of
|
|
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
242
|
}
|
|
243
|
-
var
|
|
244
|
-
function
|
|
245
|
-
return
|
|
243
|
+
var U = z;
|
|
244
|
+
function W() {
|
|
245
|
+
return B;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
return
|
|
247
|
+
function G(e) {
|
|
248
|
+
return V.add(e), () => V.delete(e);
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
return
|
|
250
|
+
function K(e) {
|
|
251
|
+
return z.get(e) ?? null;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
253
|
+
function q() {
|
|
254
|
+
return R.map((e) => ({
|
|
255
255
|
id: e.id,
|
|
256
256
|
name: e.name,
|
|
257
257
|
source: e.source,
|
|
@@ -260,52 +260,52 @@ function J() {
|
|
|
260
260
|
look: e.ocio?.look ?? null
|
|
261
261
|
}));
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
return
|
|
263
|
+
function J() {
|
|
264
|
+
return R.filter((e) => e.table).length;
|
|
265
265
|
}
|
|
266
|
-
function
|
|
266
|
+
function ae() {
|
|
267
267
|
let e = 200;
|
|
268
|
-
for (;
|
|
268
|
+
for (; z.has(e);) e++;
|
|
269
269
|
return e;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function oe(e) {
|
|
272
272
|
if (typeof e?.id != "number") throw Error("view transform needs a numeric id");
|
|
273
273
|
if (typeof e.cpu != "function") throw Error(`view transform ${e.id} needs a cpu function`);
|
|
274
274
|
if (!e.name) throw Error(`view transform ${e.id} needs a name`);
|
|
275
275
|
if (!/^TM_[A-Z0-9_]+$/.test(e.wgslConst ?? "")) throw Error(`view transform ${e.id} needs a wgslConst like TM_SOMETHING`);
|
|
276
|
-
let t =
|
|
277
|
-
if (!t && e.table &&
|
|
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
278
|
let n = {
|
|
279
279
|
source: "custom",
|
|
280
280
|
outputEncoded: !1,
|
|
281
281
|
appliesExposure: !0,
|
|
282
282
|
...e
|
|
283
283
|
};
|
|
284
|
-
return t ?
|
|
284
|
+
return t ? R[R.indexOf(t)] = n : R.push(n), z.set(n.id, n), H(), n;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
let t =
|
|
288
|
-
return t ? (
|
|
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
289
|
}
|
|
290
|
-
function
|
|
291
|
-
let t =
|
|
290
|
+
function ce(e = null) {
|
|
291
|
+
let t = R.filter((t) => t.source === "ocio" && !e?.has(t.id)).map((e) => e.id);
|
|
292
292
|
if (t.length === 0) return 0;
|
|
293
293
|
for (let e of t) {
|
|
294
|
-
let t =
|
|
295
|
-
|
|
294
|
+
let t = z.get(e);
|
|
295
|
+
R.splice(R.indexOf(t), 1), z.delete(e);
|
|
296
296
|
}
|
|
297
|
-
return
|
|
297
|
+
return H(), t.length;
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function le(e) {
|
|
300
300
|
let t = e?.library;
|
|
301
301
|
if (!t?.addToneMapping) return 0;
|
|
302
302
|
let n = 0;
|
|
303
|
-
for (let e of
|
|
303
|
+
for (let e of R) e.tsl && (t.toneMappingNodes?.delete(e.id), t.addToneMapping(e.tsl, e.id), n++);
|
|
304
304
|
return n;
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function Y({ group: e = 0, firstBinding: t = 3 } = {}) {
|
|
307
307
|
let n = [], r = t, i = [], a = [];
|
|
308
|
-
for (let t of
|
|
308
|
+
for (let t of R) {
|
|
309
309
|
if (t.table) {
|
|
310
310
|
let a = `${t.wgslConst.toLowerCase()}_tex`;
|
|
311
311
|
i.push(`@group(${e}) @binding(${r}) var ${a}: texture_3d<f32>;`), n.push({
|
|
@@ -316,7 +316,7 @@ function X({ group: e = 0, firstBinding: t = 3 } = {}) {
|
|
|
316
316
|
}
|
|
317
317
|
t.wgsl && a.push(t.wgsl);
|
|
318
318
|
}
|
|
319
|
-
let o =
|
|
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
320
|
return {
|
|
321
321
|
wgsl: `
|
|
322
322
|
${o}
|
|
@@ -370,28 +370,34 @@ fn rayzee_to_u8( srgb: vec3<f32> ) -> vec3<u32> {
|
|
|
370
370
|
bindings: n
|
|
371
371
|
};
|
|
372
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;
|
|
373
379
|
function Z() {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
var le = a, ue = 0, de = 3;
|
|
379
|
-
function Q() {
|
|
380
|
-
let { wgsl: e, bindings: t } = X({
|
|
381
|
-
group: ue,
|
|
382
|
-
firstBinding: de
|
|
380
|
+
let { wgsl: e, bindings: t } = Y({
|
|
381
|
+
group: de,
|
|
382
|
+
firstBinding: fe
|
|
383
383
|
});
|
|
384
384
|
return {
|
|
385
385
|
wgsl: e,
|
|
386
386
|
bindings: t,
|
|
387
|
-
version:
|
|
387
|
+
version: W()
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
|
|
391
|
-
var
|
|
390
|
+
Z().wgsl;
|
|
391
|
+
var pe = {
|
|
392
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
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
|
-
},
|
|
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) => `
|
|
395
401
|
struct Params {
|
|
396
402
|
width: u32,
|
|
397
403
|
height: u32,
|
|
@@ -402,11 +408,11 @@ struct Params {
|
|
|
402
408
|
alpha: u32,
|
|
403
409
|
};
|
|
404
410
|
|
|
405
|
-
@group(0) @binding(1) var<storage, read_write> dst: array<u32>;
|
|
406
411
|
@group(0) @binding(2) var<uniform> params: Params;
|
|
407
|
-
${
|
|
412
|
+
${pe[t]}
|
|
408
413
|
|
|
409
414
|
${e}
|
|
415
|
+
${me[n]}
|
|
410
416
|
|
|
411
417
|
@compute @workgroup_size(8, 8)
|
|
412
418
|
fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
@@ -416,25 +422,21 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
416
422
|
if ( params.flipY == 1u ) { srcY = params.height - 1u - gid.y; }
|
|
417
423
|
|
|
418
424
|
let linear = rayzee_source( gid.x, srcY );
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
`, $ = 32, me = class {
|
|
426
|
-
constructor(e, t = "rayzee:tonemap", { input: n = "packed" } = {}) {
|
|
427
|
-
this.device = e, this.label = t, this.input = n, 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;
|
|
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;
|
|
428
430
|
}
|
|
429
431
|
_ensurePipeline() {
|
|
430
|
-
let { wgsl: e, bindings: t, version: n } =
|
|
432
|
+
let { wgsl: e, bindings: t, version: n } = Z();
|
|
431
433
|
this._pipeline && this._shaderVersion === n || (this._bindings = t, this._shaderVersion = n, this._pipeline = this.device.createComputePipeline({
|
|
432
434
|
label: this.label,
|
|
433
435
|
layout: "auto",
|
|
434
436
|
compute: {
|
|
435
437
|
module: this.device.createShaderModule({
|
|
436
438
|
label: this.label,
|
|
437
|
-
code:
|
|
439
|
+
code: he(e, this.input, this.output)
|
|
438
440
|
}),
|
|
439
441
|
entryPoint: "main"
|
|
440
442
|
}
|
|
@@ -477,7 +479,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
477
479
|
ensureSize(e, t) {
|
|
478
480
|
if (this._ensurePipeline(), this._ensureTables(), this.width === e && this.height === t && this._storage) return;
|
|
479
481
|
this._releaseBuffers();
|
|
480
|
-
let n = e * t *
|
|
482
|
+
let n = e * t * Q[this.output];
|
|
481
483
|
this._storage = this.device.createBuffer({
|
|
482
484
|
label: `${this.label}-out`,
|
|
483
485
|
size: n,
|
|
@@ -492,19 +494,25 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
492
494
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
493
495
|
}), this.width = e, this.height = t;
|
|
494
496
|
}
|
|
495
|
-
async toRGBA8(e,
|
|
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 } = {}) {
|
|
496
504
|
if (this.disposed) throw Error("PackedToneMapper: disposed");
|
|
497
505
|
if (!this._storage) throw Error("PackedToneMapper: call ensureSize() first");
|
|
498
506
|
this._ensurePipeline(), this._ensureTables();
|
|
499
|
-
let { width: o, height: s } = this;
|
|
507
|
+
let { width: o, height: s } = this, c = o * s * Q[this.output];
|
|
500
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);
|
|
501
|
-
let
|
|
509
|
+
let l = [...this._tables.entries()].map(([e, t]) => ({
|
|
502
510
|
binding: e,
|
|
503
511
|
resource: t.view
|
|
504
|
-
})),
|
|
512
|
+
})), u = this.device.createBindGroup({
|
|
505
513
|
layout: this._pipeline.getBindGroupLayout(0),
|
|
506
514
|
entries: [
|
|
507
|
-
...
|
|
515
|
+
...l,
|
|
508
516
|
{
|
|
509
517
|
binding: 0,
|
|
510
518
|
resource: this.input === "texture" ? e.createView() : {
|
|
@@ -521,10 +529,10 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
521
529
|
resource: { buffer: this._params }
|
|
522
530
|
}
|
|
523
531
|
]
|
|
524
|
-
}),
|
|
525
|
-
|
|
526
|
-
let
|
|
527
|
-
return this._map.unmap(),
|
|
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;
|
|
528
536
|
}
|
|
529
537
|
release() {
|
|
530
538
|
this._releaseBuffers(), this.width = this.height = 0;
|
|
@@ -541,4 +549,4 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
|
|
|
541
549
|
}
|
|
542
550
|
};
|
|
543
551
|
//#endregion
|
|
544
|
-
export { C, E, S, T,
|
|
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 };
|