rayzee 4.8.11 → 4.8.13

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 CHANGED
@@ -540,6 +540,30 @@ OIDN provides high-quality AI denoising for final renders. It runs automatically
540
540
 
541
541
  ## Troubleshooting
542
542
 
543
+ **OIDN: `Cannot find module './tza'` (webpack)**
544
+ The `oidn-web` package uses dynamic imports that webpack cannot resolve. This does not affect Vite or other ESM-native bundlers. Add `oidn-web` to your webpack externals:
545
+
546
+ ```js
547
+ // webpack.config.js
548
+ module.exports = {
549
+ externals: {
550
+ 'oidn-web': 'oidn-web'
551
+ }
552
+ };
553
+ ```
554
+
555
+ Then load it via a script tag or import map instead:
556
+
557
+ ```html
558
+ <script type="importmap">
559
+ {
560
+ "imports": {
561
+ "oidn-web": "https://cdn.jsdelivr.net/npm/oidn-web@0.3.0/+esm"
562
+ }
563
+ }
564
+ </script>
565
+ ```
566
+
543
567
  **Black screen / "WebGPU not supported"**
544
568
  Your browser may not support WebGPU. Use Chrome 113+, Edge 113+, Safari 18+, or Firefox 141+. Ensure you're on HTTPS or localhost.
545
569
 
package/dist/rayzee.es.js CHANGED
@@ -2181,10 +2181,10 @@ var Xr = X("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3
2181
2181
  let t = z(1).sub(o).sub(s), r = $(n, a, B(6), B(ui)), c = $(n, a, B(7), B(ui));
2182
2182
  i.uv.assign(r.xy.mul(t).add(r.zw.mul(o)).add(c.xy.mul(s))), i.triangleIndex.assign(a);
2183
2183
  }), i;
