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 +29 -35
- package/dist/rayzee.es.js.map +1 -1
- package/dist/rayzee.umd.js +5 -2
- package/dist/rayzee.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/Stages/ASVGF.js +62 -248
- package/src/Stages/BilateralFilter.js +4 -1
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.
|
|
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.
|
|
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
|
|
9230
|
-
}
|
|
9231
|
-
_buildTemporalForDirection(e
|
|
9232
|
-
let
|
|
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
|
|
9239
|
-
m(
|
|
9240
|
-
let
|
|
9241
|
-
m(
|
|
9242
|
-
let e = B(
|
|
9243
|
-
m(
|
|
9244
|
-
let e = P(N(
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
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
|
-
|
|
9252
|
-
let
|
|
9253
|
-
|
|
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
|
-
|
|
9249
|
+
h.assign(G(p, 1));
|
|
9256
9250
|
});
|
|
9257
|
-
}), xe(e, we(V(
|
|
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.
|
|
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,
|
|
9324
|
-
let a = this.currentMoments === 0 ? this._temporalTexB : this._temporalTexA, o = this.currentMoments === 0 ? this.
|
|
9325
|
-
this._readTemporalTexNode.value = a, this.renderer.compute(
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
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,
|