shaders 2.2.26 → 2.2.28
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/{AngularBlur-Dl2gwk68.js → AngularBlur-DKFExWUF.js} +15 -16
- package/dist/core/{Ascii-DsuNLJKv.js → Ascii-BRApYlD4.js} +21 -22
- package/dist/core/{Beam-CTN9Ni43.js → Beam-DU7wxmIh.js} +23 -24
- package/dist/core/{Blob-CxFDZovO.js → Blob-nssNzEgN.js} +37 -38
- package/dist/core/{Blur-Y2FsmFk_.js → Blur-k37gOaRA.js} +16 -17
- package/dist/core/{Bulge-Cb-t0xqI.js → Bulge-Dm02_fG6.js} +23 -25
- package/dist/core/{CRTScreen-CtERsenz.js → CRTScreen-DLy8Rig6.js} +19 -20
- package/dist/core/ChannelBlur-BPOGOQXl.js +117 -0
- package/dist/core/{Checkerboard-BIFNsUYG.js → Checkerboard-SKsXoUXE.js} +10 -11
- package/dist/core/{ChromaFlow-vRCwhQpN.js → ChromaFlow-VpfgLFbs.js} +31 -32
- package/dist/core/{ChromaticAberration-FTquTQIL.js → ChromaticAberration-CaCyXMyE.js} +10 -11
- package/dist/core/{Circle-Daziv5d7.js → Circle-BHnAmzVb.js} +7 -8
- package/dist/core/{CursorTrail-Bsz9e6Fn.js → CursorTrail-CfVWIKok.js} +16 -17
- package/dist/core/{DiffuseBlur-Cj2PtRNd.js → DiffuseBlur-GWPb8Zht.js} +19 -21
- package/dist/core/{Dither-Cq8j0QIU.js → Dither-BNEeyo0u.js} +7 -8
- package/dist/core/{DotGrid-BHfQ3hcI.js → DotGrid-CRRS6nbt.js} +12 -13
- package/dist/core/{Duotone-XuTN9tI7.js → Duotone-5gKND3an.js} +8 -9
- package/dist/core/{FilmGrain-D3-nbi12.js → FilmGrain-osBGk_b9.js} +4 -5
- package/dist/core/{FloatingParticles-CP6GqC3k.js → FloatingParticles-CULOurGT.js} +41 -42
- package/dist/core/GlassTiles-CA90XrNT.js +67 -0
- package/dist/core/{Glow-BluFc9be.js → Glow-D0boDIAW.js} +12 -13
- package/dist/core/{Godrays-ChLh_vGl.js → Godrays-BQsDwU26.js} +27 -28
- package/dist/core/{Grid-DgyDa4H1.js → Grid-CWHxwO7R.js} +7 -8
- package/dist/core/{GridDistortion-BAspCYvp.js → GridDistortion-CZB9w-rv.js} +21 -22
- package/dist/core/{Group-Dul7PUBl.js → Group-C0AknFDS.js} +2 -3
- package/dist/core/{Halftone-Ifv5F_FT.js → Halftone-MMcLMRpL.js} +11 -12
- package/dist/core/{ImageTexture-DvYcQgJB.js → ImageTexture-D9OMwqAs.js} +26 -27
- package/dist/core/{Invert-Fz0NtIJc.js → Invert-Bmjbp6g6.js} +5 -6
- package/dist/core/{LinearBlur-LmhnQoA4.js → LinearBlur-B-Ikurxt.js} +12 -13
- package/dist/core/{LinearGradient-xbloQjzt.js → LinearGradient-DV6UkhZk.js} +21 -22
- package/dist/core/{Liquify-DMe1V5-O.js → Liquify-W8UQNeEM.js} +24 -26
- package/dist/core/{Pixelate-JF72DGuK.js → Pixelate-_pyYeLRP.js} +6 -8
- package/dist/core/{PolarCoordinates-DDvDhBE-.js → PolarCoordinates-D63xm0oJ.js} +15 -17
- package/dist/core/{ProgressiveBlur-EGkevObV.js → ProgressiveBlur-G-s-o9ic.js} +23 -24
- package/dist/core/{RadialGradient-B7ZZB_VJ.js → RadialGradient-BGVqSwh0.js} +6 -7
- package/dist/core/{RectangularCoordinates-muWR8mZS.js → RectangularCoordinates-DyHBo456.js} +19 -21
- package/dist/core/{Ripples-8XaZaXQF.js → Ripples-2FGWCZlp.js} +9 -10
- package/dist/core/{SimplexNoise-DJUe0wz_.js → SimplexNoise-B6dtUCmn.js} +4 -4
- package/dist/core/{SineWave-Dl3nFO1W.js → SineWave-BtPf6-2H.js} +11 -12
- package/dist/core/{SolidColor-CWGq_Bjq.js → SolidColor-CETl1cEr.js} +1 -1
- package/dist/core/{Spherize-C-jZEUsN.js → Spherize-BwvUcorJ.js} +24 -25
- package/dist/core/{Spiral-BSB_R39p.js → Spiral-DmJWmUmr.js} +16 -17
- package/dist/core/{Strands-0stO5BMy.js → Strands-CV1oCmHx.js} +31 -32
- package/dist/core/{Stretch-B645paha.js → Stretch-pl-Cn2F8.js} +23 -25
- package/dist/core/{Swirl-CVnbawit.js → Swirl-D65vXLDw.js} +15 -16
- package/dist/core/{TiltShift-0CxNRI6L.js → TiltShift-CFcK6Hzg.js} +22 -23
- package/dist/core/{Tritone-Daa-I5UD.js → Tritone-EmnjV2rX.js} +8 -9
- package/dist/core/{Twirl-2CJVZEtk.js → Twirl-HSMyRx5I.js} +18 -20
- package/dist/core/{WaveDistortion-BscXN2rs.js → WaveDistortion-DG8GO_l8.js} +31 -33
- package/dist/core/{ZoomBlur-CAqK0Kju.js → ZoomBlur-C01oGwwG.js} +12 -13
- package/dist/core/colorMixing-CZPFmiT4.js +68 -0
- package/dist/core/edges-Djr_12SL.js +25 -0
- package/dist/core/helpers/distort.d.ts.map +1 -1
- package/dist/core/helpers/edgeMask.d.ts.map +1 -1
- package/dist/core/helpers/glow.d.ts +3 -2
- package/dist/core/helpers/glow.d.ts.map +1 -1
- package/dist/core/helpers/grain.d.ts.map +1 -1
- package/dist/core/index.js +94 -102
- package/dist/core/shaders/AngularBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/AngularBlur/index.js +2 -2
- package/dist/core/shaders/Ascii/index.d.ts.map +1 -1
- package/dist/core/shaders/Ascii/index.js +1 -1
- package/dist/core/shaders/Beam/index.d.ts.map +1 -1
- package/dist/core/shaders/Beam/index.js +3 -3
- package/dist/core/shaders/Blob/index.d.ts.map +1 -1
- package/dist/core/shaders/Blob/index.js +3 -3
- package/dist/core/shaders/Blur/index.d.ts.map +1 -1
- package/dist/core/shaders/Blur/index.js +1 -1
- package/dist/core/shaders/Bulge/index.d.ts.map +1 -1
- package/dist/core/shaders/Bulge/index.js +3 -3
- package/dist/core/shaders/CRTScreen/index.d.ts.map +1 -1
- package/dist/core/shaders/CRTScreen/index.js +1 -1
- package/dist/core/shaders/ChannelBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ChannelBlur/index.js +1 -1
- package/dist/core/shaders/Checkerboard/index.d.ts.map +1 -1
- package/dist/core/shaders/Checkerboard/index.js +3 -3
- package/dist/core/shaders/ChromaFlow/index.d.ts.map +1 -1
- package/dist/core/shaders/ChromaFlow/index.js +2 -2
- package/dist/core/shaders/ChromaticAberration/index.d.ts.map +1 -1
- package/dist/core/shaders/ChromaticAberration/index.js +2 -2
- package/dist/core/shaders/Circle/index.d.ts.map +1 -1
- package/dist/core/shaders/Circle/index.js +2 -2
- package/dist/core/shaders/CursorTrail/index.d.ts.map +1 -1
- package/dist/core/shaders/CursorTrail/index.js +3 -3
- package/dist/core/shaders/DiffuseBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/DiffuseBlur/index.js +3 -3
- package/dist/core/shaders/Dither/index.d.ts.map +1 -1
- package/dist/core/shaders/Dither/index.js +2 -2
- package/dist/core/shaders/DotGrid/index.d.ts.map +1 -1
- package/dist/core/shaders/DotGrid/index.js +2 -2
- package/dist/core/shaders/Duotone/index.d.ts.map +1 -1
- package/dist/core/shaders/Duotone/index.js +3 -3
- package/dist/core/shaders/FilmGrain/index.d.ts.map +1 -1
- package/dist/core/shaders/FilmGrain/index.js +1 -1
- package/dist/core/shaders/FloatingParticles/index.d.ts.map +1 -1
- package/dist/core/shaders/FloatingParticles/index.js +2 -2
- package/dist/core/shaders/GlassTiles/index.d.ts.map +1 -1
- package/dist/core/shaders/GlassTiles/index.js +1 -1
- package/dist/core/shaders/Glow/index.d.ts.map +1 -1
- package/dist/core/shaders/Glow/index.js +1 -1
- package/dist/core/shaders/Godrays/index.d.ts.map +1 -1
- package/dist/core/shaders/Godrays/index.js +2 -2
- package/dist/core/shaders/Grid/index.d.ts.map +1 -1
- package/dist/core/shaders/Grid/index.js +2 -2
- package/dist/core/shaders/GridDistortion/index.d.ts.map +1 -1
- package/dist/core/shaders/GridDistortion/index.js +3 -3
- package/dist/core/shaders/Group/index.d.ts.map +1 -1
- package/dist/core/shaders/Group/index.js +1 -1
- package/dist/core/shaders/Halftone/index.d.ts.map +1 -1
- package/dist/core/shaders/Halftone/index.js +2 -2
- package/dist/core/shaders/ImageTexture/index.d.ts.map +1 -1
- package/dist/core/shaders/ImageTexture/index.js +1 -1
- package/dist/core/shaders/Invert/index.d.ts.map +1 -1
- package/dist/core/shaders/Invert/index.js +1 -1
- package/dist/core/shaders/LinearBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/LinearBlur/index.js +2 -2
- package/dist/core/shaders/LinearGradient/index.d.ts.map +1 -1
- package/dist/core/shaders/LinearGradient/index.js +3 -3
- package/dist/core/shaders/Liquify/index.d.ts.map +1 -1
- package/dist/core/shaders/Liquify/index.js +3 -3
- package/dist/core/shaders/Pixelate/index.d.ts.map +1 -1
- package/dist/core/shaders/Pixelate/index.js +1 -1
- package/dist/core/shaders/PolarCoordinates/index.d.ts.map +1 -1
- package/dist/core/shaders/PolarCoordinates/index.js +3 -3
- package/dist/core/shaders/ProgressiveBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ProgressiveBlur/index.js +2 -2
- package/dist/core/shaders/RadialGradient/index.d.ts.map +1 -1
- package/dist/core/shaders/RadialGradient/index.js +3 -3
- package/dist/core/shaders/RectangularCoordinates/index.d.ts.map +1 -1
- package/dist/core/shaders/RectangularCoordinates/index.js +3 -3
- package/dist/core/shaders/Ripples/index.d.ts.map +1 -1
- package/dist/core/shaders/Ripples/index.js +3 -3
- package/dist/core/shaders/SimplexNoise/index.js +3 -3
- package/dist/core/shaders/SineWave/index.d.ts.map +1 -1
- package/dist/core/shaders/SineWave/index.js +2 -2
- package/dist/core/shaders/SolidColor/index.js +2 -2
- package/dist/core/shaders/Spherize/index.d.ts.map +1 -1
- package/dist/core/shaders/Spherize/index.js +2 -2
- package/dist/core/shaders/Spiral/index.d.ts.map +1 -1
- package/dist/core/shaders/Spiral/index.js +3 -3
- package/dist/core/shaders/Strands/index.d.ts.map +1 -1
- package/dist/core/shaders/Strands/index.js +2 -2
- package/dist/core/shaders/Stretch/index.d.ts.map +1 -1
- package/dist/core/shaders/Stretch/index.js +3 -3
- package/dist/core/shaders/Swirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Swirl/index.js +3 -3
- package/dist/core/shaders/TiltShift/index.d.ts.map +1 -1
- package/dist/core/shaders/TiltShift/index.js +2 -2
- package/dist/core/shaders/Tritone/index.d.ts.map +1 -1
- package/dist/core/shaders/Tritone/index.js +3 -3
- package/dist/core/shaders/Twirl/index.d.ts.map +1 -1
- package/dist/core/shaders/Twirl/index.js +3 -3
- package/dist/core/shaders/WaveDistortion/index.d.ts.map +1 -1
- package/dist/core/shaders/WaveDistortion/index.js +3 -3
- package/dist/core/shaders/ZoomBlur/index.d.ts.map +1 -1
- package/dist/core/shaders/ZoomBlur/index.js +2 -2
- package/dist/core/{transformations-DxfQXZWi.js → transformations-Dv5JW9ck.js} +11 -12
- package/dist/core/utilities/colorMixing.d.ts.map +1 -1
- package/dist/core/utilities/edges.d.ts.map +1 -1
- package/dist/core/utilities/transformations.d.ts.map +1 -1
- package/dist/core/utilities/uniforms.d.ts.map +1 -1
- package/dist/core/utilities/uv.d.ts.map +1 -1
- package/dist/core/utilities/uvTransform.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/core/ChannelBlur-CvM6GJgZ.js +0 -118
- package/dist/core/GlassTiles-CXChgYaL.js +0 -69
- package/dist/core/colorMixing-BXiTAqJU.js +0 -69
- package/dist/core/edges-Bn_OIa_h.js +0 -26
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-
|
|
2
|
-
import { t as mixColors } from "./colorMixing-
|
|
3
|
-
import
|
|
1
|
+
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-CZPFmiT4.js";
|
|
3
|
+
import { float, floor, fract, min, mod, screenUV, smoothstep, vec2, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "Checkerboard",
|
|
6
6
|
category: "Base Layers",
|
|
@@ -59,22 +59,21 @@ const componentDefinition = {
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
fragmentNode: ({ uniforms, uvContext }) => {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const correctedUV = vec2$1(uv.x.mul(aspect), uv.y.oneMinus());
|
|
62
|
+
const uv$1 = uvContext ?? screenUV;
|
|
63
|
+
const aspect = viewportSize.x.div(viewportSize.y);
|
|
64
|
+
const correctedUV = vec2(uv$1.x.mul(aspect), uv$1.y.oneMinus());
|
|
66
65
|
const cells = uniforms.cells.uniform;
|
|
67
66
|
const softness = uniforms.softness.uniform;
|
|
68
67
|
const gridUV = correctedUV.mul(cells);
|
|
69
|
-
const gridCoords = floor
|
|
68
|
+
const gridCoords = floor(gridUV);
|
|
70
69
|
const checkerValue = mod(gridCoords.x.add(gridCoords.y), 2);
|
|
71
70
|
let blendFactor = checkerValue;
|
|
72
71
|
if (softness) {
|
|
73
72
|
const cellUV = fract(gridUV);
|
|
74
|
-
const distToEdge = min
|
|
73
|
+
const distToEdge = min(min(cellUV.x, float(1).sub(cellUV.x)), min(cellUV.y, float(1).sub(cellUV.y)));
|
|
75
74
|
const softRange = softness.mul(.5);
|
|
76
|
-
const edgeBlend = smoothstep(float
|
|
77
|
-
blendFactor = checkerValue.mul(edgeBlend).add(float
|
|
75
|
+
const edgeBlend = smoothstep(float(0), softRange, distToEdge);
|
|
76
|
+
blendFactor = checkerValue.mul(edgeBlend).add(float(.5).mul(float(1).sub(edgeBlend)));
|
|
78
77
|
}
|
|
79
78
|
return mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, blendFactor, uniforms.colorSpace.uniform);
|
|
80
79
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as transformColor } from "./transformations-
|
|
1
|
+
import { r as transformColor } from "./transformations-Dv5JW9ck.js";
|
|
2
2
|
import { DataTexture, FloatType, LinearFilter, RGFormat } from "three";
|
|
3
|
-
import
|
|
3
|
+
import { float, mix, screenUV, smoothstep, texture, uniform, vec2, vec4 } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "ChromaFlow",
|
|
6
6
|
category: "Interactive",
|
|
@@ -86,7 +86,6 @@ const componentDefinition = {
|
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
fragmentNode: ({ uniforms, onBeforeRender, onCleanup }) => {
|
|
89
|
-
const { vec2: vec2$1, vec4: vec4$1, float: float$1, uniform: uniform$1, screenUV: screenUV$1, texture, smoothstep, mix: mix$1 } = TSL;
|
|
90
89
|
const GRID_SIZE = 128;
|
|
91
90
|
const displacementData = new Float32Array(GRID_SIZE * GRID_SIZE * 2);
|
|
92
91
|
const liquidData = new Float32Array(GRID_SIZE * GRID_SIZE * 2);
|
|
@@ -100,10 +99,10 @@ const componentDefinition = {
|
|
|
100
99
|
liquidTexture.needsUpdate = true;
|
|
101
100
|
const displacementField = texture(displacementTexture);
|
|
102
101
|
const liquidField = texture(liquidTexture);
|
|
103
|
-
const mouseX = uniform
|
|
104
|
-
const mouseY = uniform
|
|
105
|
-
const mouseVelX = uniform
|
|
106
|
-
const mouseVelY = uniform
|
|
102
|
+
const mouseX = uniform(.5);
|
|
103
|
+
const mouseY = uniform(.5);
|
|
104
|
+
const mouseVelX = uniform(0);
|
|
105
|
+
const mouseVelY = uniform(0);
|
|
107
106
|
let prevX = .5;
|
|
108
107
|
let prevY = .5;
|
|
109
108
|
let lastTime = Date.now();
|
|
@@ -181,41 +180,41 @@ const componentDefinition = {
|
|
|
181
180
|
displacementTexture.dispose();
|
|
182
181
|
liquidTexture.dispose();
|
|
183
182
|
});
|
|
184
|
-
const liquidDensity = liquidField.sample(screenUV
|
|
185
|
-
const pixelSize = vec2
|
|
186
|
-
const sample1 = liquidField.sample(screenUV
|
|
187
|
-
const sample2 = liquidField.sample(screenUV
|
|
188
|
-
const sample3 = liquidField.sample(screenUV
|
|
189
|
-
const sample4 = liquidField.sample(screenUV
|
|
190
|
-
const smoothedLiquid = liquidDensity.add(sample1).add(sample2).add(sample3).add(sample4).mul(float
|
|
191
|
-
const liquidIntensity = smoothstep(float
|
|
192
|
-
const flowPixelSize = vec2
|
|
193
|
-
const centerFlow = displacementField.sample(screenUV
|
|
194
|
-
const flowSample1 = displacementField.sample(screenUV
|
|
195
|
-
const flowSample2 = displacementField.sample(screenUV
|
|
196
|
-
const flowSample3 = displacementField.sample(screenUV
|
|
197
|
-
const flowSample4 = displacementField.sample(screenUV
|
|
198
|
-
const flowVectors = centerFlow.add(flowSample1).add(flowSample2).add(flowSample3).add(flowSample4).mul(float
|
|
183
|
+
const liquidDensity = liquidField.sample(screenUV).x;
|
|
184
|
+
const pixelSize = vec2(float(1 / 128), float(1 / 128));
|
|
185
|
+
const sample1 = liquidField.sample(screenUV.add(vec2(pixelSize.x, float(0)))).x;
|
|
186
|
+
const sample2 = liquidField.sample(screenUV.add(vec2(float(0), pixelSize.y))).x;
|
|
187
|
+
const sample3 = liquidField.sample(screenUV.add(vec2(pixelSize.x.negate(), float(0)))).x;
|
|
188
|
+
const sample4 = liquidField.sample(screenUV.add(vec2(float(0), pixelSize.y.negate()))).x;
|
|
189
|
+
const smoothedLiquid = liquidDensity.add(sample1).add(sample2).add(sample3).add(sample4).mul(float(.2));
|
|
190
|
+
const liquidIntensity = smoothstep(float(0), float(.1), smoothedLiquid);
|
|
191
|
+
const flowPixelSize = vec2(float(1 / 128), float(1 / 128));
|
|
192
|
+
const centerFlow = displacementField.sample(screenUV).xy;
|
|
193
|
+
const flowSample1 = displacementField.sample(screenUV.add(vec2(flowPixelSize.x, float(0)))).xy;
|
|
194
|
+
const flowSample2 = displacementField.sample(screenUV.add(vec2(float(0), flowPixelSize.y))).xy;
|
|
195
|
+
const flowSample3 = displacementField.sample(screenUV.add(vec2(flowPixelSize.x.negate(), float(0)))).xy;
|
|
196
|
+
const flowSample4 = displacementField.sample(screenUV.add(vec2(float(0), flowPixelSize.y.negate()))).xy;
|
|
197
|
+
const flowVectors = centerFlow.add(flowSample1).add(flowSample2).add(flowSample3).add(flowSample4).mul(float(.2));
|
|
199
198
|
const baseColor = uniforms.baseColor.uniform;
|
|
200
199
|
const upColor = uniforms.upColor.uniform;
|
|
201
200
|
const downColor = uniforms.downColor.uniform;
|
|
202
201
|
const leftColor = uniforms.leftColor.uniform;
|
|
203
202
|
const rightColor = uniforms.rightColor.uniform;
|
|
204
203
|
const flowMagnitude = flowVectors.x.mul(flowVectors.x).add(flowVectors.y.mul(flowVectors.y)).sqrt();
|
|
205
|
-
const hasFlow = smoothstep(float
|
|
206
|
-
const normalizedX = flowVectors.x.div(flowMagnitude.add(float
|
|
207
|
-
const normalizedY = flowVectors.y.div(flowMagnitude.add(float
|
|
208
|
-
const rightAmount = smoothstep(float
|
|
209
|
-
const leftAmount = smoothstep(float
|
|
210
|
-
const upAmount = smoothstep(float
|
|
211
|
-
const downAmount = smoothstep(float
|
|
204
|
+
const hasFlow = smoothstep(float(.01), float(.1), flowMagnitude);
|
|
205
|
+
const normalizedX = flowVectors.x.div(flowMagnitude.add(float(.001)));
|
|
206
|
+
const normalizedY = flowVectors.y.div(flowMagnitude.add(float(.001)));
|
|
207
|
+
const rightAmount = smoothstep(float(0), float(.7), normalizedX.max(float(0)));
|
|
208
|
+
const leftAmount = smoothstep(float(0), float(.7), normalizedX.negate().max(float(0)));
|
|
209
|
+
const upAmount = smoothstep(float(0), float(.7), normalizedY.max(float(0)));
|
|
210
|
+
const downAmount = smoothstep(float(0), float(.7), normalizedY.negate().max(float(0)));
|
|
212
211
|
const horizontalColor = leftColor.mul(leftAmount).add(rightColor.mul(rightAmount));
|
|
213
212
|
const verticalColor = downColor.mul(downAmount).add(upColor.mul(upAmount));
|
|
214
213
|
const horizontalWeight = leftAmount.add(rightAmount);
|
|
215
214
|
const verticalWeight = upAmount.add(downAmount);
|
|
216
|
-
const totalWeight = horizontalWeight.add(verticalWeight).add(float
|
|
217
|
-
const finalColor = mix
|
|
218
|
-
return vec4
|
|
215
|
+
const totalWeight = horizontalWeight.add(verticalWeight).add(float(.001));
|
|
216
|
+
const finalColor = mix(baseColor, horizontalColor.mul(horizontalWeight.div(totalWeight)).add(verticalColor.mul(verticalWeight.div(totalWeight))), hasFlow);
|
|
217
|
+
return vec4(finalColor.rgb.mul(liquidIntensity), finalColor.a.mul(liquidIntensity));
|
|
219
218
|
}
|
|
220
219
|
};
|
|
221
220
|
var ChromaFlow_default = componentDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as transformAngle } from "./transformations-
|
|
2
|
-
import
|
|
1
|
+
import { n as transformAngle } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { convertToTexture, cos, radians, screenUV, sin, vec2, vec4 } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "ChromaticAberration",
|
|
5
5
|
category: "Stylize",
|
|
@@ -65,23 +65,22 @@ const componentDefinition = {
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const childTexture = convertToTexture$1(childNode);
|
|
68
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
69
|
+
const childTexture = convertToTexture(childNode);
|
|
71
70
|
onCleanup(() => {
|
|
72
71
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
73
72
|
});
|
|
74
73
|
const angleRad = radians(uniforms.angle.uniform);
|
|
75
|
-
const direction = vec2
|
|
74
|
+
const direction = vec2(cos(angleRad), sin(angleRad));
|
|
76
75
|
const scaledStrength = uniforms.strength.uniform.mul(.1);
|
|
77
|
-
const redUV = screenUV
|
|
78
|
-
const greenUV = screenUV
|
|
79
|
-
const blueUV = screenUV
|
|
76
|
+
const redUV = screenUV.add(direction.mul(scaledStrength).mul(uniforms.redOffset.uniform));
|
|
77
|
+
const greenUV = screenUV.add(direction.mul(scaledStrength).mul(uniforms.greenOffset.uniform));
|
|
78
|
+
const blueUV = screenUV.add(direction.mul(scaledStrength).mul(uniforms.blueOffset.uniform));
|
|
80
79
|
const redChannel = childTexture.sample(redUV).r;
|
|
81
80
|
const greenChannel = childTexture.sample(greenUV).g;
|
|
82
81
|
const blueChannel = childTexture.sample(blueUV).b;
|
|
83
|
-
const alpha = childTexture.sample(screenUV
|
|
84
|
-
return vec4
|
|
82
|
+
const alpha = childTexture.sample(screenUV).a;
|
|
83
|
+
return vec4(redChannel, greenChannel, blueChannel, alpha);
|
|
85
84
|
}
|
|
86
85
|
};
|
|
87
86
|
var ChromaticAberration_default = componentDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as transformPosition, r as transformColor } from "./transformations-
|
|
2
|
-
import
|
|
1
|
+
import { o as transformPosition, r as transformColor } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { length, screenUV, smoothstep, vec2, vec4, viewportSize } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "Circle",
|
|
5
5
|
category: "Base Layers",
|
|
@@ -51,16 +51,15 @@ const componentDefinition = {
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
fragmentNode: ({ uniforms, uvContext }) => {
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const centerPos = vec2$1(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
54
|
+
const uv$1 = uvContext ?? screenUV;
|
|
55
|
+
const aspect = viewportSize.x.div(viewportSize.y);
|
|
56
|
+
const aspectCorrectedUV = vec2(uv$1.x.mul(aspect), uv$1.y);
|
|
57
|
+
const centerPos = vec2(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
59
58
|
const distanceFromCenter = length(aspectCorrectedUV.sub(centerPos));
|
|
60
59
|
const edgeSoftness = uniforms.softness.uniform;
|
|
61
60
|
const circleEdge = uniforms.radius.uniform.mul(.5);
|
|
62
61
|
const circleMask = smoothstep(circleEdge, circleEdge.sub(edgeSoftness), distanceFromCenter);
|
|
63
|
-
return vec4
|
|
62
|
+
return vec4(uniforms.color.uniform.rgb, uniforms.color.uniform.a.mul(circleMask));
|
|
64
63
|
}
|
|
65
64
|
};
|
|
66
65
|
var Circle_default = componentDefinition;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-
|
|
2
|
-
import { t as mixColors } from "./colorMixing-
|
|
1
|
+
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-CZPFmiT4.js";
|
|
3
3
|
import { DataTexture, FloatType, LinearFilter, RGBAFormat } from "three";
|
|
4
|
-
import
|
|
4
|
+
import { float, screenUV, step, texture, vec2, vec4 } from "three/tsl";
|
|
5
5
|
const componentDefinition = {
|
|
6
6
|
name: "CursorTrail",
|
|
7
7
|
category: "Interactive",
|
|
@@ -70,7 +70,6 @@ const componentDefinition = {
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
fragmentNode: ({ uniforms, onBeforeRender, onCleanup }) => {
|
|
73
|
-
const { vec4: vec4$1, float: float$1, texture, step: step$1, screenUV: screenUV$1 } = TSL;
|
|
74
73
|
const GRID_SIZE = 128;
|
|
75
74
|
const trailData = new Float32Array(GRID_SIZE * GRID_SIZE * 4);
|
|
76
75
|
const trailTexture = new DataTexture(trailData, GRID_SIZE, GRID_SIZE, RGBAFormat, FloatType);
|
|
@@ -86,13 +85,13 @@ const componentDefinition = {
|
|
|
86
85
|
const dt = Math.min((currentTime - lastTime) / 1e3, .016);
|
|
87
86
|
lastTime = currentTime;
|
|
88
87
|
const radius = uniforms.radius.uniform.value * .1;
|
|
89
|
-
const length = uniforms.length.uniform.value;
|
|
88
|
+
const length$1 = uniforms.length.uniform.value;
|
|
90
89
|
const shrink = uniforms.shrink.uniform.value;
|
|
91
90
|
const dx = pointer.x - prevX;
|
|
92
91
|
const dy = pointer.y - prevY;
|
|
93
92
|
const speed = Math.sqrt(dx * dx + dy * dy);
|
|
94
|
-
const fadeRate = 1 - dt / Math.max(.1, length);
|
|
95
|
-
const ageRate = dt / Math.max(.1, length);
|
|
93
|
+
const fadeRate = 1 - dt / Math.max(.1, length$1);
|
|
94
|
+
const ageRate = dt / Math.max(.1, length$1);
|
|
96
95
|
for (let i = 0; i < GRID_SIZE * GRID_SIZE * 4; i += 4) {
|
|
97
96
|
trailData[i] *= fadeRate;
|
|
98
97
|
trailData[i + 1] = 1 - (1 - trailData[i]) * shrink;
|
|
@@ -126,19 +125,19 @@ const componentDefinition = {
|
|
|
126
125
|
onCleanup(() => {
|
|
127
126
|
trailTexture.dispose();
|
|
128
127
|
});
|
|
129
|
-
const pixelSize = float
|
|
130
|
-
const centerSample = trailField.sample(screenUV
|
|
131
|
-
const sample1 = trailField.sample(screenUV
|
|
132
|
-
const sample2 = trailField.sample(screenUV
|
|
133
|
-
const sample3 = trailField.sample(screenUV
|
|
134
|
-
const sample4 = trailField.sample(screenUV
|
|
135
|
-
const trailIntensity = centerSample.x.mul(float
|
|
136
|
-
const trailAge = centerSample.z.mul(float
|
|
137
|
-
const circleMask = step
|
|
128
|
+
const pixelSize = float(1 / GRID_SIZE);
|
|
129
|
+
const centerSample = trailField.sample(screenUV);
|
|
130
|
+
const sample1 = trailField.sample(screenUV.add(vec2(pixelSize, float(0))));
|
|
131
|
+
const sample2 = trailField.sample(screenUV.add(vec2(float(0), pixelSize)));
|
|
132
|
+
const sample3 = trailField.sample(screenUV.add(vec2(pixelSize.negate(), float(0))));
|
|
133
|
+
const sample4 = trailField.sample(screenUV.add(vec2(float(0), pixelSize.negate())));
|
|
134
|
+
const trailIntensity = centerSample.x.mul(float(.5)).add(sample1.x.mul(float(.125))).add(sample2.x.mul(float(.125))).add(sample3.x.mul(float(.125))).add(sample4.x.mul(float(.125)));
|
|
135
|
+
const trailAge = centerSample.z.mul(float(.5)).add(sample1.z.mul(float(.125))).add(sample2.z.mul(float(.125))).add(sample3.z.mul(float(.125))).add(sample4.z.mul(float(.125)));
|
|
136
|
+
const circleMask = step(float(.01), trailIntensity);
|
|
138
137
|
const colorA = uniforms.colorA.uniform;
|
|
139
138
|
const colorB = uniforms.colorB.uniform;
|
|
140
139
|
const trailColor = mixColors(colorA, colorB, trailAge, uniforms.colorSpace.uniform);
|
|
141
|
-
return vec4
|
|
140
|
+
return vec4(trailColor.rgb, trailColor.a.mul(circleMask));
|
|
142
141
|
}
|
|
143
142
|
};
|
|
144
143
|
var CursorTrail_default = componentDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as applyEdgeHandling } from "./edges-
|
|
2
|
-
import { a as transformEdges } from "./transformations-
|
|
3
|
-
import
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-Djr_12SL.js";
|
|
2
|
+
import { a as transformEdges } from "./transformations-Dv5JW9ck.js";
|
|
3
|
+
import { convertToTexture, dot, fract, screenUV, sin, vec2, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "DiffuseBlur",
|
|
6
6
|
category: "Blurs",
|
|
@@ -47,35 +47,33 @@ const componentDefinition = {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
uvTransformNode: ({ uv, uniforms, viewportSize: viewportSize$1 }) => {
|
|
51
|
-
const { vec2: vec2$1, fract, sin: sin$1, dot: dot$1 } = TSL;
|
|
50
|
+
uvTransformNode: ({ uv: uv$1, uniforms, viewportSize: viewportSize$1 }) => {
|
|
52
51
|
const hash = (p) => {
|
|
53
|
-
return fract(sin
|
|
52
|
+
return fract(sin(dot(p, vec2(12.9898, 78.233).mul(2))).mul(43758.5453));
|
|
54
53
|
};
|
|
55
|
-
const pixelSize = vec2
|
|
56
|
-
const seed = uv.mul(1e3);
|
|
54
|
+
const pixelSize = vec2(1).div(viewportSize$1);
|
|
55
|
+
const seed = uv$1.mul(1e3);
|
|
57
56
|
const rand1 = hash(seed);
|
|
58
|
-
const rand2 = hash(seed.add(vec2
|
|
59
|
-
const offset = vec2
|
|
60
|
-
return uv.add(offset);
|
|
57
|
+
const rand2 = hash(seed.add(vec2(73.2, 41.9)));
|
|
58
|
+
const offset = vec2(rand1.mul(2).sub(1), rand2.mul(2).sub(1)).mul(uniforms.intensity.uniform).mul(pixelSize);
|
|
59
|
+
return uv$1.add(offset);
|
|
61
60
|
},
|
|
62
61
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const childTexture = convertToTexture$1(childNode);
|
|
62
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
63
|
+
const childTexture = convertToTexture(childNode);
|
|
66
64
|
onCleanup(() => {
|
|
67
65
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
68
66
|
});
|
|
69
67
|
const hash = (p) => {
|
|
70
|
-
return fract(sin
|
|
68
|
+
return fract(sin(dot(p, vec2(12.9898, 78.233).mul(2))).mul(43758.5453));
|
|
71
69
|
};
|
|
72
|
-
const uv = screenUV
|
|
73
|
-
const pixelSize = vec2
|
|
74
|
-
const seed = uv.mul(1e3);
|
|
70
|
+
const uv$1 = screenUV;
|
|
71
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
72
|
+
const seed = uv$1.mul(1e3);
|
|
75
73
|
const rand1 = hash(seed);
|
|
76
|
-
const rand2 = hash(seed.add(vec2
|
|
77
|
-
const offset = vec2
|
|
78
|
-
const displacedUV = uv.add(offset);
|
|
74
|
+
const rand2 = hash(seed.add(vec2(73.2, 41.9)));
|
|
75
|
+
const offset = vec2(rand1.mul(2).sub(1), rand2.mul(2).sub(1)).mul(uniforms.intensity.uniform).mul(pixelSize);
|
|
76
|
+
const displacedUV = uv$1.add(offset);
|
|
79
77
|
return applyEdgeHandling(displacedUV, childTexture.sample(displacedUV), childTexture, uniforms.edges.uniform);
|
|
80
78
|
}
|
|
81
79
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as transformColor } from "./transformations-
|
|
2
|
-
import
|
|
1
|
+
import { r as transformColor } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { dot, floor, mix, screenUV, step, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "Dither",
|
|
5
5
|
category: "Stylize",
|
|
@@ -48,18 +48,17 @@ const componentDefinition = {
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
fragmentNode: ({ uniforms, childNode }) => {
|
|
51
|
-
|
|
52
|
-
if (!childNode) return vec4$1(0, 0, 0, 0);
|
|
51
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
53
52
|
const sourceColor = childNode;
|
|
54
|
-
const luminance = dot
|
|
53
|
+
const luminance = dot(sourceColor.rgb, vec3(.299, .587, .114)).mul(sourceColor.a);
|
|
55
54
|
const pixelSize = uniforms.pixelSize.uniform;
|
|
56
|
-
const bayerPos = floor
|
|
55
|
+
const bayerPos = floor(screenUV.mul(viewportSize).div(pixelSize)).mod(vec2(4));
|
|
57
56
|
const x = bayerPos.x;
|
|
58
57
|
const y = bayerPos.y;
|
|
59
58
|
const bayerValue = y.equal(0).select(x.equal(0).select(0 / 16, x.equal(1).select(8 / 16, x.equal(2).select(2 / 16, 10 / 16))), y.equal(1).select(x.equal(0).select(12 / 16, x.equal(1).select(4 / 16, x.equal(2).select(14 / 16, 6 / 16))), y.equal(2).select(x.equal(0).select(3 / 16, x.equal(1).select(11 / 16, x.equal(2).select(1 / 16, 9 / 16))), x.equal(0).select(15 / 16, x.equal(1).select(7 / 16, x.equal(2).select(13 / 16, 5 / 16))))));
|
|
60
59
|
const threshold = uniforms.threshold.uniform;
|
|
61
|
-
const ditherResult = step
|
|
62
|
-
return vec4
|
|
60
|
+
const ditherResult = step(bayerValue, luminance.add(threshold.sub(.5)));
|
|
61
|
+
return vec4(mix(uniforms.colorA.uniform.rgb, uniforms.colorB.uniform.rgb, ditherResult), mix(uniforms.colorA.uniform.a, uniforms.colorB.uniform.a, ditherResult));
|
|
63
62
|
}
|
|
64
63
|
};
|
|
65
64
|
var Dither_default = componentDefinition;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as transformColor } from "./transformations-
|
|
2
|
-
import
|
|
1
|
+
import { r as transformColor } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { float, floor, fwidth, length, mix, screenUV, sin, smoothstep, time, vec2, vec4, viewportSize } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "DotGrid",
|
|
5
5
|
category: "Base Layers",
|
|
@@ -50,25 +50,24 @@ const componentDefinition = {
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
fragmentNode: ({ uniforms, uvContext }) => {
|
|
53
|
-
const
|
|
54
|
-
const uvCoords = uvContext ?? screenUV$1;
|
|
53
|
+
const uvCoords = uvContext ?? screenUV;
|
|
55
54
|
const density = uniforms.density.uniform;
|
|
56
55
|
const dotSize = uniforms.dotSize.uniform;
|
|
57
56
|
const dotColor = uniforms.color.uniform;
|
|
58
57
|
const twinkleIntensity = uniforms.twinkle.uniform;
|
|
59
|
-
const resolution = viewportSize
|
|
58
|
+
const resolution = viewportSize;
|
|
60
59
|
const aspect = resolution.x.div(resolution.y);
|
|
61
|
-
const correctedUV = vec2
|
|
60
|
+
const correctedUV = vec2(uvCoords.x.mul(aspect), uvCoords.y.oneMinus());
|
|
62
61
|
const gridUV = correctedUV.mul(density);
|
|
63
|
-
const centerDistance = length(gridUV.sub(floor
|
|
64
|
-
const pixelSize = length(
|
|
65
|
-
const dot$1 = float
|
|
66
|
-
const gridPosition = floor
|
|
62
|
+
const centerDistance = length(gridUV.sub(floor(gridUV)).sub(.5));
|
|
63
|
+
const pixelSize = length(fwidth(correctedUV.mul(density)));
|
|
64
|
+
const dot$1 = float(1).sub(smoothstep(dotSize.mul(.5), dotSize.mul(.5).add(pixelSize.mul(.5)), centerDistance));
|
|
65
|
+
const gridPosition = floor(gridUV);
|
|
67
66
|
const dotPhase = gridPosition.x.mul(12.9898).add(gridPosition.y.mul(78.233)).sin().mul(43758.5453).fract();
|
|
68
|
-
const twinkleValue = sin
|
|
69
|
-
const twinkleModifier = mix
|
|
67
|
+
const twinkleValue = sin(time.mul(2).add(dotPhase.mul(6.28318))).mul(.5).add(.5);
|
|
68
|
+
const twinkleModifier = mix(float(1), twinkleValue, twinkleIntensity);
|
|
70
69
|
const twinkledAlpha = dot$1.mul(twinkleModifier);
|
|
71
|
-
return vec4
|
|
70
|
+
return vec4(dotColor.rgb, twinkledAlpha);
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
73
|
var DotGrid_default = componentDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-
|
|
2
|
-
import { t as mixColors } from "./colorMixing-
|
|
3
|
-
import
|
|
1
|
+
import { i as transformColorSpace, r as transformColor, t as colorSpaceOptions } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-CZPFmiT4.js";
|
|
3
|
+
import { convertToTexture, dot, screenUV, smoothstep, vec3, vec4 } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "Duotone",
|
|
6
6
|
category: "Adjustments",
|
|
@@ -49,16 +49,15 @@ const componentDefinition = {
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const childTexture = convertToTexture$1(childNode);
|
|
52
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
53
|
+
const childTexture = convertToTexture(childNode);
|
|
55
54
|
onCleanup(() => {
|
|
56
55
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
57
56
|
});
|
|
58
|
-
const inputColor = childTexture.sample(screenUV
|
|
59
|
-
const luminance = dot
|
|
57
|
+
const inputColor = childTexture.sample(screenUV);
|
|
58
|
+
const luminance = dot(inputColor.rgb, vec3(.299, .587, .114));
|
|
60
59
|
const adjustedLuminance = smoothstep(uniforms.blend.uniform.sub(.5), uniforms.blend.uniform.add(.5), luminance);
|
|
61
|
-
return vec4
|
|
60
|
+
return vec4(mixColors(uniforms.colorA.uniform, uniforms.colorB.uniform, adjustedLuminance, uniforms.colorSpace.uniform).rgb, inputColor.a);
|
|
62
61
|
}
|
|
63
62
|
};
|
|
64
63
|
var Duotone_default = componentDefinition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { dot, float, fract, screenUV, sin, vec2, vec4 } from "three/tsl";
|
|
2
2
|
const componentDefinition = {
|
|
3
3
|
name: "FilmGrain",
|
|
4
4
|
category: "Stylize",
|
|
@@ -17,11 +17,10 @@ const componentDefinition = {
|
|
|
17
17
|
}
|
|
18
18
|
} },
|
|
19
19
|
fragmentNode: ({ uniforms, childNode, uvContext }) => {
|
|
20
|
-
const { vec2: vec2$1, vec4: vec4$1, float: float$1, screenUV: screenUV$1, sin: sin$1, dot: dot$1, fract } = TSL;
|
|
21
20
|
const strength = uniforms.strength.uniform;
|
|
22
|
-
const sourceColor = childNode || vec4
|
|
23
|
-
const grainIntensity = fract(sin
|
|
24
|
-
return vec4
|
|
21
|
+
const sourceColor = childNode || vec4(0, 0, 0, 0);
|
|
22
|
+
const grainIntensity = fract(sin(dot(uvContext ?? screenUV, vec2(float(12.9898), float(78.233)).mul(float(2)))).mul(float(43758.5453))).mul(float(2)).sub(float(1)).mul(strength.mul(float(.1)));
|
|
23
|
+
return vec4(sourceColor.rgb.add(grainIntensity), sourceColor.a);
|
|
25
24
|
}
|
|
26
25
|
};
|
|
27
26
|
var FilmGrain_default = componentDefinition;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { r as transformColor } from "./transformations-
|
|
2
|
-
import
|
|
3
|
-
var { vec2: vec2$1, vec3: vec3$1, vec4: vec4$1, float: float$1, sin: sin$1, cos: cos$1, smoothstep, mix: mix$1, min: min$1, floor: floor$1, fract, length, dot: dot$1, screenUV: screenUV$1, viewportSize: viewportSize$1, time, Fn } = TSL;
|
|
1
|
+
import { r as transformColor } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { Fn, cos, dot, float, floor, fract, length, min, mix, screenUV, sin, smoothstep, time, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
4
3
|
var hash1_2 = Fn(([p]) => {
|
|
5
|
-
return fract(sin
|
|
4
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))).mul(43758.5453123));
|
|
6
5
|
});
|
|
7
6
|
var hash2_2 = Fn(([p]) => {
|
|
8
|
-
return fract(sin
|
|
7
|
+
return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))).mul(43758.5453));
|
|
9
8
|
});
|
|
10
9
|
var voronoiPointFromRoot = Fn(([root, deg]) => {
|
|
11
10
|
const point = hash2_2(root).sub(.5);
|
|
12
|
-
const s = sin
|
|
13
|
-
const c = cos
|
|
14
|
-
return vec2
|
|
11
|
+
const s = sin(deg);
|
|
12
|
+
const c = cos(deg);
|
|
13
|
+
return vec2(c.mul(point.x).sub(s.mul(point.y)).mul(.66), s.mul(point.x).add(c.mul(point.y)).mul(.66)).add(root).add(.5);
|
|
15
14
|
});
|
|
16
|
-
var degFromRootUV = Fn(([uv, randomness]) => {
|
|
17
|
-
return time.mul(randomness).mul(hash1_2(uv).sub(.5)).mul(2);
|
|
15
|
+
var degFromRootUV = Fn(([uv$1, randomness]) => {
|
|
16
|
+
return time.mul(randomness).mul(hash1_2(uv$1).sub(.5)).mul(2);
|
|
18
17
|
});
|
|
19
|
-
var getParticleDistance = Fn(([uv, cellUV, randomness]) => {
|
|
18
|
+
var getParticleDistance = Fn(([uv$1, cellUV, randomness]) => {
|
|
20
19
|
const pointUV = voronoiPointFromRoot(cellUV, degFromRootUV(cellUV, randomness));
|
|
21
|
-
return length(uv.sub(pointUV));
|
|
20
|
+
return length(uv$1.sub(pointUV));
|
|
22
21
|
});
|
|
23
22
|
const componentDefinition = {
|
|
24
23
|
name: "FloatingParticles",
|
|
@@ -148,11 +147,11 @@ const componentDefinition = {
|
|
|
148
147
|
}
|
|
149
148
|
},
|
|
150
149
|
fragmentNode: ({ uniforms, childNode, uvContext }) => {
|
|
151
|
-
const baseUV = uvContext ?? screenUV
|
|
152
|
-
const renderParticle = Fn(([uv$
|
|
153
|
-
const rootUV = floor
|
|
154
|
-
const localPos = fract(uv$
|
|
155
|
-
let minDist = getParticleDistance(uv$
|
|
150
|
+
const baseUV = uvContext ?? screenUV;
|
|
151
|
+
const renderParticle = Fn(([uv$2]) => {
|
|
152
|
+
const rootUV = floor(uv$2);
|
|
153
|
+
const localPos = fract(uv$2);
|
|
154
|
+
let minDist = getParticleDistance(uv$2, rootUV, uniforms.randomness.uniform);
|
|
156
155
|
const softness = uniforms.particleSoftness.uniform;
|
|
157
156
|
const scaledSize = uniforms.particleSize.uniform.mul(.01);
|
|
158
157
|
const outerRadius = scaledSize.mul(.6).add(softness.mul(scaledSize.mul(2.4)));
|
|
@@ -165,52 +164,52 @@ const componentDefinition = {
|
|
|
165
164
|
const checkRight = needsNeighbors.and(nearRight);
|
|
166
165
|
const checkTop = needsNeighbors.and(nearTop);
|
|
167
166
|
const checkBottom = needsNeighbors.and(nearBottom);
|
|
168
|
-
minDist = checkLeft.select(min
|
|
169
|
-
minDist = checkRight.select(min
|
|
170
|
-
minDist = checkTop.select(min
|
|
171
|
-
minDist = checkBottom.select(min
|
|
167
|
+
minDist = checkLeft.select(min(minDist, getParticleDistance(uv$2, rootUV.add(vec2(-1, 0)), uniforms.randomness.uniform)), minDist);
|
|
168
|
+
minDist = checkRight.select(min(minDist, getParticleDistance(uv$2, rootUV.add(vec2(1, 0)), uniforms.randomness.uniform)), minDist);
|
|
169
|
+
minDist = checkTop.select(min(minDist, getParticleDistance(uv$2, rootUV.add(vec2(0, -1)), uniforms.randomness.uniform)), minDist);
|
|
170
|
+
minDist = checkBottom.select(min(minDist, getParticleDistance(uv$2, rootUV.add(vec2(0, 1)), uniforms.randomness.uniform)), minDist);
|
|
172
171
|
const baseIntensity = smoothstep(outerRadius, scaledSize.mul(.6), minDist);
|
|
173
172
|
const twinkleIntensity = uniforms.twinkle.uniform;
|
|
174
173
|
const particlePhase = rootUV.x.mul(12.9898).add(rootUV.y.mul(78.233)).sin().mul(43758.5453).fract();
|
|
175
|
-
const twinkleValue = sin
|
|
176
|
-
const twinkleModifier = mix
|
|
174
|
+
const twinkleValue = sin(time.mul(2).add(particlePhase.mul(6.28318))).mul(.5).add(.5);
|
|
175
|
+
const twinkleModifier = mix(float(1), twinkleValue, twinkleIntensity);
|
|
177
176
|
return baseIntensity.mul(twinkleModifier).mul(uniforms.particleColor.uniform.rgb);
|
|
178
177
|
});
|
|
179
|
-
const layeredParticles = Fn(([uv$
|
|
180
|
-
const sizeMod = float
|
|
181
|
-
const alphaMod = float
|
|
178
|
+
const layeredParticles = Fn(([uv$2]) => {
|
|
179
|
+
const sizeMod = float(1.05);
|
|
180
|
+
const alphaMod = float(.9);
|
|
182
181
|
const layers = uniforms.count.uniform;
|
|
183
|
-
const particles$1 = vec3
|
|
184
|
-
const size = float
|
|
185
|
-
const alpha = float
|
|
186
|
-
const offset = vec2
|
|
182
|
+
const particles$1 = vec3(0).toVar();
|
|
183
|
+
const size = float(1).toVar();
|
|
184
|
+
const alpha = float(1).toVar();
|
|
185
|
+
const offset = vec2(0).toVar();
|
|
187
186
|
const angleRad = uniforms.angle.uniform.mul(3.14159).div(180);
|
|
188
|
-
const baseMovementDir = vec2
|
|
187
|
+
const baseMovementDir = vec2(cos(angleRad), sin(angleRad));
|
|
189
188
|
const baseMovement = time.mul(baseMovementDir).mul(uniforms.speed.uniform);
|
|
190
189
|
const speedVar = uniforms.speedVariance.uniform;
|
|
191
190
|
const angleVar = uniforms.angleVariance.uniform.mul(3.14159).div(180);
|
|
192
191
|
for (let i = 0; i < 4; i++) {
|
|
193
|
-
const layerActive = float
|
|
194
|
-
const layerHash = hash2_2(vec2
|
|
195
|
-
const speedMod = float
|
|
192
|
+
const layerActive = float(i).lessThan(layers).and(alpha.greaterThan(.02));
|
|
193
|
+
const layerHash = hash2_2(vec2(alpha, float(i).mul(7.919)));
|
|
194
|
+
const speedMod = float(1).add(layerHash.x.sub(.5).mul(speedVar));
|
|
196
195
|
const angleDelta = layerHash.y.sub(.5).mul(angleVar).mul(2);
|
|
197
196
|
const variedAngle = angleRad.add(angleDelta);
|
|
198
|
-
const variedDir = vec2
|
|
197
|
+
const variedDir = vec2(cos(variedAngle), sin(variedAngle));
|
|
199
198
|
const movement = baseMovement.mul(speedMod).add(variedDir.sub(baseMovementDir).mul(time).mul(uniforms.speed.uniform));
|
|
200
|
-
const layerParticles = renderParticle(uv$
|
|
201
|
-
particles$1.assign(particles$1.add(layerActive.select(layerParticles, vec3
|
|
199
|
+
const layerParticles = renderParticle(uv$2.mul(size).add(movement).add(offset)).mul(alpha);
|
|
200
|
+
particles$1.assign(particles$1.add(layerActive.select(layerParticles, vec3(0))));
|
|
202
201
|
offset.assign(offset.add(layerHash.mul(10)));
|
|
203
202
|
alpha.assign(alpha.mul(alphaMod));
|
|
204
203
|
size.assign(size.mul(sizeMod));
|
|
205
204
|
}
|
|
206
205
|
return particles$1;
|
|
207
206
|
});
|
|
208
|
-
const uv = baseUV.mul(2).sub(1);
|
|
209
|
-
const aspectRatio = viewportSize
|
|
210
|
-
const particles = layeredParticles(vec2$1
|
|
207
|
+
const uv$1 = baseUV.mul(2).sub(1);
|
|
208
|
+
const aspectRatio = viewportSize.x.div(viewportSize.y);
|
|
209
|
+
const particles = layeredParticles(vec2(uv$1.x.mul(aspectRatio), uv$1.y).mul(uniforms.particleDensity.uniform));
|
|
211
210
|
const particleAlpha = length(particles);
|
|
212
|
-
if (childNode) return vec4
|
|
213
|
-
return vec4
|
|
211
|
+
if (childNode) return vec4(mix(childNode.xyz, particles, particleAlpha.greaterThan(.01).select(particleAlpha, 0)), childNode.w);
|
|
212
|
+
return vec4(particles, particleAlpha);
|
|
214
213
|
}
|
|
215
214
|
};
|
|
216
215
|
var FloatingParticles_default = componentDefinition;
|