2184
- }), bi = M(([e, t, n, r]) => {
2185
- let i = Tr({
2184
+ }), bi = M(([e, t, n, r, i]) => {
2185
+ let a = Tr({
2186
2186
  didHit: !1,
2187
- dst: z(0x56bc75e2d63100000),
2187
+ dst: i,
2188
2188
  hitPoint: J(0),
2189
2189
  normal: J(0),
2190
2190
  uv: q(0),
@@ -2192,62 +2192,62 @@ var Xr = X("\n fn constructTBN( N: vec3f ) -> mat3x3f {\n\n var majorAxis: vec3
2192
2192
  meshIndex: B(-1),
2193
2193
  boxTests: B(0),
2194
2194
  triTests: B(0)
2195
- }).toVar(), a = fi(), o = B(1).toVar();
2196
- a.element(B(0)).assign(B(0));
2197
- let s = H(J(1), pt(e.direction), ct(e.direction, J(0))), c = H(J(1).div(e.direction), J(di).mul(s), nt(F(e.direction), J(1e-8))).toVar(), l = B(0).toVar();
2198
- return P(o.greaterThan(B(0)).and(i.didHit.not()).and(l.lessThan(B(ci))), () => {
2199
- l.addAssign(1), o.subAssign(1);
2200
- let s = a.element(o).toVar(), u = $(t, s, B(0), B(li));
2201
- N(u.w.lessThan(0), () => {
2202
- N(u.w.greaterThan(z(-1.5)), () => {
2203
- let t = B(u.x).toVar(), a = B(u.y).toVar();
2195
+ }).toVar(), o = fi(), s = B(1).toVar();
2196
+ o.element(B(0)).assign(B(0));
2197
+ let c = H(J(1), pt(e.direction), ct(e.direction, J(0))), l = H(J(1).div(e.direction), J(di).mul(c), nt(F(e.direction), J(1e-8))).toVar(), u = B(0).toVar();
2198
+ return P(s.greaterThan(B(0)).and(a.didHit.not()).and(u.lessThan(B(ci))), () => {
2199
+ u.addAssign(1), s.subAssign(1);
2200
+ let i = o.element(s).toVar(), c = $(t, i, B(0), B(li));
2201
+ N(c.w.lessThan(0), () => {
2202
+ N(c.w.greaterThan(z(-1.5)), () => {
2203
+ let t = B(c.x).toVar(), i = B(c.y).toVar();
2204
2204
  P({
2205
2205
  start: B(0),
2206
- end: a
2207
- }, ({ i: a }) => {
2208
- let o = t.add(a).toVar(), s = $(n, o, B(0), B(ui)).xyz, c = $(n, o, B(1), B(ui)).xyz, l = $(n, o, B(2), B(ui)).xyz, u = pi({
2206
+ end: i
2207
+ }, ({ i }) => {
2208
+ let o = t.add(i).toVar(), s = $(n, o, B(0), B(ui)).xyz, c = $(n, o, B(1), B(ui)).xyz, l = $(n, o, B(2), B(ui)).xyz, u = pi({
2209
2209
  rayOrigin: e.origin,
2210
2210
  rayDir: e.direction,
2211
2211
  pA: s,
2212
2212
  pB: c,
2213
2213
  pC: l,
2214
- closestHitDst: i.dst
2214
+ closestHitDst: a.dst
2215
2215
  });
2216
2216
  N(u.w.greaterThan(.5), () => {
2217
- let t = $(n, o, B(7), B(ui)), a = B(t.z);
2218
- N(gi(a, r), () => {
2219
- i.didHit.assign(!0), i.dst.assign(u.x), i.materialIndex.assign(a), i.meshIndex.assign(B(t.w)), i.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), i.normal.assign(U(Xe(c.sub(s), l.sub(s)))), He();
2217
+ let t = $(n, o, B(7), B(ui)), i = B(t.z);
2218
+ N(gi(i, r), () => {
2219
+ a.didHit.assign(!0), a.dst.assign(u.x), a.materialIndex.assign(i), a.meshIndex.assign(B(t.w)), a.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), a.normal.assign(U(Xe(c.sub(s), l.sub(s)))), He();
2220
2220
  });
2221
2221
  });
2222
2222
  });
2223
2223
  }).Else(() => {
2224
- let e = B(u.x).toVar();
2225
- N(o.lessThan(B(si)), () => {
2226
- a.element(o).assign(e), o.addAssign(1);
2224
+ let e = B(c.x).toVar();
2225
+ N(s.lessThan(B(si)), () => {
2226
+ o.element(s).assign(e), s.addAssign(1);
2227
2227
  });
2228
2228
  });
2229
2229
  }).Else(() => {
2230
- let n = $(t, s, B(1), B(li)), r = $(t, s, B(2), B(li)), l = $(t, s, B(3), B(li)), d = B(u.w).toVar(), f = B(n.w).toVar(), p = mi({
2230
+ let n = $(t, i, B(1), B(li)), r = $(t, i, B(2), B(li)), u = $(t, i, B(3), B(li)), d = B(c.w).toVar(), f = B(n.w).toVar(), p = mi({
2231
2231
  rayOrigin: e.origin,
2232
- invDir: c,
2233
- boxMin: u.xyz,
2232
+ invDir: l,
2233
+ boxMin: c.xyz,
2234
2234
  boxMax: n.xyz
2235
2235
  }).toVar(), m = mi({
2236
2236
  rayOrigin: e.origin,
2237
- invDir: c,
2237
+ invDir: l,
2238
2238
  boxMin: r.xyz,
2239
- boxMax: l.xyz
2239
+ boxMax: u.xyz
2240
2240
  }).toVar();
2241
- N(ot(p, m).lessThan(i.dst), () => {
2241
+ N(ot(p, m).lessThan(a.dst), () => {
2242
2242
  let e = p.lessThan(m), t = W(e, d, f).toVar(), n = W(e, f, d).toVar();
2243
- N(W(e, m, p).toVar().lessThan(i.dst).and(o.lessThan(B(si))), () => {
2244
- a.element(o).assign(n), o.addAssign(1);
2245
- }), N(o.lessThan(B(si)), () => {
2246
- a.element(o).assign(t), o.addAssign(1);
2243
+ N(W(e, m, p).toVar().lessThan(a.dst).and(s.lessThan(B(si))), () => {
2244
+ o.element(s).assign(n), s.addAssign(1);
2245
+ }), N(s.lessThan(B(si)), () => {
2246
+ o.element(s).assign(t), s.addAssign(1);
2247
2247
  });
2248
2248
  });
2249
2249
  });
2250
- }), i;
2250
+ }), a;
2251
2251
  }), xi = M(([e, t, n, r, i, a, o, s, c, l, u]) => {
2252
2252
  let d = J(e.xy, 1), f = r.mul(Y(d, 1)), p = U(at(n[0].xyz, n[1].xyz, n[2].xyz).mul(f.xyz.div(f.w))).toVar(), m = J(n[3]).toVar(), h = m.toVar(), g = p.toVar();
2253
2253
  return N(i.and(a.greaterThan(0)).and(o.lessThan(64)).and(s.greaterThan(.001)), () => {
@@ -3228,7 +3228,7 @@ M(([e, t, n]) => {
3228
3228
  }), r;
3229
3229
  });
3230
3230
  var qa = M(([e, t, n, r, i, a, o, s]) => {
3231
- let c = z(1).toVar(), l = e.toVar();
3231
+ let c = z(1).toVar(), l = e.toVar(), u = z(n).toVar();
3232
3232
  return P({
3233
3233
  start: B(0),
3234
3234
  end: B(8)
@@ -3236,25 +3236,25 @@ var qa = M(([e, t, n, r, i, a, o, s]) => {
3236
3236
  let e = Cr({
3237
3237
  origin: l,
3238
3238
  direction: t
3239
- }), r = Tr.wrap(i(e, a, o, s));
3240
- N(r.didHit.not().or(r.dst.greaterThan(n)), () => {
3239
+ }), n = Tr.wrap(i(e, a, o, s, u));
3240
+ N(n.didHit.not(), () => {
3241
3241
  He();
3242
3242
  });
3243
- let u = wr.wrap(ii(r.materialIndex, s));
3244
- N(u.transmission.greaterThan(0), () => {
3245
- let e = R(t, r.normal).lessThan(0), n = W(e, r.normal, r.normal.negate());
3246
- N(e.not().and(u.attenuationDistance.greaterThan(0)), () => {
3247
- let e = tt(r.hitPoint.sub(l)), t = Ca(u.attenuationColor, u.attenuationDistance, e);
3243
+ let r = wr.wrap(ii(n.materialIndex, s));
3244
+ N(r.transmission.greaterThan(0), () => {
3245
+ let e = R(t, n.normal).lessThan(0), i = W(e, n.normal, n.normal.negate());
3246
+ N(e.not().and(r.attenuationDistance.greaterThan(0)), () => {
3247
+ let e = tt(n.hitPoint.sub(l)), t = Ca(r.attenuationColor, r.attenuationDistance, e);
3248
3248
  c.mulAssign(t.x.add(t.y).add(t.z).div(3));
3249
3249
  });
3250
- let i = qi(F(R(t, n)), Zi(u.ior, z(1))), a = z(1).sub(i).mul(u.transmission);
3251
- c.mulAssign(a), N(c.lessThan(.005), () => {
3250
+ let a = qi(F(R(t, i)), Zi(r.ior, z(1))), o = z(1).sub(a).mul(r.transmission);
3251
+ c.mulAssign(o), N(c.lessThan(.005), () => {
3252
3252
  c.assign(0), He();
3253
- }), l.assign(r.hitPoint.add(t.mul(.001)));
3254
- }).ElseIf(u.transparent, () => {
3255
- c.mulAssign(z(1).sub(u.opacity)), N(c.lessThan(.005), () => {
3253
+ }), l.assign(n.hitPoint.add(t.mul(.001))), u.subAssign(n.dst.add(.001));
3254
+ }).ElseIf(r.transparent, () => {
3255
+ c.mulAssign(z(1).sub(r.opacity)), N(c.lessThan(.005), () => {
3256
3256
  c.assign(0), He();
3257
- }), l.assign(r.hitPoint.add(t.mul(.001)));
3257
+ }), l.assign(n.hitPoint.add(t.mul(.001))), u.subAssign(n.dst.add(.001));
3258
3258
  }).Else(() => {
3259
3259
  c.assign(0), He();
3260
3260
  });
@@ -11011,7 +11011,7 @@ var oc = class extends fn {
11011
11011
  e.traverse((e) => {
11012
11012
  let n = e.userData;
11013
11013
  if (e.isRectAreaLight && !t.includes(e.uuid) && t.push(e.uuid), e.name.startsWith("RectAreaLightPlaceholder") && n.name && n.type === "RectAreaLight") {
11014
- let r = new we(new v(...n.color), n.intensity, n.width, n.height);
11014
+ let r = new we(new v(...n.color), n.intensity / Math.PI, n.width, n.height);
11015
11015
  r.position.z = -2, r.name = n.name, e.add(r), t.push(r.uuid);
11016
11016
  }
11017
11017
  if (e.isMesh && Array.isArray(e.material)) {
@@ -11891,21 +11891,45 @@ var Wc = new Float32Array(3), Gc = {
11891
11891
  let r = this.gpuDevice;
11892
11892
  if (!r) return console.warn("OIDNDenoiser: gpuDevice not available"), !1;
11893
11893
  this._ensureGPUInputBuffers(e, t);
11894
- let i = r.createCommandEncoder({ label: "oidn-tex-to-buf" }), a = e * 16, o = (n, r) => i.copyTextureToBuffer({
11895
- texture: n,
11896
- mipLevel: 0
11897
- }, {
11898
- buffer: r,
11899
- offset: 0,
11900
- bytesPerRow: a,
11901
- rowsPerImage: t
11902
- }, {
11903
- width: e,
11904
- height: t,
11905
- depthOrArrayLayers: 1
11906
- });
11907
- o(n.color, this._gpuInputBuffers.color), o(n.albedo, this._gpuInputBuffers.albedo), o(n.normal, this._gpuInputBuffers.normal), r.queue.submit([i.finish()]), this.getTransparentBackground() ? await this._cacheInputAlpha(r, e, t) : this._cachedAlpha = null, this.ctx.drawImage(this.input, 0, 0, e, t);
11908
- let s = {
11894
+ let i = r.createCommandEncoder({ label: "oidn-tex-to-buf" }), a = e * 16, o = Math.ceil(a / 256) * 256, s = o !== a, c = [], l = (n, l) => {
11895
+ if (!s) i.copyTextureToBuffer({
11896
+ texture: n,
11897
+ mipLevel: 0
11898
+ }, {
11899
+ buffer: l,
11900
+ offset: 0,
11901
+ bytesPerRow: a,
11902
+ rowsPerImage: t
11903
+ }, {
11904
+ width: e,
11905
+ height: t,
11906
+ depthOrArrayLayers: 1
11907
+ });
11908
+ else {
11909
+ let s = r.createBuffer({
11910
+ size: o * t,
11911
+ usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
11912
+ });
11913
+ c.push(s), i.copyTextureToBuffer({
11914
+ texture: n,
11915
+ mipLevel: 0
11916
+ }, {
11917
+ buffer: s,
11918
+ offset: 0,
11919
+ bytesPerRow: o,
11920
+ rowsPerImage: t
11921
+ }, {
11922
+ width: e,
11923
+ height: t,
11924
+ depthOrArrayLayers: 1
11925
+ });
11926
+ for (let e = 0; e < t; e++) i.copyBufferToBuffer(s, e * o, l, e * a, a);
11927
+ }
11928
+ };
11929
+ l(n.color, this._gpuInputBuffers.color), l(n.albedo, this._gpuInputBuffers.albedo), l(n.normal, this._gpuInputBuffers.normal), r.queue.submit([i.finish()]);
11930
+ for (let e of c) e.destroy();
11931
+ this.getTransparentBackground() ? await this._cacheInputAlpha(r, e, t) : this._cachedAlpha = null, this.ctx.drawImage(this.input, 0, 0, e, t);
11932
+ let u = {
11909
11933
  color: {
11910
11934
  data: this._gpuInputBuffers.color,
11911
11935
  width: e,
@@ -11922,13 +11946,13 @@ var Wc = new Float32Array(3), Gc = {
11922
11946
  height: t
11923
11947
  }
11924
11948
  };
11925
- return this._executeWithAbortGPU(s);
11949
+ return this._executeWithAbortGPU(u);
11926
11950
  }
11927
11951
  _ensureGPUInputBuffers(e, t) {
11928
11952
  let { width: n, height: r } = this._gpuInputBufferSize;
11929
11953
  if (n === e && r === t && this._gpuInputBuffers.color) return;
11930
11954
  this._destroyGPUInputBuffers();
11931
- let i = this.gpuDevice, a = e * t * 4 * 4, o = GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC;
11955
+ let i = this.gpuDevice, a = e * t * 16, o = GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC;
11932
11956
  this._gpuInputBuffers.color = i.createBuffer({
11933
11957
  label: "oidn-in-color",
11934
11958
  size: a,
@@ -11957,7 +11981,7 @@ var Wc = new Float32Array(3), Gc = {
11957
11981
  };
11958
11982
  }
11959
11983
  async _cacheInputAlpha(e, t, n) {
11960
- let r = t * n * 4 * 4, i = e.createBuffer({
11984
+ let r = t * n * 16, i = e.createBuffer({
11961
11985
  label: "oidn-alpha-staging",
11962
11986
  size: r,
11963
11987
  usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST
@@ -11994,24 +12018,26 @@ var Wc = new Float32Array(3), Gc = {
11994
12018
  imageWidth: e.width,
11995
12019
  imageHeight: e.height
11996
12020
  });
11997
- let r = this.gpuDevice, i = e.width, a = n.width * 16, o = n.width * n.height * 16, s = r.createBuffer({
11998
- size: o,
12021
+ let r = this.gpuDevice, i = e.width, a = e.height, o = Math.min(n.width, i - n.x), s = Math.min(n.height, a - n.y);
12022
+ if (o <= 0 || s <= 0) return;
12023
+ let l = o * 16, u = o * s * 16, d = r.createBuffer({
12024
+ size: u,
11999
12025
  usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST
12000
- }), l = r.createCommandEncoder();
12001
- for (let t = 0; t < n.height; t++) {
12002
- let r = ((n.y + t) * i + n.x) * 16, o = t * a;
12003
- l.copyBufferToBuffer(e.data, r, s, o, a);
12026
+ }), f = r.createCommandEncoder();
12027
+ for (let t = 0; t < s; t++) {
12028
+ let r = ((n.y + t) * i + n.x) * 16, a = t * l;
12029
+ f.copyBufferToBuffer(e.data, r, d, a, l);
12004
12030
  }
12005
- r.queue.submit([l.finish()]), s.mapAsync(GPUMapMode.READ).then(() => {
12006
- let e = new Float32Array(s.getMappedRange()), t = new ImageData(n.width, n.height), r = this.getExposure(), i = this.getSaturation(), a = Ic.get(this.getToneMapping()) || Ic.get(c), o = this._cachedAlpha, l = this._cachedAlphaWidth;
12031
+ r.queue.submit([f.finish()]), d.mapAsync(GPUMapMode.READ).then(() => {
12032
+ let e = new Float32Array(d.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), i = this.getSaturation(), a = Ic.get(this.getToneMapping()) || Ic.get(c), l = this._cachedAlpha, u = this._cachedAlphaWidth;
12007
12033
  for (let s = 0, c = e.length; s < c; s += 4) {
12008
- let c = e[s] * r, u = e[s + 1] * r, d = e[s + 2] * r;
12009
- if (i !== 1 && (Wc[0] = c, Wc[1] = u, Wc[2] = d, Vc(Wc, i), c = Wc[0], u = Wc[1], d = Wc[2]), a(c, u, d, 1, Wc), t.data[s] = Wc[0] ** Lc * 255 | 0, t.data[s + 1] = Wc[1] ** Lc * 255 | 0, t.data[s + 2] = Wc[2] ** Lc * 255 | 0, o) {
12010
- let e = (s >> 2) % n.width, r = (s >> 2) / n.width | 0;
12011
- t.data[s + 3] = o[(n.y + r) * l + n.x + e];
12034
+ let c = e[s] * r, d = e[s + 1] * r, f = e[s + 2] * r;
12035
+ if (i !== 1 && (Wc[0] = c, Wc[1] = d, Wc[2] = f, Vc(Wc, i), c = Wc[0], d = Wc[1], f = Wc[2]), a(c, d, f, 1, Wc), t.data[s] = Wc[0] ** Lc * 255 | 0, t.data[s + 1] = Wc[1] ** Lc * 255 | 0, t.data[s + 2] = Wc[2] ** Lc * 255 | 0, l) {
12036
+ let e = (s >> 2) % o, r = (s >> 2) / o | 0;
12037
+ t.data[s + 3] = l[(n.y + r) * u + n.x + e];
12012
12038
  } else t.data[s + 3] = 255;
12013
12039
  }
12014
- s.unmap(), s.destroy(), this.ctx.putImageData(t, n.x, n.y);
12040
+ d.unmap(), d.destroy(), this.ctx.putImageData(t, n.x, n.y);
12015
12041
  });
12016
12042
  }
12017
12043
  });