rayzee 5.8.0 → 5.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rayzee.es.js CHANGED
@@ -9177,9 +9177,9 @@ var bc = class extends wn {
9177
9177
  super("ASVGF", {
9178
9178
  ...t,
9179
9179
  executionMode: Cn.PER_CYCLE
9180
- }), this.renderer = e, this.debugContainer = t.debugContainer || null, this.temporalAlpha = H(t.temporalAlpha ?? .1), this.gradientScale = H(t.gradientScale ?? 2), this.gradientMin = H(t.gradientMin ?? .01), this.gradientMax = H(t.gradientMax ?? .5), this.phiColor = H(t.phiColor ?? 10), this.phiNormal = H(t.phiNormal ?? 128), this.phiDepth = H(t.phiDepth ?? 1), this.maxAccumFrames = H(t.maxAccumFrames ?? 32), this.varianceClip = H(t.varianceClip ?? 1), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this.temporalEnabled = !0, this.temporalEnabledU = H(1), this._colorTexNode = new c(), this._normalDepthTexNode = new c(), this._motionTexNode = new c(), this._readTemporalTexNode = new c(), this._readPrevNDTexNode = new c(), this._gradientReadTexNode = new c();
9180
+ }), this.renderer = e, this.debugContainer = t.debugContainer || null, this.temporalAlpha = H(t.temporalAlpha ?? .1), this.phiColor = H(t.phiColor ?? 10), this.maxAccumFrames = H(t.maxAccumFrames ?? 32), this.varianceClip = H(t.varianceClip ?? 1), this.resW = H(t.width || 1), this.resH = H(t.height || 1), this.temporalEnabled = !0, this.temporalEnabledU = H(1), this._colorTexNode = new c(), this._motionTexNode = new c(), this._readTemporalTexNode = new c();
9181
9181
  let n = t.width || 1, r = t.height || 1;
