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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SRGBColorSpace, Texture, TextureLoader } from "three/webgpu";
|
|
2
|
-
import { float, max, min, or, screenUV, select,
|
|
2
|
+
import { float, max, min, or, screenUV, select, texture, uniform, vec2, vec4, viewportSize } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "ImageTexture",
|
|
5
5
|
category: "Textures",
|
|
@@ -26,6 +26,7 @@ const componentDefinition = {
|
|
|
26
26
|
"none": 4
|
|
27
27
|
}[value] ?? 0;
|
|
28
28
|
},
|
|
29
|
+
compileTime: true,
|
|
29
30
|
ui: {
|
|
30
31
|
type: "select",
|
|
31
32
|
options: [
|
|
@@ -167,22 +168,34 @@ const componentDefinition = {
|
|
|
167
168
|
});
|
|
168
169
|
const uv$1 = baseUV;
|
|
169
170
|
const viewportAspect = viewportSize.x.div(viewportSize.y);
|
|
170
|
-
const objectFitMode = uniforms.objectFit.uniform;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
171
|
+
const objectFitMode = uniforms.objectFit.uniform.value;
|
|
172
|
+
let uvScale;
|
|
173
|
+
switch (objectFitMode) {
|
|
174
|
+
case 1: {
|
|
175
|
+
const containScale = min(viewportAspect.div(imageAspectUniform), float(1));
|
|
176
|
+
uvScale = vec2(imageAspectUniform.div(viewportAspect).mul(containScale), containScale);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case 2:
|
|
180
|
+
uvScale = vec2(1, 1);
|
|
181
|
+
break;
|
|
182
|
+
case 3: {
|
|
183
|
+
const scaleDownScale = min(min(viewportAspect.div(imageAspectUniform), float(1)), min(viewportSize.x.div(imageWidthUniform), viewportSize.y.div(imageHeightUniform)));
|
|
184
|
+
uvScale = vec2(imageAspectUniform.div(viewportAspect).mul(scaleDownScale), scaleDownScale);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 4: {
|
|
188
|
+
const noneScale = min(viewportSize.x.div(imageWidthUniform), viewportSize.y.div(imageHeightUniform));
|
|
189
|
+
uvScale = vec2(imageAspectUniform.div(viewportAspect).mul(noneScale), noneScale);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case 0:
|
|
193
|
+
default: {
|
|
194
|
+
const coverScale = max(viewportAspect.div(imageAspectUniform), float(1));
|
|
195
|
+
uvScale = vec2(imageAspectUniform.div(viewportAspect).mul(coverScale), coverScale);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
186
199
|
const adjustedUV = uv$1.sub(vec2(.5)).div(uvScale).add(vec2(.5));
|
|
187
200
|
const finalUV = vec2(adjustedUV.x, float(1).sub(adjustedUV.y));
|
|
188
201
|
const sampledColor = textureNode.sample(finalUV);
|
|
@@ -91,7 +91,7 @@ const componentDefinition = {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
|
-
computeNode: ({ uniforms, onCleanup
|
|
94
|
+
computeNode: ({ uniforms, onCleanup }) => {
|
|
95
95
|
const bufferA = attributeArray(GRID_SIZE * GRID_SIZE, "vec4");
|
|
96
96
|
const bufferB = attributeArray(GRID_SIZE * GRID_SIZE, "vec4");
|
|
97
97
|
const dispTex = new StorageTexture(GRID_SIZE, GRID_SIZE);
|
|
@@ -179,7 +179,7 @@ const componentDefinition = {
|
|
|
179
179
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
180
180
|
lastTime = currentTime;
|
|
181
181
|
if (dt <= 0) return null;
|
|
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 stiffness = uniforms.stiffness.uniform.value;
|
|
184
184
|
const damping = uniforms.damping.uniform.value;
|
|
185
185
|
const radius = uniforms.radius.uniform.value * .08;
|
|
@@ -213,7 +213,7 @@ const componentDefinition = {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
},
|
|
216
|
-
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup,
|
|
216
|
+
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup, computeOutputs }) => {
|
|
217
217
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
218
218
|
const childTexture = computeOutputs?.childTexture ?? convertToTexture(childNode);
|
|
219
219
|
if (!computeOutputs) onCleanup(() => {
|
|
@@ -242,12 +242,12 @@ const componentDefinition = {
|
|
|
242
242
|
let prevY = .5;
|
|
243
243
|
let lastTime = Date.now();
|
|
244
244
|
const SUBSTEPS = 2;
|
|
245
|
-
onBeforeRender(({ pointer }) => {
|
|
245
|
+
onBeforeRender(({ pointer, dimensions }) => {
|
|
246
246
|
const currentTime = Date.now();
|
|
247
247
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
248
248
|
lastTime = currentTime;
|
|
249
249
|
if (dt <= 0) return;
|
|
250
|
-
const aspect = dimensions.width / Math.max(dimensions.height
|
|
250
|
+
const aspect = Math.max(1, dimensions.width) / Math.max(1, dimensions.height);
|
|
251
251
|
const stiffness = uniforms.stiffness.uniform.value;
|
|
252
252
|
const damping = uniforms.damping.uniform.value;
|
|
253
253
|
const radius = uniforms.radius.uniform.value * .08;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as transformPosition, r as transformAngle } from "./transformations-B5lM6fYX.js";
|
|
2
2
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as createVariableGaussianBlurCompute } from "./computeBlur-DCRhuYEi.js";
|
|
4
4
|
import { Fn, If, clamp, convertToTexture, cos, dot, float, instanceIndex, int, max, mix, pow, radians, screenUV, sin, smoothstep, texture, textureLoad, textureStore, uint, uniform, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
const componentDefinition = {
|
|
6
6
|
name: "ProgressiveBlur",
|
|
@@ -60,7 +60,7 @@ const componentDefinition = {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
63
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms, onResize }) => {
|
|
64
64
|
if (!childNode) return null;
|
|
65
65
|
if (uniforms.angle.mapComputeInfo || uniforms.falloff.mapComputeInfo) return null;
|
|
66
66
|
const childTexture = convertToTexture(childNode);
|
|
@@ -70,14 +70,17 @@ const componentDefinition = {
|
|
|
70
70
|
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
71
71
|
const texWidth = Math.round(dimensions.width * dpr);
|
|
72
72
|
const texHeight = Math.round(dimensions.height * dpr);
|
|
73
|
-
const
|
|
73
|
+
const blur = createVariableGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup);
|
|
74
|
+
const { computeNodes: blurNodes, outputTexture, blurMapWriteNode, computeWidth, computeHeight } = blur;
|
|
74
75
|
const angleU = uniform(0);
|
|
75
76
|
const centerXU = uniform(0);
|
|
76
77
|
const centerYU = uniform(.5);
|
|
77
78
|
const falloffU = uniform(1);
|
|
78
79
|
const aspectU = uniform(1);
|
|
79
|
-
const
|
|
80
|
-
const
|
|
80
|
+
const inputWidthU = uniform(texWidth);
|
|
81
|
+
const inputHeightU = uniform(texHeight);
|
|
82
|
+
const cw = uint(computeWidth);
|
|
83
|
+
const ch = uint(computeHeight);
|
|
81
84
|
function readScalar(entry) {
|
|
82
85
|
return entry.getCpuValue?.() ?? (typeof entry.uniform.value === "number" ? entry.uniform.value : null);
|
|
83
86
|
}
|
|
@@ -97,18 +100,18 @@ const componentDefinition = {
|
|
|
97
100
|
const { sourceTexture, channel, inputMin, inputMax, outputMin, outputMax, curve } = intensityMapInfo;
|
|
98
101
|
const fillBlurMap$1 = Fn(() => {
|
|
99
102
|
const idx = instanceIndex;
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
If(
|
|
103
|
-
const u =
|
|
104
|
-
const v =
|
|
103
|
+
const cx = idx.mod(cw);
|
|
104
|
+
const cy = idx.div(cw);
|
|
105
|
+
If(cy.lessThan(ch), () => {
|
|
106
|
+
const u = cx.toFloat().add(float(.5)).div(float(computeWidth));
|
|
107
|
+
const v = cy.toFloat().add(float(.5)).div(float(computeHeight));
|
|
105
108
|
const angleRad = angleU.mul(float(Math.PI / 180));
|
|
106
109
|
const direction = vec2(angleRad.cos().div(aspectU), angleRad.sin());
|
|
107
110
|
const centerPos = vec2(centerXU, float(1).sub(centerYU));
|
|
108
111
|
const centeredUV = vec2(u, v).sub(centerPos);
|
|
109
112
|
const directionalDist = max(float(0), centeredUV.dot(direction));
|
|
110
113
|
const blurAmount = smoothstep(float(0), falloffU, directionalDist);
|
|
111
|
-
const mapSample = textureLoad(sourceTexture, uvec2(
|
|
114
|
+
const mapSample = 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));
|
|
112
115
|
let raw;
|
|
113
116
|
if (channel === "alpha") raw = mapSample.a;
|
|
114
117
|
else if (channel === "alphaInverted") raw = mapSample.a.oneMinus();
|
|
@@ -117,9 +120,16 @@ const componentDefinition = {
|
|
|
117
120
|
const inputRange = inputMax.sub(inputMin).max(float(1e-4));
|
|
118
121
|
const maxRadius = 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));
|
|
119
122
|
const radius = blurAmount.mul(maxRadius);
|
|
120
|
-
textureStore(blurMapWriteNode, uvec2(
|
|
123
|
+
textureStore(blurMapWriteNode, uvec2(cx, cy), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
121
124
|
});
|
|
122
|
-
})().compute(
|
|
125
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
126
|
+
onResize(({ width, height }) => {
|
|
127
|
+
const newW = Math.round(width * dpr);
|
|
128
|
+
const newH = Math.round(height * dpr);
|
|
129
|
+
inputWidthU.value = newW;
|
|
130
|
+
inputHeightU.value = newH;
|
|
131
|
+
blur.setInputDimensions(newW, newH);
|
|
132
|
+
});
|
|
123
133
|
return {
|
|
124
134
|
outputs: {
|
|
125
135
|
childTexture,
|
|
@@ -134,20 +144,23 @@ const componentDefinition = {
|
|
|
134
144
|
const maxRadiusU = uniform(18);
|
|
135
145
|
const fillBlurMap = Fn(() => {
|
|
136
146
|
const idx = instanceIndex;
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
If(
|
|
140
|
-
const u =
|
|
141
|
-
const v =
|
|
147
|
+
const cx = idx.mod(cw);
|
|
148
|
+
const cy = idx.div(cw);
|
|
149
|
+
If(cy.lessThan(ch), () => {
|
|
150
|
+
const u = cx.toFloat().add(float(.5)).div(float(computeWidth));
|
|
151
|
+
const v = cy.toFloat().add(float(.5)).div(float(computeHeight));
|
|
142
152
|
const angleRad = angleU.mul(float(Math.PI / 180));
|
|
143
153
|
const direction = vec2(angleRad.cos().div(aspectU), angleRad.sin());
|
|
144
154
|
const centerPos = vec2(centerXU, float(1).sub(centerYU));
|
|
145
155
|
const centeredUV = vec2(u, v).sub(centerPos);
|
|
146
156
|
const directionalDist = max(float(0), centeredUV.dot(direction));
|
|
147
157
|
const radius = smoothstep(float(0), falloffU, directionalDist).mul(maxRadiusU);
|
|
148
|
-
textureStore(blurMapWriteNode, uvec2(
|
|
158
|
+
textureStore(blurMapWriteNode, uvec2(cx, cy), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
149
159
|
});
|
|
150
|
-
})().compute(
|
|
160
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
161
|
+
onResize(({ width, height }) => {
|
|
162
|
+
blur.setInputDimensions(Math.round(width * dpr), Math.round(height * dpr));
|
|
163
|
+
});
|
|
151
164
|
return {
|
|
152
165
|
outputs: {
|
|
153
166
|
childTexture,
|
|
@@ -7,6 +7,7 @@ const componentDefinition = {
|
|
|
7
7
|
props: { intensity: {
|
|
8
8
|
default: 1,
|
|
9
9
|
description: "The intensity of the saturation effect (1 being no change)",
|
|
10
|
+
compileTimeWhen: (prev, next) => prev === 1 !== (next === 1),
|
|
10
11
|
ui: {
|
|
11
12
|
type: ["range", "map"],
|
|
12
13
|
min: 0,
|
|
@@ -21,6 +22,7 @@ const componentDefinition = {
|
|
|
21
22
|
console.error("You must pass a child component into the Saturation shader.");
|
|
22
23
|
return vec4(0);
|
|
23
24
|
}
|
|
25
|
+
if (uniforms.intensity.uniform.value === 1) return childNode;
|
|
24
26
|
const luminance = dot(childNode.rgb, vec3(.2126, .7152, .0722));
|
|
25
27
|
return vec4(mix(vec3(luminance, luminance, luminance), childNode.rgb, uniforms.intensity.uniform), childNode.a);
|
|
26
28
|
}
|
|
@@ -9,6 +9,7 @@ const componentDefinition = {
|
|
|
9
9
|
props: { sharpness: {
|
|
10
10
|
default: 0,
|
|
11
11
|
description: "How sharp to make the underlying image",
|
|
12
|
+
compileTimeWhen: (prev, next) => prev === 0 !== (next === 0),
|
|
12
13
|
ui: {
|
|
13
14
|
type: ["range", "map"],
|
|
14
15
|
min: 0,
|
|
@@ -20,6 +21,7 @@ const componentDefinition = {
|
|
|
20
21
|
} },
|
|
21
22
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
22
23
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
24
|
+
if (uniforms.sharpness.uniform.value === 0) return childNode;
|
|
23
25
|
const childTexture = convertToTexture(childNode);
|
|
24
26
|
onCleanup(() => {
|
|
25
27
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
@@ -2,7 +2,7 @@ import { t as applyEdgeHandling } from "./edges-CfGcQniB.js";
|
|
|
2
2
|
import { c as transformEdges } from "./transformations-B5lM6fYX.js";
|
|
3
3
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
4
4
|
import { StorageTexture } from "three/webgpu";
|
|
5
|
-
import { DataTexture, FloatType,
|
|
5
|
+
import { DataTexture, FloatType, NearestFilter, RGBAFormat } from "three";
|
|
6
6
|
import { Fn, If, convertToTexture, float, instanceIndex, int, screenUV, smoothstep, storageTexture, texture, textureStore, uint, uniformArray, uvec2, vec2, vec4 } from "three/tsl";
|
|
7
7
|
var seededRandom = (seed) => {
|
|
8
8
|
const x = Math.sin(seed) * 1e4;
|
|
@@ -220,13 +220,25 @@ const componentDefinition = {
|
|
|
220
220
|
fragmentNode: ({ uniforms, onBeforeRender, childNode, onCleanup, dimensions, computeOutputs }) => {
|
|
221
221
|
const FRICTION = 1;
|
|
222
222
|
const cellData = new Float32Array(SHARD_COUNT * 4);
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
cellTexture.minFilter = LinearFilter$1;
|
|
223
|
+
const cellPosArray = new Array(SHARD_COUNT * 2).fill(0);
|
|
224
|
+
const cellPosUniform = uniformArray(cellPosArray, "float");
|
|
226
225
|
const displacementData = new Float32Array(SHARD_COUNT * 4);
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
const dispArray = new Array(SHARD_COUNT * 2).fill(0);
|
|
227
|
+
const dispUniform = uniformArray(dispArray, "float");
|
|
228
|
+
const syncCellPosUniform = () => {
|
|
229
|
+
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
230
|
+
cellPosArray[i * 2] = cellData[i * 4];
|
|
231
|
+
cellPosArray[i * 2 + 1] = cellData[i * 4 + 1];
|
|
232
|
+
}
|
|
233
|
+
cellPosUniform.array = cellPosArray;
|
|
234
|
+
};
|
|
235
|
+
const syncDispUniform = () => {
|
|
236
|
+
for (let i = 0; i < SHARD_COUNT; i++) {
|
|
237
|
+
dispArray[i * 2] = displacementData[i * 4];
|
|
238
|
+
dispArray[i * 2 + 1] = displacementData[i * 4 + 1];
|
|
239
|
+
}
|
|
240
|
+
dispUniform.array = dispArray;
|
|
241
|
+
};
|
|
230
242
|
let voronoiField;
|
|
231
243
|
if (computeOutputs?.voronoiTexture) voronoiField = texture(computeOutputs.voronoiTexture);
|
|
232
244
|
else {
|
|
@@ -268,7 +280,7 @@ const componentDefinition = {
|
|
|
268
280
|
cellData[i * 4 + 2] = seededRandom(seed + i * 3);
|
|
269
281
|
cellData[i * 4 + 3] = seededRandom(seed + i * 3 + 1);
|
|
270
282
|
}
|
|
271
|
-
|
|
283
|
+
syncCellPosUniform();
|
|
272
284
|
};
|
|
273
285
|
generateCells(currentSeed);
|
|
274
286
|
generateVoronoi();
|
|
@@ -292,12 +304,12 @@ const componentDefinition = {
|
|
|
292
304
|
cellData[i * 4 + 2] = seededRandom(seed + i * 3);
|
|
293
305
|
cellData[i * 4 + 3] = seededRandom(seed + i * 3 + 1);
|
|
294
306
|
}
|
|
295
|
-
|
|
307
|
+
syncCellPosUniform();
|
|
296
308
|
};
|
|
297
309
|
let currentSeedForDisp = uniforms.seed.uniform.value;
|
|
298
310
|
generateCellsFull(currentSeedForDisp);
|
|
299
311
|
displacementData.fill(0);
|
|
300
|
-
|
|
312
|
+
syncDispUniform();
|
|
301
313
|
let prevX = .5, prevY = .5, lastTime = Date.now();
|
|
302
314
|
onBeforeRender(({ pointer }) => {
|
|
303
315
|
const currentTime = Date.now();
|
|
@@ -354,31 +366,23 @@ const componentDefinition = {
|
|
|
354
366
|
displacementData[i * 4 + 2] = 0;
|
|
355
367
|
displacementData[i * 4 + 3] = 0;
|
|
356
368
|
}
|
|
357
|
-
|
|
369
|
+
syncDispUniform();
|
|
358
370
|
prevX = pointer.x;
|
|
359
371
|
prevY = pointer.y;
|
|
360
372
|
});
|
|
361
|
-
onCleanup(() => {
|
|
362
|
-
cellTexture.dispose();
|
|
363
|
-
displacementTexture.dispose();
|
|
364
|
-
});
|
|
365
373
|
if (!childNode) return vec4(0, 0, 0, 0);
|
|
366
374
|
const childTexture = convertToTexture(childNode);
|
|
367
375
|
onCleanup(() => {
|
|
368
376
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
369
377
|
});
|
|
370
|
-
const cellField = texture(cellTexture);
|
|
371
|
-
const dispField = texture(displacementTexture);
|
|
372
378
|
const voronoiSample = voronoiField.sample(screenUV);
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
const
|
|
377
|
-
const nearestCellPos = cellField.sample(nearestUV).xy;
|
|
378
|
-
const secondCellPos = cellField.sample(secondUV).xy;
|
|
379
|
+
const nearestI = voronoiSample.r.toInt();
|
|
380
|
+
const secondI = voronoiSample.g.toInt();
|
|
381
|
+
const nearestCellPos = vec2(cellPosUniform.element(nearestI.mul(2)), cellPosUniform.element(nearestI.mul(2).add(1)));
|
|
382
|
+
const secondCellPos = vec2(cellPosUniform.element(secondI.mul(2)), cellPosUniform.element(secondI.mul(2).add(1)));
|
|
379
383
|
const minDist1 = screenUV.sub(nearestCellPos).length();
|
|
380
384
|
const minDist2 = screenUV.sub(secondCellPos).length();
|
|
381
|
-
const displacement =
|
|
385
|
+
const displacement = vec2(dispUniform.element(nearestI.mul(2)), dispUniform.element(nearestI.mul(2).add(1)));
|
|
382
386
|
const displacementMag = displacement.length();
|
|
383
387
|
const edgeDiff = minDist2.sub(minDist1);
|
|
384
388
|
const crackThreshold = uniforms.crackWidth.uniform.mul(.005);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as transformColor } from "./transformations-B5lM6fYX.js";
|
|
1
|
+
import { a as transformColor, 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
4
|
import { clamp, exp, mx_noise_float, screenUV, vec2, vec3, viewportSize } from "three/tsl";
|
|
@@ -27,6 +27,18 @@ const componentDefinition = {
|
|
|
27
27
|
group: "Colors"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
+
colorSpace: {
|
|
31
|
+
default: "linear",
|
|
32
|
+
transform: transformColorSpace,
|
|
33
|
+
compileTime: true,
|
|
34
|
+
description: "Color space for color interpolation",
|
|
35
|
+
ui: {
|
|
36
|
+
type: "select",
|
|
37
|
+
options: colorSpaceOptions,
|
|
38
|
+
label: "Color Space",
|
|
39
|
+
group: "Colors"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
30
42
|
scale: {
|
|
31
43
|
default: 2,
|
|
32
44
|
description: "Pattern scale (higher = larger patterns)",
|
|
@@ -98,7 +110,7 @@ const componentDefinition = {
|
|
|
98
110
|
const noise = mx_noise_float(vec3(pos.x, pos.y, animTime.mul(.5)));
|
|
99
111
|
const contrastMultiplier = uniforms.contrast.uniform.add(1);
|
|
100
112
|
const k = clamp(noise.mul(contrastMultiplier).add(uniforms.balance.uniform).mul(.5).add(.5), 0, 1);
|
|
101
|
-
return mixColors(uniforms.colorB.uniform, uniforms.colorA.uniform, k,
|
|
113
|
+
return mixColors(uniforms.colorB.uniform, uniforms.colorA.uniform, k, uniforms.colorSpace.uniform.value);
|
|
102
114
|
}
|
|
103
115
|
};
|
|
104
116
|
var SimplexNoise_default = componentDefinition;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { a as transformColor, o as transformColorSpace, t as colorSpaceOptions } from "./transformations-B5lM6fYX.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-BPpDnR5I.js";
|
|
3
|
+
import { t as createAnimatedTime } from "./time-DUqSFWvT.js";
|
|
4
|
+
import { Fn, cos, screenUV, sin, smoothstep, vec2, vec4 } from "three/tsl";
|
|
5
|
+
const componentDefinition = {
|
|
6
|
+
name: "Swirl",
|
|
7
|
+
category: "Textures",
|
|
8
|
+
description: "Flowing swirl pattern with multi-layered noise",
|
|
9
|
+
props: {
|
|
10
|
+
colorA: {
|
|
11
|
+
default: "#1275d8",
|
|
12
|
+
description: "Primary gradient color",
|
|
13
|
+
transform: transformColor,
|
|
14
|
+
ui: {
|
|
15
|
+
type: "color",
|
|
16
|
+
label: "Color A",
|
|
17
|
+
group: "Colors"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
colorB: {
|
|
21
|
+
default: "#e19136",
|
|
22
|
+
description: "Secondary gradient color",
|
|
23
|
+
transform: transformColor,
|
|
24
|
+
ui: {
|
|
25
|
+
type: "color",
|
|
26
|
+
label: "Color B",
|
|
27
|
+
group: "Colors"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
speed: {
|
|
31
|
+
default: 1,
|
|
32
|
+
description: "Flow animation speed",
|
|
33
|
+
ui: {
|
|
34
|
+
type: "range",
|
|
35
|
+
min: 0,
|
|
36
|
+
max: 5,
|
|
37
|
+
step: .1,
|
|
38
|
+
label: "Speed",
|
|
39
|
+
group: "Animation"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
detail: {
|
|
43
|
+
default: 1,
|
|
44
|
+
description: "Level of detail and intricacy in the swirl patterns",
|
|
45
|
+
ui: {
|
|
46
|
+
type: ["range", "map"],
|
|
47
|
+
min: 0,
|
|
48
|
+
max: 5,
|
|
49
|
+
step: .1,
|
|
50
|
+
label: "Detail",
|
|
51
|
+
group: "Effect"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
blend: {
|
|
55
|
+
default: 50,
|
|
56
|
+
description: "Skew color balance toward A (lower values) or B (higher values)",
|
|
57
|
+
ui: {
|
|
58
|
+
type: ["range", "map"],
|
|
59
|
+
min: 0,
|
|
60
|
+
max: 100,
|
|
61
|
+
step: 1,
|
|
62
|
+
label: "Blend",
|
|
63
|
+
group: "Effect"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
colorSpace: {
|
|
67
|
+
default: "linear",
|
|
68
|
+
transform: transformColorSpace,
|
|
69
|
+
compileTime: true,
|
|
70
|
+
description: "Color space for color interpolation",
|
|
71
|
+
ui: {
|
|
72
|
+
type: "select",
|
|
73
|
+
options: colorSpaceOptions,
|
|
74
|
+
label: "Color Space",
|
|
75
|
+
group: "Colors"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
fragmentNode: (params) => {
|
|
80
|
+
const { uniforms } = params;
|
|
81
|
+
const t = createAnimatedTime(params, uniforms.speed);
|
|
82
|
+
const detail = uniforms.detail.uniform;
|
|
83
|
+
const csMode = uniforms.colorSpace.uniform.value;
|
|
84
|
+
return Fn(() => {
|
|
85
|
+
const freq1 = detail;
|
|
86
|
+
const d1 = vec2(screenUV.x.add(sin(screenUV.y.mul(freq1.mul(1.7)).add(t.mul(.8))).mul(.12).add(cos(screenUV.x.mul(freq1.mul(.9)).sub(t.mul(.5))).mul(.05))), screenUV.y.add(cos(screenUV.x.mul(freq1.mul(1.3)).sub(t.mul(.6))).mul(.12).add(sin(screenUV.y.mul(freq1.mul(1.1)).add(t.mul(.7))).mul(.05)))).toVar();
|
|
87
|
+
const pattern1 = sin(d1.x.mul(freq1.mul(2.1)).add(d1.y.mul(freq1.mul(1.8))).add(t.mul(.4)));
|
|
88
|
+
const freq2 = detail.mul(2.1);
|
|
89
|
+
const d2 = vec2(d1.x.add(cos(d1.y.mul(freq2.mul(2.7)).sub(t.mul(.45))).mul(.07).add(sin(d1.x.mul(freq2.mul(1.9)).add(t.mul(.6))).mul(.04))), d1.y.add(sin(d1.x.mul(freq2.mul(2.3)).add(t.mul(.65))).mul(.07).add(cos(d1.y.mul(freq2.mul(1.6)).sub(t.mul(.4))).mul(.04)))).toVar();
|
|
90
|
+
const pattern2 = cos(d2.x.mul(freq2.mul(1.4)).sub(d2.y.mul(freq2.mul(1.9))).add(t.mul(.35)));
|
|
91
|
+
const freq3 = detail.mul(3.7);
|
|
92
|
+
const d3 = vec2(d2.x.add(sin(d2.y.mul(freq3.mul(1.8)).add(t.mul(.85))).mul(.04).add(cos(d2.x.mul(freq3.mul(1.3)).sub(t.mul(.55))).mul(.025)).add(sin(d2.x.add(d2.y).mul(freq3.mul(.7)).add(t.mul(.9))).mul(.02))), d2.y.add(cos(d2.x.mul(freq3.mul(1.6)).sub(t.mul(.75))).mul(.04).add(sin(d2.y.mul(freq3.mul(1.1)).add(t.mul(.5))).mul(.025)).add(cos(d2.x.add(d2.y).mul(freq3.mul(.8)).sub(t.mul(.95))).mul(.02)))).toVar();
|
|
93
|
+
const pattern3 = sin(d3.x.mul(freq3.mul(1.1)).add(d3.y.mul(freq3.mul(1.5))).sub(t.mul(.55)));
|
|
94
|
+
const combinedPattern = pattern1.mul(.45).add(pattern2.mul(.35)).add(pattern3.mul(.2));
|
|
95
|
+
const blendBias = uniforms.blend.uniform.sub(50).mul(.006);
|
|
96
|
+
const blendFactor = smoothstep(.3, .7, combinedPattern.mul(.5).add(.5).add(blendBias));
|
|
97
|
+
const colorMix = mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, blendFactor, csMode);
|
|
98
|
+
const shimmer = sin(t.mul(2.5).add(combinedPattern.mul(8))).mul(.015).add(1);
|
|
99
|
+
const finalColor = colorMix.mul(shimmer);
|
|
100
|
+
return vec4(finalColor.rgb, finalColor.a);
|
|
101
|
+
})();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var Swirl_default = componentDefinition;
|
|
105
|
+
export { componentDefinition as n, Swirl_default as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { l as transformPosition, r as transformAngle } from "./transformations-B5lM6fYX.js";
|
|
2
2
|
import { t as unpremultiplyAlpha } from "./alpha-C4ptedXe.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as createVariableGaussianBlurCompute } from "./computeBlur-DCRhuYEi.js";
|
|
4
4
|
import { Fn, If, abs, clamp, convertToTexture, cos, dot, float, instanceIndex, int, mix, pow, radians, screenUV, sin, smoothstep, texture, textureLoad, textureStore, uint, uniform, uvec2, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
const componentDefinition = {
|
|
6
6
|
name: "TiltShift",
|
|
@@ -72,7 +72,7 @@ const componentDefinition = {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms }) => {
|
|
75
|
+
computeNode: ({ childNode, onCleanup, dimensions, renderer, uniforms, onResize }) => {
|
|
76
76
|
if (!childNode) return null;
|
|
77
77
|
if (uniforms.angle.mapComputeInfo || uniforms.width.mapComputeInfo || uniforms.falloff.mapComputeInfo) return null;
|
|
78
78
|
const childTexture = convertToTexture(childNode);
|
|
@@ -82,15 +82,18 @@ const componentDefinition = {
|
|
|
82
82
|
const dpr = renderer?.getPixelRatio?.() ?? 1;
|
|
83
83
|
const texWidth = Math.round(dimensions.width * dpr);
|
|
84
84
|
const texHeight = Math.round(dimensions.height * dpr);
|
|
85
|
-
const
|
|
85
|
+
const blur = createVariableGaussianBlurCompute(childTexture, texWidth, texHeight, onCleanup, 14);
|
|
86
|
+
const { computeNodes: blurNodes, outputTexture, blurMapWriteNode, computeWidth, computeHeight } = blur;
|
|
86
87
|
const angleU = uniform(0);
|
|
87
88
|
const centerXU = uniform(.5);
|
|
88
89
|
const centerYU = uniform(.5);
|
|
89
90
|
const focusWidthU = uniform(.15);
|
|
90
91
|
const falloffU = uniform(.3);
|
|
91
92
|
const aspectU = uniform(1);
|
|
92
|
-
const
|
|
93
|
-
const
|
|
93
|
+
const inputWidthU = uniform(texWidth);
|
|
94
|
+
const inputHeightU = uniform(texHeight);
|
|
95
|
+
const cw = uint(computeWidth);
|
|
96
|
+
const ch = uint(computeHeight);
|
|
94
97
|
function readScalar(entry) {
|
|
95
98
|
return entry.getCpuValue?.() ?? (typeof entry.uniform.value === "number" ? entry.uniform.value : null);
|
|
96
99
|
}
|
|
@@ -112,18 +115,18 @@ const componentDefinition = {
|
|
|
112
115
|
const { sourceTexture, channel, inputMin, inputMax, outputMin, outputMax, curve } = intensityMapInfo;
|
|
113
116
|
const fillBlurMap$1 = Fn(() => {
|
|
114
117
|
const idx = instanceIndex;
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
If(
|
|
118
|
-
const u =
|
|
119
|
-
const v =
|
|
118
|
+
const cx = idx.mod(cw);
|
|
119
|
+
const cy = idx.div(cw);
|
|
120
|
+
If(cy.lessThan(ch), () => {
|
|
121
|
+
const u = cx.toFloat().add(float(.5)).div(float(computeWidth));
|
|
122
|
+
const v = cy.toFloat().add(float(.5)).div(float(computeHeight));
|
|
120
123
|
const angleRad = angleU.mul(float(Math.PI / 180));
|
|
121
124
|
const perpVector = vec2(angleRad.sin().negate(), angleRad.cos());
|
|
122
125
|
const centerPos = vec2(centerXU, float(1).sub(centerYU));
|
|
123
126
|
const centeredUV = vec2(u, v).sub(centerPos);
|
|
124
127
|
const distFromLine = abs(dot(vec2(centeredUV.x.mul(aspectU), centeredUV.y), perpVector));
|
|
125
128
|
const blurAmount = smoothstep(focusWidthU, focusWidthU.add(falloffU), distFromLine);
|
|
126
|
-
const mapSample = textureLoad(sourceTexture, uvec2(
|
|
129
|
+
const mapSample = 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));
|
|
127
130
|
let raw;
|
|
128
131
|
if (channel === "alpha") raw = mapSample.a;
|
|
129
132
|
else if (channel === "alphaInverted") raw = mapSample.a.oneMinus();
|
|
@@ -132,9 +135,16 @@ const componentDefinition = {
|
|
|
132
135
|
const inputRange = inputMax.sub(inputMin).max(float(1e-4));
|
|
133
136
|
const maxRadius = 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));
|
|
134
137
|
const radius = blurAmount.mul(maxRadius);
|
|
135
|
-
textureStore(blurMapWriteNode, uvec2(
|
|
138
|
+
textureStore(blurMapWriteNode, uvec2(cx, cy), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
136
139
|
});
|
|
137
|
-
})().compute(
|
|
140
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
141
|
+
onResize(({ width, height }) => {
|
|
142
|
+
const newW = Math.round(width * dpr);
|
|
143
|
+
const newH = Math.round(height * dpr);
|
|
144
|
+
inputWidthU.value = newW;
|
|
145
|
+
inputHeightU.value = newH;
|
|
146
|
+
blur.setInputDimensions(newW, newH);
|
|
147
|
+
});
|
|
138
148
|
return {
|
|
139
149
|
outputs: {
|
|
140
150
|
childTexture,
|
|
@@ -149,20 +159,27 @@ const componentDefinition = {
|
|
|
149
159
|
const maxRadiusU = uniform(18);
|
|
150
160
|
const fillBlurMap = Fn(() => {
|
|
151
161
|
const idx = instanceIndex;
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
If(
|
|
155
|
-
const u =
|
|
156
|
-
const v =
|
|
162
|
+
const cx = idx.mod(cw);
|
|
163
|
+
const cy = idx.div(cw);
|
|
164
|
+
If(cy.lessThan(ch), () => {
|
|
165
|
+
const u = cx.toFloat().add(float(.5)).div(float(computeWidth));
|
|
166
|
+
const v = cy.toFloat().add(float(.5)).div(float(computeHeight));
|
|
157
167
|
const angleRad = angleU.mul(float(Math.PI / 180));
|
|
158
168
|
const perpVector = vec2(angleRad.sin().negate(), angleRad.cos());
|
|
159
169
|
const centerPos = vec2(centerXU, float(1).sub(centerYU));
|
|
160
170
|
const centeredUV = vec2(u, v).sub(centerPos);
|
|
161
171
|
const distFromLine = abs(dot(vec2(centeredUV.x.mul(aspectU), centeredUV.y), perpVector));
|
|
162
172
|
const radius = smoothstep(focusWidthU, focusWidthU.add(falloffU), distFromLine).mul(maxRadiusU);
|
|
163
|
-
textureStore(blurMapWriteNode, uvec2(
|
|
173
|
+
textureStore(blurMapWriteNode, uvec2(cx, cy), vec4(radius, float(0), float(0), float(1))).toWriteOnly();
|
|
164
174
|
});
|
|
165
|
-
})().compute(
|
|
175
|
+
})().compute(computeWidth * computeHeight, [256]);
|
|
176
|
+
onResize(({ width, height }) => {
|
|
177
|
+
const newW = Math.round(width * dpr);
|
|
178
|
+
const newH = Math.round(height * dpr);
|
|
179
|
+
inputWidthU.value = newW;
|
|
180
|
+
inputHeightU.value = newH;
|
|
181
|
+
blur.setInputDimensions(newW, newH);
|
|
182
|
+
});
|
|
166
183
|
return {
|
|
167
184
|
outputs: {
|
|
168
185
|
childTexture,
|
|
@@ -181,8 +198,17 @@ const componentDefinition = {
|
|
|
181
198
|
if (computeOutputs?.blurredTexture) {
|
|
182
199
|
const sharp = computeOutputs.childTexture.sample(screenUV);
|
|
183
200
|
const blurred = texture(computeOutputs.blurredTexture).sample(screenUV);
|
|
201
|
+
const aspect$1 = viewportSize.x.div(viewportSize.y);
|
|
202
|
+
const angleRad$1 = radians(uniforms.angle.uniform);
|
|
203
|
+
const perpVector$1 = vec2(angleRad$1.sin().negate(), angleRad$1.cos());
|
|
204
|
+
const centerPosition$1 = vec2(uniforms.center.uniform[0], uniforms.center.uniform[1].oneMinus());
|
|
205
|
+
const centeredUV$1 = screenUV.sub(centerPosition$1);
|
|
206
|
+
const distFromLine$1 = abs(dot(vec2(centeredUV$1.x.mul(aspect$1), centeredUV$1.y), perpVector$1));
|
|
207
|
+
const focusWidth$1 = uniforms.width.uniform.mul(.5);
|
|
208
|
+
const blurAmount$1 = smoothstep(focusWidth$1, focusWidth$1.add(uniforms.falloff.uniform), distFromLine$1);
|
|
184
209
|
const propsPin = uniforms.intensity.uniform.mul(float(0)).add(uniforms.width.uniform.mul(float(0))).add(uniforms.falloff.uniform.mul(float(0))).add(uniforms.angle.uniform.mul(float(0)));
|
|
185
|
-
|
|
210
|
+
const mixed = mix(sharp, blurred, blurAmount$1);
|
|
211
|
+
return unpremultiplyAlpha(vec4(mixed.rgb.add(propsPin), mixed.a));
|
|
186
212
|
}
|
|
187
213
|
const childTexture = convertToTexture(childNode);
|
|
188
214
|
onCleanup(() => {
|