shaders 2.5.109 → 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/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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as transformColor, l as transformPosition, o as transformColorSpace, t as colorSpaceOptions } from "./transformations-B5lM6fYX.js";
|
|
2
2
|
import { t as mixColors } from "./colorMixing-BPpDnR5I.js";
|
|
3
3
|
import { t as createAnimatedTime } from "./time-DUqSFWvT.js";
|
|
4
|
-
import { Fn, clamp, exp, float, fract, mix, mx_noise_float, pow, screenUV, sin, smoothstep,
|
|
4
|
+
import { Fn, clamp, exp, float, fract, mix, mx_noise_float, pow, screenUV, sin, smoothstep, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
const componentDefinition = {
|
|
6
6
|
name: "Aurora",
|
|
7
7
|
category: "Textures",
|
|
@@ -75,6 +75,7 @@ const componentDefinition = {
|
|
|
75
75
|
},
|
|
76
76
|
curtainCount: {
|
|
77
77
|
default: 4,
|
|
78
|
+
compileTime: true,
|
|
78
79
|
description: "Number of aurora curtain layers",
|
|
79
80
|
ui: {
|
|
80
81
|
type: "range",
|
|
@@ -167,7 +168,7 @@ const componentDefinition = {
|
|
|
167
168
|
const csMode = uniforms.colorSpace.uniform.value;
|
|
168
169
|
const balanceExp = mix(float(2.5), float(.4), uniforms.balance.uniform.mul(.01));
|
|
169
170
|
const intensity = uniforms.intensity.uniform.mul(.018);
|
|
170
|
-
const curtainCount = uniforms.curtainCount.uniform;
|
|
171
|
+
const curtainCount = uniforms.curtainCount.uniform.value | 0;
|
|
171
172
|
const waviness = uniforms.waviness.uniform.mul(.01);
|
|
172
173
|
const rayAmount = uniforms.rayDensity.uniform.mul(.01);
|
|
173
174
|
const auroraHeight = uniforms.height.uniform.mul(.01);
|
|
@@ -209,18 +210,24 @@ const componentDefinition = {
|
|
|
209
210
|
const a1 = auroraCurtain(uv$1, float(0), float(0));
|
|
210
211
|
weightedT.assign(weightedT.add(a1.x.mul(a1.y)));
|
|
211
212
|
totalAlpha.assign(totalAlpha.add(a1.y));
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
213
|
+
if (curtainCount >= 2) {
|
|
214
|
+
const a2 = auroraCurtain(uv$1, float(1), float(3.1));
|
|
215
|
+
const w2 = a2.y.mul(.65);
|
|
216
|
+
weightedT.assign(weightedT.add(a2.x.mul(w2)));
|
|
217
|
+
totalAlpha.assign(totalAlpha.add(w2));
|
|
218
|
+
}
|
|
219
|
+
if (curtainCount >= 3) {
|
|
220
|
+
const a3 = auroraCurtain(uv$1, float(2), float(6.7));
|
|
221
|
+
const w3 = a3.y.mul(.45);
|
|
222
|
+
weightedT.assign(weightedT.add(a3.x.mul(w3)));
|
|
223
|
+
totalAlpha.assign(totalAlpha.add(w3));
|
|
224
|
+
}
|
|
225
|
+
if (curtainCount >= 4) {
|
|
226
|
+
const a4 = auroraCurtain(uv$1, float(3), float(9.4));
|
|
227
|
+
const w4 = a4.y.mul(.3);
|
|
228
|
+
weightedT.assign(weightedT.add(a4.x.mul(w4)));
|
|
229
|
+
totalAlpha.assign(totalAlpha.add(w4));
|
|
230
|
+
}
|
|
224
231
|
const avgT = pow(weightedT.div(totalAlpha.add(.001)), balanceExp);
|
|
225
232
|
const lowToMid = smoothstep(float(0), float(.2), avgT);
|
|
226
233
|
const midToHigh = smoothstep(float(.4), float(.85), avgT);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Fn, If, clamp, convertToTexture, dot, float, instanceIndex, int, mix, pow, screenUV, texture, textureLoad, textureStore, uint, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
2
|
+
import { i as createVariableGaussianBlurCompute, r as createGaussianBlurCompute } from "./computeBlur-DCRhuYEi.js";
|
|
3
|
+
import { Fn, If, clamp, convertToTexture, dot, float, instanceIndex, int, mix, pow, screenUV, texture, textureLoad, textureStore, uint, uniform, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "Blur",
|
|
6
6
|
category: "Blurs",
|
|
@@ -19,7 +19,7 @@ const componentDefinition = {
|
|
|
19
19
|
group: "Effect"
|
|
20
20
|
}
|
|
21
21
|
} },
|
|
22
|
-
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
22
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms, onResize }) => {
|
|
23
23
|
if (!childNode) return null;
|
|
24
24
|
const childTexture = convertToTexture(childNode);
|
|
25
25
|
onCleanup(() => {
|
|
@@ -30,16 +30,21 @@ const componentDefinition = {
|
|
|
30
30
|
const texHeight = Math.round(dimensions.height * dpr);
|
|
31
31
|
const mapInfo = uniforms.intensity.mapComputeInfo;
|
|
32
32
|
if (mapInfo) {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
33
|
+
const blur$1 = createVariableGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
34
|
+
const { computeNodes: blurNodes, outputTexture: outputTexture$1, blurMapWriteNode, computeWidth, computeHeight } = blur$1;
|
|
35
|
+
const inputWidthU = uniform(texWidth);
|
|
36
|
+
const inputHeightU = uniform(texHeight);
|
|
37
|
+
const cw = uint(computeWidth);
|
|
38
|
+
const ch = uint(computeHeight);
|
|
36
39
|
const { sourceTexture, channel, inputMin, inputMax, outputMin, outputMax, curve } = mapInfo;
|
|
37
40
|
const fillBlurMap = Fn(() => {
|
|
38
41
|
const idx = instanceIndex;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
If(
|
|
42
|
-
const
|
|
42
|
+
const cx = idx.mod(cw);
|
|
43
|
+
const cy = idx.div(cw);
|
|
44
|
+
If(cy.lessThan(ch), () => {
|
|
45
|
+
const u = cx.toFloat().add(float(.5)).div(float(computeWidth));
|
|
46
|
+
const v = cy.toFloat().add(float(.5)).div(float(computeHeight));
|
|
47
|
+
const sample = textureLoad(sourceTexture, uvec2(u.mul(inputWidthU).round().toInt().clamp(int(0), int(inputWidthU.sub(1))).toUint(), v.mul(inputHeightU).round().toInt().clamp(int(0), int(inputHeightU.sub(1))).toUint()), int(0));
|
|
43
48
|
let raw;
|
|
44
49
|
if (channel === "alpha") raw = sample.a;
|
|
45
50
|
else if (channel === "alphaInverted") raw = sample.a.oneMinus();
|
|
@@ -47,9 +52,16 @@ const componentDefinition = {
|
|
|
47
52
|
else raw = dot(sample.rgb, vec3(.2126, .7152, .0722));
|
|
48
53
|
const inputRange = inputMax.sub(inputMin).max(float(1e-4));
|
|
49
54
|
const radius = mix(outputMin, outputMax, pow(clamp(raw.sub(inputMin).div(inputRange), float(0), float(1)), pow(float(2), curve.negate().mul(float(2))))).mul(float(.36));
|
|
50
|
-
textureStore(blurMapWriteNode, uvec2(
|
|
55
|
+
textureStore(blurMapWriteNode, uvec2(cx, cy), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
51
56
|
});
|
|
52
|
-
})().compute(
|
|
57
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
58
|
+
onResize(({ width, height }) => {
|
|
59
|
+
const newW = Math.round(width * dpr);
|
|
60
|
+
const newH = Math.round(height * dpr);
|
|
61
|
+
inputWidthU.value = newW;
|
|
62
|
+
inputHeightU.value = newH;
|
|
63
|
+
blur$1.setInputDimensions(newW, newH);
|
|
64
|
+
});
|
|
53
65
|
return {
|
|
54
66
|
outputs: {
|
|
55
67
|
childTexture,
|
|
@@ -58,7 +70,11 @@ const componentDefinition = {
|
|
|
58
70
|
getComputeNodes: () => [fillBlurMap, ...blurNodes]
|
|
59
71
|
};
|
|
60
72
|
}
|
|
61
|
-
const
|
|
73
|
+
const blur = createGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
74
|
+
const { computeNodes, outputTexture, updateRadius } = blur;
|
|
75
|
+
onResize(({ width, height }) => {
|
|
76
|
+
blur.setInputDimensions(Math.round(width * dpr), Math.round(height * dpr));
|
|
77
|
+
});
|
|
62
78
|
return {
|
|
63
79
|
outputs: {
|
|
64
80
|
childTexture,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as createGaussianBlurCompute } from "./computeBlur-DCRhuYEi.js";
|
|
3
3
|
import { Fn, convertToTexture, float, mix, screenUV, texture, vec2, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "ChannelBlur",
|
|
@@ -45,14 +45,18 @@ const componentDefinition = {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
48
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms, onResize }) => {
|
|
49
49
|
if (!childNode) return null;
|
|
50
50
|
const childTexture = convertToTexture(childNode);
|
|
51
51
|
onCleanup(() => {
|
|
52
52
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
53
53
|
});
|
|
54
54
|
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
55
|
-
const
|
|
55
|
+
const blur = createGaussianBlurCompute(childTexture, Math.round(dimensions.width * dpr), Math.round(dimensions.height * dpr), onCleanup);
|
|
56
|
+
const { computeNodes, outputTexture, updateRadius } = blur;
|
|
57
|
+
onResize(({ width, height }) => {
|
|
58
|
+
blur.setInputDimensions(Math.round(width * dpr), Math.round(height * dpr));
|
|
59
|
+
});
|
|
56
60
|
return {
|
|
57
61
|
outputs: {
|
|
58
62
|
childTexture,
|
|
@@ -77,6 +77,7 @@ const componentDefinition = {
|
|
|
77
77
|
default: "luminance",
|
|
78
78
|
description: "Use luminance or alpha channel for contours",
|
|
79
79
|
transform: transformSource,
|
|
80
|
+
compileTime: true,
|
|
80
81
|
ui: {
|
|
81
82
|
type: "select",
|
|
82
83
|
options: [{
|
|
@@ -94,6 +95,7 @@ const componentDefinition = {
|
|
|
94
95
|
default: "source",
|
|
95
96
|
description: "Use source image colors or custom colors",
|
|
96
97
|
transform: transformColorMode,
|
|
98
|
+
compileTime: true,
|
|
97
99
|
ui: {
|
|
98
100
|
type: "select",
|
|
99
101
|
options: [{
|
|
@@ -144,18 +146,17 @@ const componentDefinition = {
|
|
|
144
146
|
const customBgColor = vec3(bgColorVec.x, bgColorVec.y, bgColorVec.z);
|
|
145
147
|
const customBgAlpha = bgColorVec.w;
|
|
146
148
|
const originalColor = childNode;
|
|
147
|
-
const
|
|
148
|
-
const rawSourceValue = uniforms.source.uniform.equal(float(1)).select(originalColor.a, luminance);
|
|
149
|
+
const rawSourceValue = uniforms.source.uniform.value === 1 ? originalColor.a : dot(originalColor.rgb, vec3(.2126, .7152, .0722));
|
|
149
150
|
const scaledValue = pow(isInverted.select(oneMinus(rawSourceValue), rawSourceValue), gamma).mul(levels).add(.5);
|
|
150
151
|
const fw = fwidth(scaledValue).max(float(1e-4));
|
|
151
152
|
const normalizedDist = fract(scaledValue.add(.5)).sub(.5).abs().div(fw);
|
|
152
153
|
const transitionFactor = softness.mul(.99).add(.01);
|
|
153
154
|
const lineMask = smoothstep(lineWidth.mul(oneMinus(transitionFactor)), lineWidth, normalizedDist).oneMinus();
|
|
154
|
-
const
|
|
155
|
-
const lineColor =
|
|
156
|
-
const lineAlpha =
|
|
157
|
-
const bgColor =
|
|
158
|
-
const bgAlpha =
|
|
155
|
+
const colorMode = uniforms.colorMode.uniform.value;
|
|
156
|
+
const lineColor = colorMode === 1 ? customLineColor : originalColor.rgb;
|
|
157
|
+
const lineAlpha = colorMode === 1 ? customLineAlpha : float(1);
|
|
158
|
+
const bgColor = colorMode === 1 ? customBgColor : vec3(0, 0, 0);
|
|
159
|
+
const bgAlpha = colorMode === 1 ? customBgAlpha : float(0);
|
|
159
160
|
return vec4(mix(bgColor, lineColor, lineMask), mix(bgAlpha, lineAlpha, lineMask));
|
|
160
161
|
}
|
|
161
162
|
};
|
|
@@ -79,7 +79,7 @@ const componentDefinition = {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
|
-
computeNode: ({ uniforms, onCleanup,
|
|
82
|
+
computeNode: ({ uniforms, onCleanup, renderer }) => {
|
|
83
83
|
const trailBuffer = attributeArray(GRID_SIZE * GRID_SIZE, "vec4");
|
|
84
84
|
const trailTex = new StorageTexture(GRID_SIZE, GRID_SIZE);
|
|
85
85
|
trailTex.type = FloatType;
|
|
@@ -140,7 +140,7 @@ const componentDefinition = {
|
|
|
140
140
|
const currentTime = Date.now();
|
|
141
141
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
142
142
|
lastTime = currentTime;
|
|
143
|
-
const aspect = dimensions.width / dimensions.height;
|
|
143
|
+
const aspect = Math.max(1, params.dimensions.width) / Math.max(1, params.dimensions.height);
|
|
144
144
|
const radius = uniforms.radius.uniform.value * .1;
|
|
145
145
|
const length$1 = uniforms.length.uniform.value;
|
|
146
146
|
const shrink = uniforms.shrink.uniform.value;
|
|
@@ -177,7 +177,7 @@ const componentDefinition = {
|
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
},
|
|
180
|
-
fragmentNode: ({ uniforms, onBeforeRender, onCleanup,
|
|
180
|
+
fragmentNode: ({ uniforms, onBeforeRender, onCleanup, computeOutputs }) => {
|
|
181
181
|
let trailField;
|
|
182
182
|
if (computeOutputs?.trailTexture) trailField = texture(computeOutputs.trailTexture);
|
|
183
183
|
else {
|
|
@@ -190,11 +190,11 @@ const componentDefinition = {
|
|
|
190
190
|
let prevX = .5;
|
|
191
191
|
let prevY = .5;
|
|
192
192
|
let lastTime = Date.now();
|
|
193
|
-
onBeforeRender(({ pointer }) => {
|
|
193
|
+
onBeforeRender(({ pointer, dimensions }) => {
|
|
194
194
|
const currentTime = Date.now();
|
|
195
195
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
196
196
|
lastTime = currentTime;
|
|
197
|
-
const aspect = dimensions.width / dimensions.height;
|
|
197
|
+
const aspect = Math.max(1, dimensions.width) / Math.max(1, dimensions.height);
|
|
198
198
|
const radius = uniforms.radius.uniform.value * .1;
|
|
199
199
|
const length$1 = uniforms.length.uniform.value;
|
|
200
200
|
const shrink = uniforms.shrink.uniform.value;
|
|
@@ -85,6 +85,7 @@ const componentDefinition = {
|
|
|
85
85
|
cutout: {
|
|
86
86
|
default: false,
|
|
87
87
|
transform: transformBoolean,
|
|
88
|
+
compileTime: true,
|
|
88
89
|
description: "Hide the original layer and show only the shadow",
|
|
89
90
|
ui: {
|
|
90
91
|
type: "checkbox",
|
|
@@ -130,16 +131,21 @@ const componentDefinition = {
|
|
|
130
131
|
}
|
|
131
132
|
return total;
|
|
132
133
|
})().mul(uniforms.intensity.uniform);
|
|
133
|
-
const isCutout = uniforms.cutout.uniform.equal(float(1));
|
|
134
134
|
const shadowColor = uniforms.color.uniform;
|
|
135
|
-
const shadowPremulRGB = shadowColor.rgb.mul(shadowColor.a).mul(shadowAlpha);
|
|
136
135
|
const shadowA = shadowColor.a.mul(shadowAlpha);
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
const cutout = uniforms.cutout.uniform.value === 1;
|
|
137
|
+
let resultRGB;
|
|
138
|
+
let resultA;
|
|
139
|
+
if (cutout) {
|
|
140
|
+
resultA = clamp(shadowA.sub(originalColor.a), float(0), float(1));
|
|
141
|
+
resultRGB = shadowColor.rgb.mul(shadowColor.a).mul(resultA);
|
|
142
|
+
} else {
|
|
143
|
+
const shadowPremulRGB = shadowColor.rgb.mul(shadowColor.a).mul(shadowAlpha);
|
|
144
|
+
const oneMinusOrigA = float(1).sub(originalColor.a);
|
|
145
|
+
resultRGB = originalColor.rgb.add(shadowPremulRGB.mul(oneMinusOrigA));
|
|
146
|
+
resultA = max(originalColor.a.add(shadowA.mul(oneMinusOrigA)), originalColor.a);
|
|
147
|
+
}
|
|
148
|
+
return unpremultiplyAlpha(vec4(resultRGB, resultA));
|
|
143
149
|
}
|
|
144
150
|
};
|
|
145
151
|
var DropShadow_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: "Duotone",
|
|
7
6
|
category: "Adjustments",
|
|
8
7
|
description: "Map colors to two tones based on luminance",
|
|
9
|
-
requiresRTT: true,
|
|
10
8
|
requiresChild: true,
|
|
11
9
|
props: {
|
|
12
10
|
colorA: {
|
|
@@ -54,16 +52,11 @@ const componentDefinition = {
|
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
},
|
|
57
|
-
fragmentNode: ({ uniforms, childNode
|
|
55
|
+
fragmentNode: ({ uniforms, childNode }) => {
|
|
58
56
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
59
|
-
const
|
|
60
|
-
onCleanup(() => {
|
|
61
|
-
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
62
|
-
});
|
|
63
|
-
const inputColor = unpremultiplyAlpha(childTexture.sample(screenUV));
|
|
64
|
-
const luminance = dot(inputColor.rgb, vec3(.299, .587, .114));
|
|
57
|
+
const luminance = dot(vec3(childNode.r, childNode.g, childNode.b), vec3(.299, .587, .114));
|
|
65
58
|
const adjustedLuminance = smoothstep(uniforms.blend.uniform.sub(.5), uniforms.blend.uniform.add(.5), luminance);
|
|
66
|
-
return vec4(mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, adjustedLuminance, uniforms.colorSpace.uniform.value).rgb,
|
|
59
|
+
return vec4(mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, adjustedLuminance, uniforms.colorSpace.uniform.value).rgb, childNode.a);
|
|
67
60
|
}
|
|
68
61
|
};
|
|
69
62
|
var Duotone_default = componentDefinition;
|
|
@@ -206,7 +206,7 @@ const componentDefinition = {
|
|
|
206
206
|
const layerHash = hash2_2(vec2(alpha, float(i).mul(7.919)));
|
|
207
207
|
const speedMod = float(1).add(layerHash.x.sub(.5).mul(speedVar));
|
|
208
208
|
const angleDelta = layerHash.y.sub(.5).mul(angleVar).mul(2);
|
|
209
|
-
const variedAngle = angleRad.add(angleDelta);
|
|
209
|
+
const variedAngle = angleRad.add(angleDelta).toVar();
|
|
210
210
|
const variedDir = vec2(cos(variedAngle), sin(variedAngle));
|
|
211
211
|
const movement = baseMovement.mul(speedMod).add(variedDir.sub(baseMovementDir).mul(animTime));
|
|
212
212
|
const layerParticles = renderParticle(uv$2.mul(size).add(movement).add(offset)).mul(alpha);
|
|
@@ -221,7 +221,11 @@ const componentDefinition = {
|
|
|
221
221
|
const aspectRatio = viewportSize.x.div(viewportSize.y);
|
|
222
222
|
const particles = layeredParticles(vec2(uv$1.x.mul(aspectRatio), uv$1.y).mul(uniforms.particleDensity.uniform));
|
|
223
223
|
const particleAlpha = length(particles);
|
|
224
|
-
if (childNode)
|
|
224
|
+
if (childNode) {
|
|
225
|
+
const mixedColor = mix(childNode.xyz, particles, particleAlpha.greaterThan(.01).select(particleAlpha, 0));
|
|
226
|
+
const pa = particleAlpha.clamp(0, 1);
|
|
227
|
+
return vec4(mixedColor, pa.add(childNode.w.mul(float(1).sub(pa))));
|
|
228
|
+
}
|
|
225
229
|
return vec4(particles, particleAlpha);
|
|
226
230
|
}
|
|
227
231
|
};
|
|
@@ -338,12 +338,24 @@ const componentDefinition = {
|
|
|
338
338
|
});
|
|
339
339
|
const t = createAnimatedTime(params, uniforms.speed);
|
|
340
340
|
const shapeType = uniforms.shape3dType.uniform.value;
|
|
341
|
+
let _parseCacheKey = null;
|
|
342
|
+
let _parseCacheVal = {};
|
|
341
343
|
const parse = (raw) => {
|
|
344
|
+
let key;
|
|
342
345
|
try {
|
|
343
|
-
|
|
346
|
+
key = typeof raw === "string" ? raw : JSON.stringify(raw);
|
|
344
347
|
} catch {
|
|
345
|
-
|
|
348
|
+
key = null;
|
|
346
349
|
}
|
|
350
|
+
if (key !== null && key === _parseCacheKey) return _parseCacheVal;
|
|
351
|
+
try {
|
|
352
|
+
_parseCacheVal = JSON.parse(key ?? (typeof raw === "string" ? raw : "{}"));
|
|
353
|
+
_parseCacheKey = key;
|
|
354
|
+
} catch {
|
|
355
|
+
_parseCacheVal = {};
|
|
356
|
+
_parseCacheKey = null;
|
|
357
|
+
}
|
|
358
|
+
return _parseCacheVal;
|
|
347
359
|
};
|
|
348
360
|
const cfg0 = parse(uniforms.shape3d.uniform.value);
|
|
349
361
|
const DEG = Math.PI / 180;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as transformColor, l as transformPosition } from "./transformations-B5lM6fYX.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as createGaussianBlurCompute } from "./computeBlur-DCRhuYEi.js";
|
|
3
3
|
import { n as createAnalyticSdfSampler, r as createSvgSdfSampler } from "./sdf-DyC2H_qS.js";
|
|
4
4
|
import { Fn, If, clamp, convertToTexture, dot, exp2, float, max, mix, pow, screenUV, smoothstep, sqrt, texture, uniform, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
var GOLDEN_ANGLE = 2.3999632297286535;
|
|
@@ -391,7 +391,7 @@ const componentDefinition = {
|
|
|
391
391
|
description: "Active SDF shape type — triggers recompile when shape is switched. When empty, derived from shape JSON at mount time."
|
|
392
392
|
}
|
|
393
393
|
},
|
|
394
|
-
computeNode: ({ uniforms, childNode, onCleanup, dimensions, renderer }) => {
|
|
394
|
+
computeNode: ({ uniforms, childNode, onCleanup, dimensions, renderer, onResize }) => {
|
|
395
395
|
if (!childNode) return null;
|
|
396
396
|
const blurValue = uniforms.blur.uniform.value;
|
|
397
397
|
if (typeof blurValue === "number" && blurValue <= 0) return null;
|
|
@@ -400,7 +400,11 @@ const componentDefinition = {
|
|
|
400
400
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
401
401
|
});
|
|
402
402
|
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
403
|
-
const
|
|
403
|
+
const blur = createGaussianBlurCompute(childTexture, Math.round(dimensions.width * dpr), Math.round(dimensions.height * dpr), onCleanup);
|
|
404
|
+
const { computeNodes, outputTexture, updateRadius } = blur;
|
|
405
|
+
onResize(({ width, height }) => {
|
|
406
|
+
blur.setInputDimensions(Math.round(width * dpr), Math.round(height * dpr));
|
|
407
|
+
});
|
|
404
408
|
return {
|
|
405
409
|
outputs: {
|
|
406
410
|
childTexture,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { i as createVariableGaussianBlurCompute, n as DEFAULT_COMPUTE_WIDTH, t as DEFAULT_COMPUTE_HEIGHT } from "./computeBlur-DCRhuYEi.js";
|
|
3
|
+
import { StorageTexture } from "three/webgpu";
|
|
4
|
+
import { FloatType } from "three";
|
|
5
|
+
import { Fn, If, clamp, convertToTexture, dot, float, instanceIndex, int, max, mix, pow, screenUV, storageTexture, texture, textureLoad, textureStore, uint, uniform, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
6
|
const componentDefinition = {
|
|
5
7
|
name: "Glow",
|
|
6
8
|
category: "Stylize",
|
|
@@ -14,8 +16,8 @@ const componentDefinition = {
|
|
|
14
16
|
ui: {
|
|
15
17
|
type: ["range", "map"],
|
|
16
18
|
min: 0,
|
|
17
|
-
max:
|
|
18
|
-
step: .
|
|
19
|
+
max: 50,
|
|
20
|
+
step: .5,
|
|
19
21
|
label: "Intensity",
|
|
20
22
|
group: "Effect"
|
|
21
23
|
}
|
|
@@ -27,26 +29,28 @@ const componentDefinition = {
|
|
|
27
29
|
type: ["range", "map"],
|
|
28
30
|
min: 0,
|
|
29
31
|
max: 1,
|
|
30
|
-
step: .
|
|
32
|
+
step: .05,
|
|
31
33
|
label: "Threshold",
|
|
32
34
|
group: "Effect"
|
|
33
35
|
}
|
|
34
36
|
},
|
|
35
37
|
size: {
|
|
36
|
-
default:
|
|
37
|
-
description: "
|
|
38
|
+
default: 25,
|
|
39
|
+
description: "Glow spread in pixels (clean up to ~72px, mild banding above)",
|
|
40
|
+
compileTimeWhen: (prev, next) => prev === 0 !== (next === 0),
|
|
38
41
|
ui: {
|
|
39
42
|
type: ["range", "map"],
|
|
40
|
-
min:
|
|
41
|
-
max:
|
|
42
|
-
step:
|
|
43
|
+
min: 0,
|
|
44
|
+
max: 100,
|
|
45
|
+
step: 1,
|
|
43
46
|
label: "Glow Size",
|
|
44
47
|
group: "Effect"
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
},
|
|
48
|
-
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
51
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms, onResize }) => {
|
|
49
52
|
if (!childNode) return null;
|
|
53
|
+
if (uniforms.size.uniform.value === 0) return null;
|
|
50
54
|
const childTexture = convertToTexture(childNode);
|
|
51
55
|
onCleanup(() => {
|
|
52
56
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
@@ -54,63 +58,72 @@ const componentDefinition = {
|
|
|
54
58
|
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
55
59
|
const texWidth = Math.round(dimensions.width * dpr);
|
|
56
60
|
const texHeight = Math.round(dimensions.height * dpr);
|
|
61
|
+
const computeWidth = DEFAULT_COMPUTE_WIDTH;
|
|
62
|
+
const computeHeight = 640;
|
|
63
|
+
const brightTex = new StorageTexture(computeWidth, computeHeight);
|
|
64
|
+
brightTex.type = FloatType;
|
|
65
|
+
const brightWriteNode = storageTexture(brightTex);
|
|
66
|
+
const brightReadNode = storageTexture(brightTex).toReadOnly();
|
|
67
|
+
onCleanup(() => {
|
|
68
|
+
brightTex.dispose();
|
|
69
|
+
});
|
|
70
|
+
const { computeNodes: blurNodes, outputTexture: blurredTex, blurMapWriteNode } = createVariableGaussianBlurCompute(brightReadNode, computeWidth, computeHeight, onCleanup);
|
|
71
|
+
const inputWidthU = uniform(texWidth);
|
|
72
|
+
const inputHeightU = uniform(texHeight);
|
|
73
|
+
const cw = uint(computeWidth);
|
|
74
|
+
const ch = uint(computeHeight);
|
|
57
75
|
const sizeMapInfo = uniforms.size.mapComputeInfo;
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
const extractAndFill = Fn(() => {
|
|
77
|
+
const idx = instanceIndex;
|
|
78
|
+
const cx = idx.mod(cw);
|
|
79
|
+
const cy = idx.div(cw);
|
|
80
|
+
If(cy.lessThan(ch), () => {
|
|
81
|
+
const u = cx.toFloat().add(float(.5)).div(float(computeWidth));
|
|
82
|
+
const v = cy.toFloat().add(float(.5)).div(float(computeHeight));
|
|
83
|
+
const srcX = u.mul(inputWidthU).round().toInt().clamp(int(0), int(inputWidthU.sub(1))).toUint();
|
|
84
|
+
const srcY = v.mul(inputHeightU).round().toInt().clamp(int(0), int(inputHeightU.sub(1))).toUint();
|
|
85
|
+
const sample = textureLoad(childTexture, uvec2(srcX, srcY), int(0));
|
|
86
|
+
const lum = dot(sample.rgb, vec3(.2126, .7152, .0722));
|
|
87
|
+
const mask = max(float(0), lum.sub(uniforms.threshold.uniform));
|
|
88
|
+
textureStore(brightWriteNode, uvec2(cx, cy), vec4(sample.rgb.mul(mask), sample.a)).toWriteOnly();
|
|
89
|
+
let radius;
|
|
90
|
+
if (sizeMapInfo) {
|
|
91
|
+
const { sourceTexture, channel, inputMin, inputMax, outputMin, outputMax, curve } = sizeMapInfo;
|
|
92
|
+
const mapSample = textureLoad(sourceTexture, uvec2(srcX, srcY), int(0));
|
|
69
93
|
let raw;
|
|
70
|
-
if (channel === "alpha") raw =
|
|
71
|
-
else if (channel === "alphaInverted") raw =
|
|
72
|
-
else if (channel === "luminanceInverted") raw = dot(
|
|
73
|
-
else raw = dot(
|
|
94
|
+
if (channel === "alpha") raw = mapSample.a;
|
|
95
|
+
else if (channel === "alphaInverted") raw = mapSample.a.oneMinus();
|
|
96
|
+
else if (channel === "luminanceInverted") raw = dot(mapSample.rgb, vec3(.2126, .7152, .0722)).oneMinus();
|
|
97
|
+
else raw = dot(mapSample.rgb, vec3(.2126, .7152, .0722));
|
|
74
98
|
const inputRange = inputMax.sub(inputMin).max(float(1e-4));
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
const { computeNodes, outputTexture, updateRadius } = createGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
99
|
+
radius = mix(outputMin, outputMax, pow(clamp(raw.sub(inputMin).div(inputRange), float(0), float(1)), pow(float(2), curve.negate().mul(float(2)))));
|
|
100
|
+
} else radius = uniforms.size.uniform;
|
|
101
|
+
textureStore(blurMapWriteNode, uvec2(cx, cy), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
102
|
+
});
|
|
103
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
104
|
+
onResize(({ width, height }) => {
|
|
105
|
+
const newW = Math.round(width * dpr);
|
|
106
|
+
const newH = Math.round(height * dpr);
|
|
107
|
+
inputWidthU.value = newW;
|
|
108
|
+
inputHeightU.value = newH;
|
|
109
|
+
});
|
|
88
110
|
return {
|
|
89
111
|
outputs: {
|
|
90
112
|
childTexture,
|
|
91
|
-
blurredTexture:
|
|
113
|
+
blurredTexture: blurredTex
|
|
92
114
|
},
|
|
93
|
-
getComputeNodes: () =>
|
|
94
|
-
const sizeEntry = uniforms.size;
|
|
95
|
-
const size = sizeEntry.getCpuValue?.() ?? (typeof sizeEntry.uniform.value === "number" ? sizeEntry.uniform.value : null);
|
|
96
|
-
if (size !== null) updateRadius(size);
|
|
97
|
-
return computeNodes;
|
|
98
|
-
}
|
|
115
|
+
getComputeNodes: () => [extractAndFill, ...blurNodes]
|
|
99
116
|
};
|
|
100
117
|
},
|
|
101
118
|
fragmentNode: ({ uniforms, childNode, onCleanup, computeOutputs }) => {
|
|
102
119
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
120
|
+
if (uniforms.size.uniform.value === 0) return childNode;
|
|
103
121
|
if (computeOutputs?.blurredTexture) {
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const luminance = dot(originalColor$1.rgb, vec3(.299, .587, .114));
|
|
107
|
-
const brightnessMask = max(float(0), luminance.sub(uniforms.threshold.uniform));
|
|
108
|
-
const intensity$1 = uniforms.intensity.uniform;
|
|
109
|
-
const glow = blurredColor.mul(brightnessMask).mul(intensity$1);
|
|
110
|
-
const finalColor = originalColor$1.rgb.add(glow.rgb);
|
|
111
|
-
const finalAlpha = max(originalColor$1.a, glow.a);
|
|
122
|
+
const original = computeOutputs.childTexture.sample(screenUV);
|
|
123
|
+
const bloom = texture(computeOutputs.blurredTexture).sample(screenUV);
|
|
112
124
|
const sizePin = uniforms.size.uniform.mul(float(0));
|
|
113
|
-
|
|
125
|
+
const intensity$1 = uniforms.intensity.uniform;
|
|
126
|
+
return unpremultiplyAlpha(vec4(original.rgb.add(bloom.rgb.mul(intensity$1)).add(sizePin), original.a));
|
|
114
127
|
}
|
|
115
128
|
const childTexture = convertToTexture(childNode);
|
|
116
129
|
onCleanup(() => {
|
|
@@ -116,7 +116,7 @@ const componentDefinition = {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
},
|
|
119
|
-
computeNode: ({ uniforms, onCleanup
|
|
119
|
+
computeNode: ({ uniforms, onCleanup }) => {
|
|
120
120
|
const GRID_SIZE = uniforms?.gridSize?.uniform?.value ? Math.max(8, Math.min(128, Math.floor(uniforms.gridSize.uniform.value))) : DEFAULT_GRID_SIZE;
|
|
121
121
|
const buffer = attributeArray(GRID_SIZE * GRID_SIZE, "vec4");
|
|
122
122
|
const dispTex = new StorageTexture(GRID_SIZE, GRID_SIZE);
|
|
@@ -179,7 +179,7 @@ const componentDefinition = {
|
|
|
179
179
|
const currentTime = Date.now();
|
|
180
180
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
181
181
|
lastTime = currentTime;
|
|
182
|
-
const aspect = dimensions.width / Math.max(dimensions.height
|
|
182
|
+
const aspect = Math.max(1, params.dimensions.width) / Math.max(1, params.dimensions.height);
|
|
183
183
|
const velX = dt > 0 ? (params.pointer.x - prevX) / dt : 0;
|
|
184
184
|
const velY = dt > 0 ? (params.pointer.y - prevY) / dt : 0;
|
|
185
185
|
smoothVelX = smoothVelX * .85 + velX * .15;
|
|
@@ -203,7 +203,7 @@ const componentDefinition = {
|
|
|
203
203
|
}
|
|
204
204
|
};
|
|
205
205
|
},
|
|
206
|
-
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup,
|
|
206
|
+
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup, computeOutputs }) => {
|
|
207
207
|
let displacementField;
|
|
208
208
|
let GRID_SIZE;
|
|
209
209
|
if (computeOutputs?.displacement) {
|
|
@@ -217,7 +217,7 @@ const componentDefinition = {
|
|
|
217
217
|
const mouseVelX = uniform(0);
|
|
218
218
|
const mouseVelY = uniform(0);
|
|
219
219
|
let prevX = .5, prevY = .5, lastTime = Date.now();
|
|
220
|
-
onBeforeRender(({ pointer }) => {
|
|
220
|
+
onBeforeRender(({ pointer, dimensions }) => {
|
|
221
221
|
const currentTime = Date.now();
|
|
222
222
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
223
223
|
lastTime = currentTime;
|
|
@@ -7,6 +7,7 @@ const componentDefinition = {
|
|
|
7
7
|
props: { shift: {
|
|
8
8
|
default: 0,
|
|
9
9
|
description: "The amount to shift the hue by",
|
|
10
|
+
compileTimeWhen: (prev, next) => prev === 0 !== (next === 0),
|
|
10
11
|
ui: {
|
|
11
12
|
type: ["range", "map"],
|
|
12
13
|
min: -180,
|
|
@@ -22,6 +23,7 @@ const componentDefinition = {
|
|
|
22
23
|
console.error("You must pass a child component into the Hue Shift shader.");
|
|
23
24
|
return vec4(0);
|
|
24
25
|
}
|
|
26
|
+
if (uniforms.shift.uniform.value === 0) return childNode;
|
|
25
27
|
const angle = uniforms.shift.uniform;
|
|
26
28
|
const cosA = cos(angle);
|
|
27
29
|
const sinA = sin(angle);
|