shaders 2.5.108 → 2.5.110
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/core/{Aurora-BPHeGEZ_.js → Aurora-KcUDr49P.js} +21 -14
- package/dist/core/{Blur-Cxx3ZuHi.js → Blur-DG7lJKPo.js} +29 -13
- package/dist/core/{ChannelBlur-Cth0biwG.js → ChannelBlur-BhcCkwcO.js} +7 -3
- package/dist/core/{ContourLines-KTHC32hd.js → ContourLines-tDBvQOvb.js} +8 -7
- package/dist/core/{CursorTrail-R4IBB4eu.js → CursorTrail-CgRMXbTG.js} +5 -5
- package/dist/core/{DropShadow-jMhnYPXZ.js → DropShadow-B7FzTp4H.js} +14 -8
- package/dist/core/{Duotone-Bl02WcA2.js → Duotone-CqQ0NMxS.js} +4 -11
- package/dist/core/{FloatingParticles-BtwGRl_d.js → FloatingParticles-DpYA0_TE.js} +6 -2
- package/dist/core/{Form3D-DaPbLGUi.js → Form3D-Bufw6tZb.js} +14 -2
- package/dist/core/{Glass-TRSXbuE6.js → Glass-Bz9IKI2q.js} +7 -3
- package/dist/core/{Glow-8bKkyehK.js → Glow-CUv1yHLZ.js} +68 -55
- package/dist/core/{GridDistortion-CpSiGEGV.js → GridDistortion-SRyevgsp.js} +4 -4
- package/dist/core/{HueShift-BtGVMu7q.js → HueShift-ctEX5vfo.js} +2 -0
- package/dist/core/{ImageTexture-CrX_9-f0.js → ImageTexture-uxj4LpF7.js} +30 -17
- package/dist/core/{Liquify-D9YIfbfB.js → Liquify-p-_qcb1f.js} +5 -5
- package/dist/core/{ProgressiveBlur-B_z0pZ1V.js → ProgressiveBlur-NbvxFfRa.js} +33 -20
- package/dist/core/{Saturation-CB19kOXg.js → Saturation-DCFAIUvZ.js} +2 -0
- package/dist/core/{Sharpness-CQOboeqy.js → Sharpness-DSpEoCSL.js} +2 -0
- package/dist/core/{Shatter-SHNbU2KC.js → Shatter-ByKkCYTR.js} +28 -24
- package/dist/core/{SimplexNoise-BcSgytjc.js → SimplexNoise-CMuU8n27.js} +14 -2
- package/dist/core/Swirl-B_KxdaX2.js +105 -0
- package/dist/core/{TiltShift-GqDjHvmk.js → TiltShift-BSAyR0Me.js} +47 -21
- package/dist/core/{Tint-DaTx2HII.js → Tint-DdvnpzEJ.js} +11 -6
- package/dist/core/{Tritone-C9Yx69Tw.js → Tritone-Ckb6hTkI.js} +4 -11
- package/dist/core/{VideoTexture-SWLe5c3m.js → VideoTexture-BMSdfLf_.js} +30 -17
- package/dist/core/{WebcamTexture-cXPyEumA.js → WebcamTexture-Ds9IrtRn.js} +30 -17
- package/dist/core/computeBlur-DCRhuYEi.js +209 -0
- package/dist/core/index.js +28 -62
- package/dist/core/registry.js +28 -28
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/core/{shaderRegistry-fwljIrjT.js → shaderRegistry-DFzzFEKX.js} +26 -26
- package/dist/core/shaders/Aurora/index.d.ts.map +1 -1
- package/dist/core/shaders/Aurora/index.js +1 -1
- package/dist/core/shaders/Blur/index.d.ts.map +1 -1
- package/dist/core/shaders/Blur/index.js +2 -2
- package/dist/core/shaders/ChannelBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ChannelBlur/index.js +2 -2
- package/dist/core/shaders/ContourLines/index.d.ts.map +1 -1
- package/dist/core/shaders/ContourLines/index.js +1 -1
- package/dist/core/shaders/CursorTrail/index.d.ts.map +1 -1
- package/dist/core/shaders/CursorTrail/index.js +1 -1
- package/dist/core/shaders/DropShadow/index.d.ts.map +1 -1
- package/dist/core/shaders/DropShadow/index.js +1 -1
- package/dist/core/shaders/Duotone/index.d.ts.map +1 -1
- package/dist/core/shaders/Duotone/index.js +1 -2
- package/dist/core/shaders/FloatingParticles/index.d.ts.map +1 -1
- package/dist/core/shaders/FloatingParticles/index.js +1 -1
- package/dist/core/shaders/Form3D/index.d.ts.map +1 -1
- package/dist/core/shaders/Form3D/index.js +1 -1
- package/dist/core/shaders/Glass/index.d.ts.map +1 -1
- package/dist/core/shaders/Glass/index.js +2 -2
- package/dist/core/shaders/Glow/index.d.ts +2 -2
- package/dist/core/shaders/Glow/index.d.ts.map +1 -1
- package/dist/core/shaders/Glow/index.js +2 -2
- package/dist/core/shaders/GridDistortion/index.d.ts.map +1 -1
- package/dist/core/shaders/GridDistortion/index.js +1 -1
- package/dist/core/shaders/HueShift/index.d.ts.map +1 -1
- package/dist/core/shaders/HueShift/index.js +1 -1
- package/dist/core/shaders/ImageTexture/index.d.ts.map +1 -1
- package/dist/core/shaders/ImageTexture/index.js +1 -1
- package/dist/core/shaders/Liquify/index.d.ts.map +1 -1
- package/dist/core/shaders/Liquify/index.js +1 -1
- package/dist/core/shaders/ProgressiveBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ProgressiveBlur/index.js +2 -2
- package/dist/core/shaders/Saturation/index.d.ts.map +1 -1
- package/dist/core/shaders/Saturation/index.js +1 -1
- package/dist/core/shaders/Sharpness/index.d.ts.map +1 -1
- package/dist/core/shaders/Sharpness/index.js +1 -1
- package/dist/core/shaders/Shatter/index.d.ts.map +1 -1
- package/dist/core/shaders/Shatter/index.js +1 -1
- package/dist/core/shaders/SimplexNoise/index.d.ts +7 -0
- package/dist/core/shaders/SimplexNoise/index.d.ts.map +1 -1
- package/dist/core/shaders/SimplexNoise/index.js +1 -1
- package/dist/core/shaders/Swirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Swirl/index.js +1 -1
- package/dist/core/shaders/TiltShift/index.d.ts.map +1 -1
- package/dist/core/shaders/TiltShift/index.js +2 -2
- package/dist/core/shaders/Tint/index.d.ts.map +1 -1
- package/dist/core/shaders/Tint/index.js +1 -1
- package/dist/core/shaders/Tritone/index.d.ts.map +1 -1
- package/dist/core/shaders/Tritone/index.js +1 -2
- package/dist/core/shaders/VideoTexture/index.d.ts.map +1 -1
- package/dist/core/shaders/VideoTexture/index.js +1 -1
- package/dist/core/shaders/WebcamTexture/index.d.ts.map +1 -1
- package/dist/core/shaders/WebcamTexture/index.js +1 -1
- package/dist/core/utilities/computeBlur.d.ts +29 -31
- package/dist/core/utilities/computeBlur.d.ts.map +1 -1
- package/dist/js/createShader.d.ts.map +1 -1
- package/dist/js/createShader.js +3 -2
- package/dist/js/createSharedDevice.d.ts +36 -0
- package/dist/js/createSharedDevice.d.ts.map +1 -0
- package/dist/js/createSharedDevice.js +15 -0
- package/dist/js/index.d.ts +1 -0
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +2 -1
- package/dist/js/types.d.ts +10 -0
- package/dist/js/types.d.ts.map +1 -1
- package/dist/js/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/js/utils/generatePresetCode.js +2 -1
- package/dist/partner/index.d.ts +6 -2
- package/dist/partner/index.d.ts.map +1 -1
- package/dist/react/Shader.js +1 -1
- package/dist/react/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/react/utils/generatePresetCode.js +2 -1
- package/dist/registry.js +95 -18
- package/dist/solid/engine/Shader.js +1 -1
- package/dist/solid/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/solid/utils/generatePresetCode.js +2 -1
- package/dist/svelte/{generatePresetCode-DR_OAIL7.js → generatePresetCode-jdOx6mhw.js} +2 -1
- package/dist/svelte/index.js +2 -2
- package/dist/svelte/utils/generatePresetCode.js +1 -1
- package/dist/vue/Shader.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/vue/SimplexNoise.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/vue/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/vue/utils/generatePresetCode.js +2 -1
- package/package.json +1 -1
- package/dist/core/Swirl-By5FadQK.js +0 -103
- package/dist/core/computeBlur-DeXZ99YL.js +0 -150
|
@@ -30,7 +30,9 @@ const componentDefinition = {
|
|
|
30
30
|
},
|
|
31
31
|
preserveLuminosity: {
|
|
32
32
|
default: true,
|
|
33
|
+
compileTime: true,
|
|
33
34
|
description: "Preserve original brightness",
|
|
35
|
+
transform: (v) => v ? 1 : 0,
|
|
34
36
|
ui: {
|
|
35
37
|
type: "checkbox",
|
|
36
38
|
label: "Preserve Luminosity",
|
|
@@ -45,14 +47,17 @@ const componentDefinition = {
|
|
|
45
47
|
}
|
|
46
48
|
const tintColor = uniforms.color.uniform;
|
|
47
49
|
const amount = uniforms.amount.uniform;
|
|
48
|
-
const preserveLum = uniforms.preserveLuminosity.uniform;
|
|
49
50
|
const rgb = vec3(childNode.r, childNode.g, childNode.b);
|
|
50
|
-
const luminanceWeights = vec3(.299, .587, .114);
|
|
51
|
-
const originalLum = dot(rgb, luminanceWeights);
|
|
52
51
|
const tinted = mix(rgb, tintColor.rgb, amount);
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const preserveLum = uniforms.preserveLuminosity.uniform.value === 1;
|
|
53
|
+
let result;
|
|
54
|
+
if (preserveLum) {
|
|
55
|
+
const luminanceWeights = vec3(.299, .587, .114);
|
|
56
|
+
const originalLum = dot(rgb, luminanceWeights);
|
|
57
|
+
const tintedLum = dot(tinted, luminanceWeights);
|
|
58
|
+
result = tinted.mul(originalLum.div(max(tintedLum, 1e-4)));
|
|
59
|
+
} else result = tinted;
|
|
60
|
+
return vec4(result, childNode.a);
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
63
|
var Tint_default = componentDefinition;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { a as transformColor, o as transformColorSpace, t as colorSpaceOptions } from "./transformations-B5lM6fYX.js";
|
|
2
|
-
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
3
2
|
import { t as mixColors } from "./colorMixing-BPpDnR5I.js";
|
|
4
|
-
import {
|
|
3
|
+
import { dot, smoothstep, vec3, vec4 } from "three/tsl";
|
|
5
4
|
const componentDefinition = {
|
|
6
5
|
name: "Tritone",
|
|
7
6
|
category: "Adjustments",
|
|
8
7
|
description: "Map colors to three tones: shadows, midtones, highlights",
|
|
9
|
-
requiresRTT: true,
|
|
10
8
|
requiresChild: true,
|
|
11
9
|
props: {
|
|
12
10
|
colorA: {
|
|
@@ -64,19 +62,14 @@ const componentDefinition = {
|
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
},
|
|
67
|
-
fragmentNode: ({ uniforms, childNode
|
|
65
|
+
fragmentNode: ({ uniforms, childNode }) => {
|
|
68
66
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
69
|
-
const
|
|
70
|
-
onCleanup(() => {
|
|
71
|
-
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
72
|
-
});
|
|
73
|
-
const inputColor = unpremultiplyAlpha(childTexture.sample(screenUV));
|
|
74
|
-
const luminance = dot(inputColor.rgb, vec3(.299, .587, .114));
|
|
67
|
+
const luminance = dot(vec3(childNode.r, childNode.g, childNode.b), vec3(.299, .587, .114));
|
|
75
68
|
const shadowToMid = smoothstep(uniforms.blendMid.uniform.sub(.25), uniforms.blendMid.uniform, luminance);
|
|
76
69
|
const csMode = uniforms.colorSpace.uniform.value;
|
|
77
70
|
const lowerBlend = mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, shadowToMid, csMode);
|
|
78
71
|
const midToHighlight = smoothstep(uniforms.blendMid.uniform, uniforms.blendMid.uniform.add(.25), luminance);
|
|
79
|
-
return vec4(mixColors(lowerBlend, mixColors(uniforms.colorB.uniform, uniforms.colorC.uniform, midToHighlight, csMode), smoothstep(uniforms.blendMid.uniform.sub(.1), uniforms.blendMid.uniform.add(.1), luminance), csMode).rgb,
|
|
72
|
+
return vec4(mixColors(lowerBlend, mixColors(uniforms.colorB.uniform, uniforms.colorC.uniform, midToHighlight, csMode), smoothstep(uniforms.blendMid.uniform.sub(.1), uniforms.blendMid.uniform.add(.1), luminance), csMode).rgb, childNode.a);
|
|
80
73
|
}
|
|
81
74
|
};
|
|
82
75
|
var Tritone_default = componentDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as needsVideoCanvasWorkaround } from "./browser-D8zonASQ.js";
|
|
2
2
|
import { CanvasTexture, SRGBColorSpace, VideoTexture } from "three/webgpu";
|
|
3
|
-
import { float, max, min, or, screenUV, select,
|
|
3
|
+
import { float, max, min, or, screenUV, select, texture, uniform, vec2, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "VideoTexture",
|
|
6
6
|
category: "Textures",
|
|
@@ -27,6 +27,7 @@ const componentDefinition = {
|
|
|
27
27
|
"none": 4
|
|
28
28
|
}[value] ?? 0;
|
|
29
29
|
},
|
|
30
|
+
compileTime: true,
|
|
30
31
|
ui: {
|
|
31
32
|
type: "select",
|
|
32
33
|
options: [
|
|
@@ -175,22 +176,34 @@ const componentDefinition = {
|
|
|
175
176
|
});
|
|
176
177
|
const uv$1 = baseUV;
|
|
177
178
|
const viewportAspect = viewportSize.x.div(viewportSize.y);
|
|
178
|
-
const objectFitMode = uniforms.objectFit.uniform;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
179
|
+
const objectFitMode = uniforms.objectFit.uniform.value;
|
|
180
|
+
let uvScale;
|
|
181
|
+
switch (objectFitMode) {
|
|
182
|
+
case 1: {
|
|
183
|
+
const containScale = min(viewportAspect.div(videoAspectUniform), float(1));
|
|
184
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(containScale), containScale);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 2:
|
|
188
|
+
uvScale = vec2(1, 1);
|
|
189
|
+
break;
|
|
190
|
+
case 3: {
|
|
191
|
+
const scaleDownScale = min(min(viewportAspect.div(videoAspectUniform), float(1)), min(viewportSize.x.div(videoWidthUniform), viewportSize.y.div(videoHeightUniform)));
|
|
192
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(scaleDownScale), scaleDownScale);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
case 4: {
|
|
196
|
+
const noneScale = min(viewportSize.x.div(videoWidthUniform), viewportSize.y.div(videoHeightUniform));
|
|
197
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(noneScale), noneScale);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case 0:
|
|
201
|
+
default: {
|
|
202
|
+
const coverScale = max(viewportAspect.div(videoAspectUniform), float(1));
|
|
203
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(coverScale), coverScale);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
194
207
|
const adjustedUV = uv$1.sub(vec2(.5)).div(uvScale).add(vec2(.5));
|
|
195
208
|
const finalUV = vec2(adjustedUV.x, float(1).sub(adjustedUV.y));
|
|
196
209
|
const sampledColor = textureNode.sample(finalUV);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as needsVideoCanvasWorkaround } from "./browser-D8zonASQ.js";
|
|
2
2
|
import { CanvasTexture, SRGBColorSpace, VideoTexture } from "three/webgpu";
|
|
3
|
-
import { float, max, min, or, screenUV, select,
|
|
3
|
+
import { float, max, min, or, screenUV, select, texture, uniform, vec2, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "WebcamTexture",
|
|
6
6
|
category: "Textures",
|
|
@@ -18,6 +18,7 @@ const componentDefinition = {
|
|
|
18
18
|
"none": 4
|
|
19
19
|
}[value] ?? 0;
|
|
20
20
|
},
|
|
21
|
+
compileTime: true,
|
|
21
22
|
ui: {
|
|
22
23
|
type: "select",
|
|
23
24
|
options: [
|
|
@@ -159,22 +160,34 @@ const componentDefinition = {
|
|
|
159
160
|
});
|
|
160
161
|
const uv$1 = baseUV;
|
|
161
162
|
const viewportAspect = viewportSize.x.div(viewportSize.y);
|
|
162
|
-
const objectFitMode = uniforms.objectFit.uniform;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
163
|
+
const objectFitMode = uniforms.objectFit.uniform.value;
|
|
164
|
+
let uvScale;
|
|
165
|
+
switch (objectFitMode) {
|
|
166
|
+
case 1: {
|
|
167
|
+
const containScale = min(viewportAspect.div(videoAspectUniform), float(1));
|
|
168
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(containScale), containScale);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case 2:
|
|
172
|
+
uvScale = vec2(1, 1);
|
|
173
|
+
break;
|
|
174
|
+
case 3: {
|
|
175
|
+
const scaleDownScale = min(min(viewportAspect.div(videoAspectUniform), float(1)), min(viewportSize.x.div(videoWidthUniform), viewportSize.y.div(videoHeightUniform)));
|
|
176
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(scaleDownScale), scaleDownScale);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case 4: {
|
|
180
|
+
const noneScale = min(viewportSize.x.div(videoWidthUniform), viewportSize.y.div(videoHeightUniform));
|
|
181
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(noneScale), noneScale);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 0:
|
|
185
|
+
default: {
|
|
186
|
+
const coverScale = max(viewportAspect.div(videoAspectUniform), float(1));
|
|
187
|
+
uvScale = vec2(videoAspectUniform.div(viewportAspect).mul(coverScale), coverScale);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
178
191
|
const adjustedUV = uv$1.sub(vec2(.5)).div(uvScale).add(vec2(.5));
|
|
179
192
|
const mirrorMode = uniforms.mirror.uniform;
|
|
180
193
|
const finalUV = vec2(select(mirrorMode, float(1).sub(adjustedUV.x), adjustedUV.x), float(1).sub(adjustedUV.y));
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { StorageTexture } from "three/webgpu";
|
|
2
|
+
import { FloatType } from "three";
|
|
3
|
+
import { Fn, If, float, instanceIndex, int, storageTexture, textureLoad, textureStore, uint, uniform, uniformArray, uvec2, vec4 } from "three/tsl";
|
|
4
|
+
var DEFAULT_HALF_KERNEL = 24;
|
|
5
|
+
const DEFAULT_COMPUTE_WIDTH = 1024;
|
|
6
|
+
const DEFAULT_COMPUTE_HEIGHT = 640;
|
|
7
|
+
function buildFixedWeights(halfKernel) {
|
|
8
|
+
const sigma = halfKernel / 3;
|
|
9
|
+
const size = halfKernel * 2 + 1;
|
|
10
|
+
const weights = [];
|
|
11
|
+
let sum = 0;
|
|
12
|
+
for (let i = -halfKernel; i <= halfKernel; i++) {
|
|
13
|
+
const w = Math.exp(-(i * i) / (2 * sigma * sigma));
|
|
14
|
+
weights.push(w);
|
|
15
|
+
sum += w;
|
|
16
|
+
}
|
|
17
|
+
for (let i = 0; i < size; i++) weights[i] /= sum;
|
|
18
|
+
return weights;
|
|
19
|
+
}
|
|
20
|
+
var PASSTHROUGH_THRESHOLD = .5;
|
|
21
|
+
function createGaussianBlurCompute(inputTexture, inputWidth, inputHeight, onCleanup, halfKernel = DEFAULT_HALF_KERNEL, computeWidth = DEFAULT_COMPUTE_WIDTH, computeHeight = 640) {
|
|
22
|
+
const KERNEL_SIZE = halfKernel * 2 + 1;
|
|
23
|
+
const HALF_KERNEL = halfKernel;
|
|
24
|
+
const intermediateTex = new StorageTexture(computeWidth, computeHeight);
|
|
25
|
+
intermediateTex.type = FloatType;
|
|
26
|
+
const outputTex = new StorageTexture(computeWidth, computeHeight);
|
|
27
|
+
outputTex.type = FloatType;
|
|
28
|
+
onCleanup(() => {
|
|
29
|
+
intermediateTex.dispose();
|
|
30
|
+
outputTex.dispose();
|
|
31
|
+
});
|
|
32
|
+
const intermediateWriteNode = storageTexture(intermediateTex);
|
|
33
|
+
const intermediateReadNode = storageTexture(intermediateTex).toReadOnly();
|
|
34
|
+
const outputNode = storageTexture(outputTex);
|
|
35
|
+
const weightsH = uniformArray(new Array(KERNEL_SIZE).fill(0), "float");
|
|
36
|
+
const weightsV = uniformArray(new Array(KERNEL_SIZE).fill(0), "float");
|
|
37
|
+
let lastRadius = -1;
|
|
38
|
+
const inputWidthU = uniform(inputWidth);
|
|
39
|
+
const inputHeightU = uniform(inputHeight);
|
|
40
|
+
let scaleY = inputHeight / computeHeight;
|
|
41
|
+
const cw = uint(computeWidth);
|
|
42
|
+
const ch = uint(computeHeight);
|
|
43
|
+
const computeHm1 = int(computeHeight - 1);
|
|
44
|
+
const inputWm1 = int(inputWidthU.sub(1));
|
|
45
|
+
const inputHm1 = int(inputHeightU.sub(1));
|
|
46
|
+
const horizontalPass = Fn(() => {
|
|
47
|
+
const idx = instanceIndex;
|
|
48
|
+
const cx = idx.mod(cw);
|
|
49
|
+
const cy = idx.div(cw);
|
|
50
|
+
If(cy.lessThan(ch), () => {
|
|
51
|
+
const sum = vec4(0).toVar();
|
|
52
|
+
const inputCx = cx.toFloat().add(float(.5)).mul(inputWidthU).div(float(computeWidth)).sub(float(.5));
|
|
53
|
+
const inputCy = cy.toFloat().add(float(.5)).mul(inputHeightU).div(float(computeHeight)).sub(float(.5));
|
|
54
|
+
const inputCxI = inputCx.round().toInt();
|
|
55
|
+
const inputCyI = inputCy.round().toInt().clamp(int(0), inputHm1);
|
|
56
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
57
|
+
const texel = textureLoad(inputTexture, uvec2(inputCxI.add(int(i)).clamp(int(0), inputWm1).toUint(), inputCyI.toUint()), int(0));
|
|
58
|
+
sum.assign(sum.add(texel.mul(weightsH.element(int(i + HALF_KERNEL)))));
|
|
59
|
+
}
|
|
60
|
+
textureStore(intermediateWriteNode, uvec2(cx, cy), sum).toWriteOnly();
|
|
61
|
+
});
|
|
62
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
63
|
+
const verticalPass = Fn(() => {
|
|
64
|
+
const idx = instanceIndex;
|
|
65
|
+
const cx = idx.mod(cw);
|
|
66
|
+
const cy = idx.div(cw);
|
|
67
|
+
If(cy.lessThan(ch), () => {
|
|
68
|
+
const sum = vec4(0).toVar();
|
|
69
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
70
|
+
const texel = textureLoad(intermediateReadNode, uvec2(cx, cy.toInt().add(int(i)).clamp(int(0), computeHm1).toUint()), int(0));
|
|
71
|
+
sum.assign(sum.add(texel.mul(weightsV.element(int(i + HALF_KERNEL)))));
|
|
72
|
+
}
|
|
73
|
+
textureStore(outputNode, uvec2(cx, cy), sum).toWriteOnly();
|
|
74
|
+
});
|
|
75
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
76
|
+
function updateWeights() {
|
|
77
|
+
const pixelRadius = lastRadius < 0 ? 4 : lastRadius;
|
|
78
|
+
const sigmaH = Math.max(pixelRadius * .5, .001);
|
|
79
|
+
const sigmaV = Math.max(sigmaH / scaleY, .001);
|
|
80
|
+
const newH = new Array(KERNEL_SIZE);
|
|
81
|
+
const newV = new Array(KERNEL_SIZE);
|
|
82
|
+
let totalH = 0, totalV = 0;
|
|
83
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
84
|
+
const h = Math.exp(-(i * i) / (2 * sigmaH * sigmaH));
|
|
85
|
+
const v = Math.exp(-(i * i) / (2 * sigmaV * sigmaV));
|
|
86
|
+
newH[i + HALF_KERNEL] = h;
|
|
87
|
+
newV[i + HALF_KERNEL] = v;
|
|
88
|
+
totalH += h;
|
|
89
|
+
totalV += v;
|
|
90
|
+
}
|
|
91
|
+
for (let i = 0; i < KERNEL_SIZE; i++) {
|
|
92
|
+
newH[i] /= totalH;
|
|
93
|
+
newV[i] /= totalV;
|
|
94
|
+
}
|
|
95
|
+
weightsH.array = newH;
|
|
96
|
+
weightsV.array = newV;
|
|
97
|
+
}
|
|
98
|
+
function updateRadius(pixelRadius) {
|
|
99
|
+
if (Math.abs(pixelRadius - lastRadius) < .01) return;
|
|
100
|
+
lastRadius = pixelRadius;
|
|
101
|
+
updateWeights();
|
|
102
|
+
}
|
|
103
|
+
updateRadius(4);
|
|
104
|
+
return {
|
|
105
|
+
computeNodes: [horizontalPass, verticalPass],
|
|
106
|
+
outputTexture: outputTex,
|
|
107
|
+
updateRadius,
|
|
108
|
+
computeWidth,
|
|
109
|
+
computeHeight,
|
|
110
|
+
setInputDimensions: (newW, newH) => {
|
|
111
|
+
inputWidthU.value = newW;
|
|
112
|
+
inputHeightU.value = newH;
|
|
113
|
+
const newScaleY = newH / computeHeight;
|
|
114
|
+
if (Math.abs(newScaleY - scaleY) > .001) {
|
|
115
|
+
scaleY = newScaleY;
|
|
116
|
+
updateWeights();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function createVariableGaussianBlurCompute(inputTexture, inputWidth, inputHeight, onCleanup, halfKernel = DEFAULT_HALF_KERNEL, computeWidth = DEFAULT_COMPUTE_WIDTH, computeHeight = 640) {
|
|
122
|
+
const HALF_KERNEL = halfKernel;
|
|
123
|
+
const FIXED_WEIGHTS = buildFixedWeights(HALF_KERNEL);
|
|
124
|
+
const blurMapTex = new StorageTexture(computeWidth, computeHeight);
|
|
125
|
+
blurMapTex.type = FloatType;
|
|
126
|
+
const blurMapWriteNode = storageTexture(blurMapTex);
|
|
127
|
+
const blurMapReadNode = storageTexture(blurMapTex).toReadOnly();
|
|
128
|
+
const intermediateTex = new StorageTexture(computeWidth, computeHeight);
|
|
129
|
+
intermediateTex.type = FloatType;
|
|
130
|
+
const outputTex = new StorageTexture(computeWidth, computeHeight);
|
|
131
|
+
outputTex.type = FloatType;
|
|
132
|
+
onCleanup(() => {
|
|
133
|
+
blurMapTex.dispose();
|
|
134
|
+
intermediateTex.dispose();
|
|
135
|
+
outputTex.dispose();
|
|
136
|
+
});
|
|
137
|
+
const intermediateWriteNode = storageTexture(intermediateTex);
|
|
138
|
+
const intermediateReadNode = storageTexture(intermediateTex).toReadOnly();
|
|
139
|
+
const outputNode = storageTexture(outputTex);
|
|
140
|
+
const weights = uniformArray(FIXED_WEIGHTS, "float");
|
|
141
|
+
const inputWidthU = uniform(inputWidth);
|
|
142
|
+
const inputHeightU = uniform(inputHeight);
|
|
143
|
+
const scaleYU = uniform(inputHeight / computeHeight);
|
|
144
|
+
const cw = uint(computeWidth);
|
|
145
|
+
const ch = uint(computeHeight);
|
|
146
|
+
const computeHm1 = int(computeHeight - 1);
|
|
147
|
+
const inputWm1 = int(inputWidthU.sub(1));
|
|
148
|
+
const inputHm1 = int(inputHeightU.sub(1));
|
|
149
|
+
const invHalf = float(1 / HALF_KERNEL);
|
|
150
|
+
const passthroughThreshold = float(PASSTHROUGH_THRESHOLD);
|
|
151
|
+
return {
|
|
152
|
+
computeNodes: [Fn(() => {
|
|
153
|
+
const idx = instanceIndex;
|
|
154
|
+
const cx = idx.mod(cw);
|
|
155
|
+
const cy = idx.div(cw);
|
|
156
|
+
If(cy.lessThan(ch), () => {
|
|
157
|
+
const blurRadius = textureLoad(blurMapReadNode, uvec2(cx, cy), int(0)).r;
|
|
158
|
+
const inputCx = cx.toFloat().add(float(.5)).mul(inputWidthU).div(float(computeWidth)).sub(float(.5));
|
|
159
|
+
const inputCy = cy.toFloat().add(float(.5)).mul(inputHeightU).div(float(computeHeight)).sub(float(.5));
|
|
160
|
+
const inputCxF = inputCx;
|
|
161
|
+
const inputCyI = inputCy.round().toInt().clamp(int(0), inputHm1);
|
|
162
|
+
If(blurRadius.lessThan(passthroughThreshold), () => {
|
|
163
|
+
const texel = textureLoad(inputTexture, uvec2(inputCxF.round().toInt().clamp(int(0), inputWm1).toUint(), inputCyI.toUint()), int(0));
|
|
164
|
+
textureStore(intermediateWriteNode, uvec2(cx, cy), texel).toWriteOnly();
|
|
165
|
+
}).Else(() => {
|
|
166
|
+
const sum = vec4(0).toVar();
|
|
167
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
168
|
+
const offset = float(i).mul(invHalf).mul(blurRadius);
|
|
169
|
+
const texel = textureLoad(inputTexture, uvec2(inputCxF.add(offset).round().toInt().clamp(int(0), inputWm1).toUint(), inputCyI.toUint()), int(0));
|
|
170
|
+
sum.assign(sum.add(texel.mul(weights.element(int(i + HALF_KERNEL)))));
|
|
171
|
+
}
|
|
172
|
+
textureStore(intermediateWriteNode, uvec2(cx, cy), sum).toWriteOnly();
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
})().compute(computeWidth * computeHeight, [256]), Fn(() => {
|
|
176
|
+
const idx = instanceIndex;
|
|
177
|
+
const cx = idx.mod(cw);
|
|
178
|
+
const cy = idx.div(cw);
|
|
179
|
+
If(cy.lessThan(ch), () => {
|
|
180
|
+
const blurRadius = textureLoad(blurMapReadNode, uvec2(cx, cy), int(0)).r;
|
|
181
|
+
If(blurRadius.lessThan(passthroughThreshold), () => {
|
|
182
|
+
const texel = textureLoad(intermediateReadNode, uvec2(cx, cy), int(0));
|
|
183
|
+
textureStore(outputNode, uvec2(cx, cy), texel).toWriteOnly();
|
|
184
|
+
}).Else(() => {
|
|
185
|
+
const sum = vec4(0).toVar();
|
|
186
|
+
const yi = cy.toInt();
|
|
187
|
+
const radiusComputeY = blurRadius.div(scaleYU);
|
|
188
|
+
for (let i = -HALF_KERNEL; i <= HALF_KERNEL; i++) {
|
|
189
|
+
const offset = float(i).mul(invHalf).mul(radiusComputeY);
|
|
190
|
+
const texel = textureLoad(intermediateReadNode, uvec2(cx, yi.add(offset.round().toInt()).clamp(int(0), computeHm1).toUint()), int(0));
|
|
191
|
+
sum.assign(sum.add(texel.mul(weights.element(int(i + HALF_KERNEL)))));
|
|
192
|
+
}
|
|
193
|
+
textureStore(outputNode, uvec2(cx, cy), sum).toWriteOnly();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
})().compute(computeWidth * computeHeight, [256])],
|
|
197
|
+
outputTexture: outputTex,
|
|
198
|
+
blurMapTexture: blurMapTex,
|
|
199
|
+
blurMapWriteNode,
|
|
200
|
+
computeWidth,
|
|
201
|
+
computeHeight,
|
|
202
|
+
setInputDimensions: (newW, newH) => {
|
|
203
|
+
inputWidthU.value = newW;
|
|
204
|
+
inputHeightU.value = newH;
|
|
205
|
+
scaleYU.value = newH / computeHeight;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export { createVariableGaussianBlurCompute as i, DEFAULT_COMPUTE_WIDTH as n, createGaussianBlurCompute as r, DEFAULT_COMPUTE_HEIGHT as t };
|
package/dist/core/index.js
CHANGED
|
@@ -5,64 +5,64 @@ import "./AngularBlur-BgZWbEjj.js";
|
|
|
5
5
|
import "./Ascii-BwSMmD6Z.js";
|
|
6
6
|
import "./colorMixing-BPpDnR5I.js";
|
|
7
7
|
import { t as createAnimatedTime } from "./time-DUqSFWvT.js";
|
|
8
|
-
import "./Aurora-
|
|
8
|
+
import "./Aurora-KcUDr49P.js";
|
|
9
9
|
import "./Beam-CAnoOWgt.js";
|
|
10
10
|
import "./Blob-CuRSRXmA.js";
|
|
11
|
-
import "./computeBlur-
|
|
12
|
-
import "./Blur-
|
|
11
|
+
import "./computeBlur-DCRhuYEi.js";
|
|
12
|
+
import "./Blur-DG7lJKPo.js";
|
|
13
13
|
import "./BrightnessContrast-CJTOpQCn.js";
|
|
14
14
|
import "./Bulge-Chpbxxzj.js";
|
|
15
|
-
import "./ChannelBlur-
|
|
15
|
+
import "./ChannelBlur-BhcCkwcO.js";
|
|
16
16
|
import "./Checkerboard-ucave4-a.js";
|
|
17
17
|
import "./ChromaFlow-DxQaUqPL.js";
|
|
18
18
|
import "./ChromaticAberration-DsMj-vBw.js";
|
|
19
19
|
import "./Circle-QgCuVo44.js";
|
|
20
20
|
import "./ConcentricSpin-Crfxti93.js";
|
|
21
21
|
import "./ConicGradient-CQAPYlQg.js";
|
|
22
|
-
import "./ContourLines-
|
|
22
|
+
import "./ContourLines-tDBvQOvb.js";
|
|
23
23
|
import "./sdf-DyC2H_qS.js";
|
|
24
24
|
import "./Crescent-BkRt-XWy.js";
|
|
25
25
|
import "./Cross-kkY7feuC.js";
|
|
26
26
|
import "./CRTScreen-CTwXU-NX.js";
|
|
27
27
|
import "./Crystal-COGiLVvV.js";
|
|
28
28
|
import "./CursorRipples-D-cfjHY5.js";
|
|
29
|
-
import "./CursorTrail-
|
|
29
|
+
import "./CursorTrail-CgRMXbTG.js";
|
|
30
30
|
import "./DiamondGradient-BC3ugP8a.js";
|
|
31
31
|
import "./DiffuseBlur-eyM1v3ad.js";
|
|
32
32
|
import "./Dither-CDfDotR6.js";
|
|
33
33
|
import "./DOMTexture-D-RkeyMs.js";
|
|
34
34
|
import "./DotGrid-T9YbgC3V.js";
|
|
35
|
-
import "./DropShadow-
|
|
36
|
-
import "./Duotone-
|
|
35
|
+
import "./DropShadow-B7FzTp4H.js";
|
|
36
|
+
import "./Duotone-CqQ0NMxS.js";
|
|
37
37
|
import "./Ellipse-CXxGqTYI.js";
|
|
38
38
|
import "./Emboss-LU-6cckT.js";
|
|
39
39
|
import "./FallingLines-CArEXajJ.js";
|
|
40
40
|
import "./FilmGrain-DSJiMtEp.js";
|
|
41
|
-
import "./FloatingParticles-
|
|
41
|
+
import "./FloatingParticles-DpYA0_TE.js";
|
|
42
42
|
import "./Flower-MAwlZEv8.js";
|
|
43
43
|
import "./FlowField-RyqiRxyI.js";
|
|
44
44
|
import "./FlowingGradient-C0Zoyfd6.js";
|
|
45
45
|
import "./Fog-BeKcPcTq.js";
|
|
46
|
-
import "./Form3D-
|
|
47
|
-
import "./Glass-
|
|
46
|
+
import "./Form3D-Bufw6tZb.js";
|
|
47
|
+
import "./Glass-Bz9IKI2q.js";
|
|
48
48
|
import "./GlassTiles-Dgh6nOaE.js";
|
|
49
49
|
import "./Glitch-BsbzLahF.js";
|
|
50
|
-
import "./Glow-
|
|
50
|
+
import "./Glow-CUv1yHLZ.js";
|
|
51
51
|
import "./Godrays-D1LINbut.js";
|
|
52
52
|
import "./Grayscale-Ri-695Uh.js";
|
|
53
53
|
import "./Grid-BYSsAIEv.js";
|
|
54
|
-
import "./GridDistortion-
|
|
54
|
+
import "./GridDistortion-SRyevgsp.js";
|
|
55
55
|
import "./Group-CkhjTW59.js";
|
|
56
56
|
import "./Halftone-BUCDTTAU.js";
|
|
57
57
|
import "./HexGrid-BUiDrehv.js";
|
|
58
|
-
import "./HueShift-
|
|
59
|
-
import "./ImageTexture-
|
|
58
|
+
import "./HueShift-ctEX5vfo.js";
|
|
59
|
+
import "./ImageTexture-uxj4LpF7.js";
|
|
60
60
|
import "./Invert-azYrcDMi.js";
|
|
61
61
|
import "./Kaleidoscope-CFWtKisp.js";
|
|
62
62
|
import "./LensFlare-ttrXgfea.js";
|
|
63
63
|
import "./LinearBlur-By2aD8OO.js";
|
|
64
64
|
import "./LinearGradient-CM02z32l.js";
|
|
65
|
-
import "./Liquify-
|
|
65
|
+
import "./Liquify-p-_qcb1f.js";
|
|
66
66
|
import "./Mirror-B7XmfGdw.js";
|
|
67
67
|
import "./MultiPointGradient-8zGSIM4U.js";
|
|
68
68
|
import "./Neon-CMmGJzPy.js";
|
|
@@ -73,16 +73,16 @@ import "./Plasma-DGCw0cd7.js";
|
|
|
73
73
|
import "./PolarCoordinates-CMYCFT4S.js";
|
|
74
74
|
import "./Polygon-CsCOt5YE.js";
|
|
75
75
|
import "./Posterize-Blv9pzPT.js";
|
|
76
|
-
import "./ProgressiveBlur-
|
|
76
|
+
import "./ProgressiveBlur-NbvxFfRa.js";
|
|
77
77
|
import "./RadialGradient-De0gtdh3.js";
|
|
78
78
|
import "./RectangularCoordinates-8Sa2GaDy.js";
|
|
79
79
|
import "./Ring-kHH-DIDQ.js";
|
|
80
80
|
import "./Ripples-Bf6Zwg6X.js";
|
|
81
81
|
import "./RoundedRect-B0sWh2BN.js";
|
|
82
|
-
import "./Saturation-
|
|
83
|
-
import "./Sharpness-
|
|
84
|
-
import "./Shatter-
|
|
85
|
-
import "./SimplexNoise-
|
|
82
|
+
import "./Saturation-DCFAIUvZ.js";
|
|
83
|
+
import "./Sharpness-DSpEoCSL.js";
|
|
84
|
+
import "./Shatter-ByKkCYTR.js";
|
|
85
|
+
import "./SimplexNoise-CMuU8n27.js";
|
|
86
86
|
import "./SineWave-VTNDSK_g.js";
|
|
87
87
|
import "./Smoke-9MJIAKq7.js";
|
|
88
88
|
import "./SmokeFill-qV2iRIts.js";
|
|
@@ -95,25 +95,25 @@ import "./Strands-DOthZNHt.js";
|
|
|
95
95
|
import "./Stretch--GV6hbru.js";
|
|
96
96
|
import "./Stripes-CFCXw1_N.js";
|
|
97
97
|
import "./StudioBackground-DJr-cxOL.js";
|
|
98
|
-
import "./Swirl-
|
|
99
|
-
import "./TiltShift-
|
|
100
|
-
import "./Tint-
|
|
98
|
+
import "./Swirl-B_KxdaX2.js";
|
|
99
|
+
import "./TiltShift-BSAyR0Me.js";
|
|
100
|
+
import "./Tint-DdvnpzEJ.js";
|
|
101
101
|
import "./Trapezoid-Co0sIA73.js";
|
|
102
|
-
import "./Tritone-
|
|
102
|
+
import "./Tritone-Ckb6hTkI.js";
|
|
103
103
|
import "./Truchet-CkFSkniR.js";
|
|
104
104
|
import "./Twirl-v8pLqUTN.js";
|
|
105
105
|
import "./Vesica-CxP7UD0a.js";
|
|
106
106
|
import "./VHS-mKd1QBBj.js";
|
|
107
107
|
import "./Vibrance-WR5yQv_9.js";
|
|
108
108
|
import "./browser-D8zonASQ.js";
|
|
109
|
-
import "./VideoTexture-
|
|
109
|
+
import "./VideoTexture-BMSdfLf_.js";
|
|
110
110
|
import "./Vignette-hAIKTi35.js";
|
|
111
111
|
import "./Voronoi-DOGmwUSK.js";
|
|
112
112
|
import "./WaveDistortion-BGdgj3Iz.js";
|
|
113
113
|
import "./Weave-CIP_EUPa.js";
|
|
114
|
-
import "./WebcamTexture-
|
|
114
|
+
import "./WebcamTexture-Ds9IrtRn.js";
|
|
115
115
|
import "./ZoomBlur-BuIVpHGG.js";
|
|
116
|
-
import { t as getAllShaders } from "./shaderRegistry-
|
|
116
|
+
import { t as getAllShaders } from "./shaderRegistry-DFzzFEKX.js";
|
|
117
117
|
import { Material, Mesh, MeshBasicNodeMaterial, OrthographicCamera, PlaneGeometry, SRGBColorSpace, Scene, Vector2, WebGPURenderer } from "three/webgpu";
|
|
118
118
|
import { WebGLRenderer } from "three";
|
|
119
119
|
import { PI, abs, add, atan, clamp, convertToTexture, cos, div, dot, float, fract, max, min, mix, mul, pow, screenUV, sign, sin, smoothstep, sqrt, step, sub, time, uniform, uv, vec2, vec3, vec4 } from "three/tsl";
|
|
@@ -775,11 +775,6 @@ function shaderRenderer() {
|
|
|
775
775
|
let previousTextures = /* @__PURE__ */ new Set();
|
|
776
776
|
let pendingResize = null;
|
|
777
777
|
let isResizeScheduled = false;
|
|
778
|
-
const COMPUTE_REBUILD_DEBOUNCE_MS = 200;
|
|
779
|
-
const COMPUTE_REBUILD_SKIP_TOLERANCE = .02;
|
|
780
|
-
let computeRebuildTimeout = null;
|
|
781
|
-
let lastComputeRebuildWidth = 0;
|
|
782
|
-
let lastComputeRebuildHeight = 0;
|
|
783
778
|
const updateRendererDimensions = (width, height) => {
|
|
784
779
|
if (width <= 0 || height <= 0) return;
|
|
785
780
|
if (width === currentWidth && height === currentHeight) return;
|
|
@@ -798,8 +793,6 @@ function shaderRenderer() {
|
|
|
798
793
|
currentHeight = height$1;
|
|
799
794
|
if (!hasInitialDimensions) {
|
|
800
795
|
hasInitialDimensions = true;
|
|
801
|
-
lastComputeRebuildWidth = width$1;
|
|
802
|
-
lastComputeRebuildHeight = height$1;
|
|
803
796
|
if (nodeRegistry.nodes.size > 0 && materialUpdateBatchRAF === null) materialUpdateBatchRAF = requestAnimationFrame(() => {
|
|
804
797
|
materialUpdateBatchRAF = null;
|
|
805
798
|
updateMaterial();
|
|
@@ -828,27 +821,6 @@ function shaderRenderer() {
|
|
|
828
821
|
}
|
|
829
822
|
});
|
|
830
823
|
});
|
|
831
|
-
let hasComputeNodes = false;
|
|
832
|
-
for (const ni of nodeRegistry.nodes.values()) if (ni.computeGetNodes) {
|
|
833
|
-
hasComputeNodes = true;
|
|
834
|
-
break;
|
|
835
|
-
}
|
|
836
|
-
if (hasComputeNodes) {
|
|
837
|
-
const lastW = lastComputeRebuildWidth;
|
|
838
|
-
const lastH = lastComputeRebuildHeight;
|
|
839
|
-
const widthDelta = lastW > 0 ? Math.abs(width$1 - lastW) / lastW : 1;
|
|
840
|
-
const heightDelta = lastH > 0 ? Math.abs(height$1 - lastH) / lastH : 1;
|
|
841
|
-
if (!(widthDelta < COMPUTE_REBUILD_SKIP_TOLERANCE && heightDelta < COMPUTE_REBUILD_SKIP_TOLERANCE)) {
|
|
842
|
-
if (computeRebuildTimeout !== null) clearTimeout(computeRebuildTimeout);
|
|
843
|
-
computeRebuildTimeout = setTimeout(() => {
|
|
844
|
-
computeRebuildTimeout = null;
|
|
845
|
-
if (materialUpdateBatchRAF === null) materialUpdateBatchRAF = requestAnimationFrame(() => {
|
|
846
|
-
materialUpdateBatchRAF = null;
|
|
847
|
-
updateMaterial();
|
|
848
|
-
});
|
|
849
|
-
}, COMPUTE_REBUILD_DEBOUNCE_MS);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
824
|
lastRenderTime = 0;
|
|
853
825
|
renderFrame();
|
|
854
826
|
});
|
|
@@ -943,8 +915,6 @@ function shaderRenderer() {
|
|
|
943
915
|
material = newMaterial;
|
|
944
916
|
needsMaterialRefresh = false;
|
|
945
917
|
lastComposedNodes = currentComposedNodes;
|
|
946
|
-
lastComputeRebuildWidth = currentWidth;
|
|
947
|
-
lastComputeRebuildHeight = currentHeight;
|
|
948
918
|
if (!hasEmittedReady && currentComposedNodes.size > 0) firstRenderPending = true;
|
|
949
919
|
}
|
|
950
920
|
}
|
|
@@ -2222,10 +2192,6 @@ function shaderRenderer() {
|
|
|
2222
2192
|
};
|
|
2223
2193
|
const cleanup = () => {
|
|
2224
2194
|
if (initializationAbortController) initializationAbortController.abort();
|
|
2225
|
-
if (computeRebuildTimeout !== null) {
|
|
2226
|
-
clearTimeout(computeRebuildTimeout);
|
|
2227
|
-
computeRebuildTimeout = null;
|
|
2228
|
-
}
|
|
2229
2195
|
if (resizeObserver) {
|
|
2230
2196
|
resizeObserver.disconnect();
|
|
2231
2197
|
resizeObserver = null;
|