9182
- this._temporalTexA = new s(n, r), this._temporalTexA.type = Ye, this._temporalTexA.format = yt, this._temporalTexA.minFilter = q, this._temporalTexA.magFilter = q, this._temporalTexB = new s(n, r), this._temporalTexB.type = Ye, this._temporalTexB.format = yt, this._temporalTexB.minFilter = q, this._temporalTexB.magFilter = q, this._prevNDTexA = new s(n, r), this._prevNDTexA.type = Ye, this._prevNDTexA.format = yt, this._prevNDTexA.minFilter = q, this._prevNDTexA.magFilter = q, this._prevNDTexB = new s(n, r), this._prevNDTexB.type = Ye, this._prevNDTexB.format = yt, this._prevNDTexB.minFilter = q, this._prevNDTexB.magFilter = q, this._gradientStorageTex = new s(n, r), this._gradientStorageTex.type = Ye, this._gradientStorageTex.format = yt, this._gradientStorageTex.minFilter = q, this._gradientStorageTex.magFilter = q, this.currentMoments = 0, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = H(0, "int"), this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = yt, this._heatmapStorageTex.minFilter = ct, this._heatmapStorageTex.magFilter = ct, this.heatmapTarget = new i(n, r, {
9182
+ this._temporalTexA = new s(n, r), this._temporalTexA.type = Ye, this._temporalTexA.format = yt, this._temporalTexA.minFilter = q, this._temporalTexA.magFilter = q, this._temporalTexB = new s(n, r), this._temporalTexB.type = Ye, this._temporalTexB.format = yt, this._temporalTexB.minFilter = q, this._temporalTexB.magFilter = q, this._gradientStorageTex = new s(n, r), this._gradientStorageTex.type = Ye, this._gradientStorageTex.format = yt, this._gradientStorageTex.minFilter = q, this._gradientStorageTex.magFilter = q, this.currentMoments = 0, this._compiled = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = H(0, "int"), this._heatmapStorageTex = new s(n, r), this._heatmapStorageTex.type = qe, this._heatmapStorageTex.format = yt, this._heatmapStorageTex.minFilter = ct, this._heatmapStorageTex.magFilter = ct, this.heatmapTarget = new i(n, r, {
9183
9183
  type: qe,
9184
9184
  format: yt,
9185
9185
  minFilter: ct,
@@ -9226,35 +9226,29 @@ var bc = class extends wn {
9226
9226
  ]);
9227
9227
  }
9228
9228
  _buildTemporalCompute() {
9229
- this._temporalNodeA = this._buildTemporalForDirection(this._temporalTexA, this._prevNDTexA), this._temporalNodeB = this._buildTemporalForDirection(this._temporalTexB, this._prevNDTexB);
9230
- }
9231
- _buildTemporalForDirection(e, t) {
9232
- let n = this._colorTexNode, r = this._normalDepthTexNode, i = this._motionTexNode, a = this._readTemporalTexNode, o = this._readPrevNDTexNode;
9233
- this._gradientReadTexNode;
9234
- let s = this.temporalAlpha;
9235
- this.gradientScale, this.gradientMin, this.gradientMax;
9236
- let c = this.phiNormal, l = this.phiDepth, u = this.maxAccumFrames, d = this.varianceClip, f = this.temporalEnabledU, h = this.resW, g = this.resH;
9229
+ this._temporalNodeA = this._buildTemporalForDirection(this._temporalTexA), this._temporalNodeB = this._buildTemporalForDirection(this._temporalTexB);
9230
+ }
9231
+ _buildTemporalForDirection(e) {
9232
+ let t = this._colorTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.temporalAlpha, a = this.maxAccumFrames, o = this.varianceClip, s = this.temporalEnabledU, c = this.resW, l = this.resH;
9237
9233
  return p(() => {
9238
- let p = N(De.x).mul(8).add(N(F.x)), _ = N(De.y).mul(8).add(N(F.y));
9239
- m(p.lessThan(N(h)).and(_.lessThan(N(g))), () => {
9240
- let v = P(p, _), y = B(n, v).xyz, b = B(r, v), x = G(y, 1).toVar();
9241
- m(f.greaterThan(.5), () => {
9242
- let e = B(i, v), t = e.w.greaterThan(.5), r = M(p).sub(e.x.mul(h)), f = M(_).sub(e.y.mul(g)), S = r.greaterThanEqual(0).and(r.lessThan(M(h))).and(f.greaterThanEqual(0)).and(f.lessThan(M(g)));
9243
- m(t.and(S), () => {
9244
- let e = P(N(r).clamp(N(0), N(h).sub(1)), N(f).clamp(N(0), N(g).sub(1))), t = b.xyz.mul(2).sub(1), i = B(o, e);
9245
- Di(t, i.xyz.mul(2).sub(1), b.w, i.w, c, l);
9246
- let m = B(a, e), v = m.xyz, S = m.w, C = S.div(u).clamp(0, 1), w = W(1e10).toVar(), T = W(-1e10).toVar(), E = W(0).toVar();
9247
- for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
9248
- let r = B(n, P(p.add(t).clamp(N(0), N(h).sub(1)), _.add(e).clamp(N(0), N(g).sub(1)))).xyz;
9249
- w.assign(oe(w, r)), T.assign(I(T, r)), E.addAssign(r);
9234
+ let u = N(De.x).mul(8).add(N(F.x)), d = N(De.y).mul(8).add(N(F.y));
9235
+ m(u.lessThan(N(c)).and(d.lessThan(N(l))), () => {
9236
+ let f = P(u, d), p = B(t, f).xyz, h = G(p, 1).toVar();
9237
+ m(s.greaterThan(.5), () => {
9238
+ let e = B(n, f), s = e.w.greaterThan(.5), g = M(u).sub(e.x.mul(c)), _ = M(d).sub(e.y.mul(l)), v = g.greaterThanEqual(0).and(g.lessThan(M(c))).and(_.greaterThanEqual(0)).and(_.lessThan(M(l)));
9239
+ m(s.and(v), () => {
9240
+ let e = B(r, P(N(g).clamp(N(0), N(c).sub(1)), N(_).clamp(N(0), N(l).sub(1)))), n = e.xyz, s = e.w, f = W(0).toVar(), m = W(0).toVar();
9241
+ for (let e = -1; e <= 1; e++) for (let n = -1; n <= 1; n++) {
9242
+ let r = B(t, P(u.add(n).clamp(N(0), N(c).sub(1)), d.add(e).clamp(N(0), N(l).sub(1)))).xyz;
9243
+ f.addAssign(r), m.addAssign(r.mul(r));
9250
9244
  }
9251
- E.divAssign(9);
9252
- let D = M(1).add(C.mul(3)), O = T.sub(w).mul(d).mul(D), k = w.sub(O), A = T.add(O), j = L(v.clamp(k, A), y, I(M(1).div(S.add(1)), s)), ee = oe(S.add(1), u);
9253
- x.assign(G(j, ee));
9245
+ f.divAssign(9), m.divAssign(9);
9246
+ let v = A(I(m.sub(f.mul(f)), W(0)), W(1)), y = n.sub(f), b = A(y, y), x = v.mul(o.mul(o)), S = b.div(I(x, M(1e-6))).clamp(0, 1), C = L(n, p, L(I(M(1).div(s.add(1)), i), M(1), S)), w = L(oe(s.add(1), a), M(1), S);
9247
+ h.assign(G(C, w));
9254
9248
  }).Else(() => {
9255
- x.assign(G(y, 1));
9249
+ h.assign(G(p, 1));
9256
9250
  });
9257
- }), xe(e, we(V(p), V(_)), x).toWriteOnly(), xe(t, we(V(p), V(_)), b).toWriteOnly();
9251
+ }), xe(e, we(V(u), V(d)), h).toWriteOnly();
9258
9252
  });
9259
9253
  })().compute([
9260
9254
  this._dispatchX,
@@ -9312,7 +9306,7 @@ var bc = class extends wn {
9312
9306
  this.on("asvgf:reset", () => this.resetTemporalData()), this.on("asvgf:setTemporal", (e) => {
9313
9307
  e && e.enabled !== void 0 && (this.temporalEnabled = e.enabled, this.temporalEnabledU.value = +!!e.enabled);
9314
9308
  }), this.on("asvgf:updateParameters", (e) => {
9315
- e && (e.temporalAlpha !== void 0 && (this.temporalAlpha.value = e.temporalAlpha), e.gradientScale !== void 0 && (this.gradientScale.value = e.gradientScale), e.phiColor !== void 0 && (this.phiColor.value = e.phiColor), e.phiNormal !== void 0 && (this.phiNormal.value = e.phiNormal), e.phiDepth !== void 0 && (this.phiDepth.value = e.phiDepth));
9309
+ e && (e.temporalAlpha !== void 0 && (this.temporalAlpha.value = e.temporalAlpha), e.phiColor !== void 0 && (this.phiColor.value = e.phiColor));
9316
9310
  });
9317
9311
  }
9318
9312
  render(e) {
@@ -9320,9 +9314,9 @@ var bc = class extends wn {
9320
9314
  let t = e.getTexture("pathtracer:color"), n = e.getTexture("pathtracer:normalDepth"), r = e.getTexture("motionVector:screenSpace");
9321
9315
  if (!t) return;
9322
9316
  let i = t.image;
9323
- i && i.width > 0 && i.height > 0 && (i.width !== this._temporalTexA.image.width || i.height !== this._temporalTexA.image.height) && this.setSize(i.width, i.height), this._colorTexNode.value = t, n && (this._normalDepthTexNode.value = n), r && (this._motionTexNode.value = r), this._compiled ||= (this.renderer.compute(this._gradientNode), this.renderer.compute(this._temporalNodeA), this.renderer.compute(this._temporalNodeB), !0);
9324
- let a = this.currentMoments === 0 ? this._temporalTexB : this._temporalTexA, o = this.currentMoments === 0 ? this._prevNDTexB : this._prevNDTexA, s = this.currentMoments === 0 ? this._temporalNodeA : this._temporalNodeB, c = this.currentMoments === 0 ? this._temporalTexA : this._temporalTexB;
9325
- this._readTemporalTexNode.value = a, this.renderer.compute(this._gradientNode), this._gradientReadTexNode.value = this._gradientStorageTex, this._readPrevNDTexNode.value = o, this.renderer.compute(s), e.setTexture("asvgf:output", c), e.setTexture("asvgf:temporalColor", c), this.currentMoments = 1 - this.currentMoments, this.showHeatmap && (this._heatmapRawColorTexNode.value = t, this._heatmapColorTexNode.value = c, this._heatmapTemporalTexNode.value = c, n && (this._heatmapNDTexNode.value = n), r && (this._heatmapMotionTexNode.value = r), this._heatmapGradientTexNode.value = this._gradientStorageTex, this.renderer.compute(this._heatmapComputeNode), this.renderer.copyTextureToTexture(this._heatmapStorageTex, this.heatmapTarget.texture), this.heatmapHelper.update()), this.frameCount++;
9317
+ i && i.width > 0 && i.height > 0 && (i.width !== this._temporalTexA.image.width || i.height !== this._temporalTexA.image.height) && this.setSize(i.width, i.height), this._colorTexNode.value = t, r && (this._motionTexNode.value = r), this._compiled ||= (this.renderer.compute(this._gradientNode), this.renderer.compute(this._temporalNodeA), this.renderer.compute(this._temporalNodeB), !0);
9318
+ let a = this.currentMoments === 0 ? this._temporalTexB : this._temporalTexA, o = this.currentMoments === 0 ? this._temporalNodeA : this._temporalNodeB, s = this.currentMoments === 0 ? this._temporalTexA : this._temporalTexB;
9319
+ this._readTemporalTexNode.value = a, this.renderer.compute(o), e.setTexture("asvgf:output", s), e.setTexture("asvgf:temporalColor", s), this.currentMoments = 1 - this.currentMoments, this.showHeatmap && (this.renderer.compute(this._gradientNode), this._heatmapRawColorTexNode.value = t, this._heatmapColorTexNode.value = s, this._heatmapTemporalTexNode.value = s, n && (this._heatmapNDTexNode.value = n), r && (this._heatmapMotionTexNode.value = r), this._heatmapGradientTexNode.value = this._gradientStorageTex, this.renderer.compute(this._heatmapComputeNode), this.renderer.copyTextureToTexture(this._heatmapStorageTex, this.heatmapTarget.texture), this.heatmapHelper.update()), this.frameCount++;
9326
9320
  }
9327
9321
  toggleHeatmap(e) {
9328
9322
  this.showHeatmap = e, e ? this.heatmapHelper.show() : this.heatmapHelper.hide();
@@ -9331,13 +9325,13 @@ var bc = class extends wn {
9331
9325
  this.temporalEnabled = e;
9332
9326
  }
9333
9327
  updateParameters(e) {
9334
- e && (e.temporalAlpha !== void 0 && (this.temporalAlpha.value = e.temporalAlpha), e.gradientScale !== void 0 && (this.gradientScale.value = e.gradientScale), e.phiColor !== void 0 && (this.phiColor.value = e.phiColor), e.phiNormal !== void 0 && (this.phiNormal.value = e.phiNormal), e.phiDepth !== void 0 && (this.phiDepth.value = e.phiDepth), e.debugMode !== void 0 && (this.debugMode.value = e.debugMode));
9328
+ e && (e.temporalAlpha !== void 0 && (this.temporalAlpha.value = e.temporalAlpha), e.phiColor !== void 0 && (this.phiColor.value = e.phiColor), e.debugMode !== void 0 && (this.debugMode.value = e.debugMode));
9335
9329
  }
9336
9330
  resetTemporalData() {
9337
9331
  this.frameCount = 0, this.currentMoments = 0;
9338
9332
  }
9339
9333
  setSize(e, t) {
9340
- this._temporalTexA.setSize(e, t), this._temporalTexB.setSize(e, t), this._prevNDTexA.setSize(e, t), this._prevNDTexB.setSize(e, t), this._gradientStorageTex.setSize(e, t), this._heatmapStorageTex.setSize(e, t), this.heatmapTarget.setSize(e, t), this.heatmapTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / 8), this._dispatchY = Math.ceil(t / 8), this._gradientNode.dispatchSize = [
9334
+ this._temporalTexA.setSize(e, t), this._temporalTexB.setSize(e, t), this._gradientStorageTex.setSize(e, t), this._heatmapStorageTex.setSize(e, t), this.heatmapTarget.setSize(e, t), this.heatmapTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / 8), this._dispatchY = Math.ceil(t / 8), this._gradientNode.dispatchSize = [
9341
9335
  this._dispatchX,
9342
9336
  this._dispatchY,
9343
9337
  1
@@ -9357,7 +9351,7 @@ var bc = class extends wn {
9357
9351
  }
9358
9352
  reset() {}
9359
9353
  dispose() {
9360
- this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._prevNDTexA?.dispose(), this._prevNDTexB?.dispose(), this._gradientStorageTex?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._motionTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._readPrevNDTexNode?.dispose(), this._gradientReadTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose(), this.heatmapHelper?.dispose();
9354
+ this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._gradientStorageTex?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._motionTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose(), this.heatmapHelper?.dispose();
9361
9355
  }
9362
9356
  }, xc = /* @__PURE__ */ K("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), Sc = class extends wn {
9363
9357
  constructor(e, t = {}) {
@@ -9434,7 +9428,7 @@ var bc = class extends wn {
9434
9428
  dispose() {
9435
9429
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
9436
9430
  }
9437
- }, Cc = /* @__PURE__ */ K("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n phiLum: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) * phiLum );\n let normW = pow( max( dot( centerNormal, sNormal ), 0.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let colW = exp( -maxDiff * phiCol );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), wc = class extends wn {
9431
+ }, Cc = /* @__PURE__ */ K("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n phiLum: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) * phiLum );\n // clamp dot to [0,1] not just max(., 0): miss-ray normals decode to\n // non-unit (-1,-1,-1) with dot=3, which would saturate pow to +inf\n // and poison output via inf*0 = NaN. See project_tsl_pitfalls memory.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let colW = exp( -maxDiff * phiCol );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), wc = class extends wn {
9438
9432
  constructor(e, t = {}) {
9439
9433
  super("BilateralFiltering", {
9440
9434
  ...t,