shaders 2.2.26 → 2.2.27
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,5 +1,5 @@
|
|
|
1
|
-
import { o as transformPosition } from "./transformations-
|
|
2
|
-
import
|
|
1
|
+
import { o as transformPosition } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { Fn, convertToTexture, cos, float, screenUV, sin, vec2, vec4 } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "AngularBlur",
|
|
5
5
|
category: "Blurs",
|
|
@@ -32,26 +32,25 @@ const componentDefinition = {
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const childTexture = convertToTexture$1(childNode);
|
|
35
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
36
|
+
const childTexture = convertToTexture(childNode);
|
|
38
37
|
onCleanup(() => {
|
|
39
38
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
40
39
|
});
|
|
41
|
-
const center = vec2
|
|
40
|
+
const center = vec2(uniforms.center.uniform.x, uniforms.center.uniform.y.oneMinus());
|
|
42
41
|
const angle = uniforms.intensity.uniform.mul(.005);
|
|
43
42
|
return Fn(() => {
|
|
44
|
-
const initialCoord = screenUV
|
|
45
|
-
const total = vec4
|
|
46
|
-
const totalWeight = float
|
|
47
|
-
const angleStep = angle.div(float
|
|
43
|
+
const initialCoord = screenUV.sub(center);
|
|
44
|
+
const total = vec4(0).toVar();
|
|
45
|
+
const totalWeight = float(0).toVar();
|
|
46
|
+
const angleStep = angle.div(float(31));
|
|
48
47
|
for (let i = 0; i < 32; i++) {
|
|
49
|
-
const t = float
|
|
50
|
-
const weight = float
|
|
51
|
-
const currentAngle = angleStep.mul(float
|
|
52
|
-
const cosAngle = cos
|
|
53
|
-
const sinAngle = sin
|
|
54
|
-
const sampleCoord = vec2
|
|
48
|
+
const t = float(i).div(float(31)).sub(.5).mul(2);
|
|
49
|
+
const weight = float(1).div(float(2.506628)).mul(float(-.5).mul(t).mul(t).div(float(.64)).exp());
|
|
50
|
+
const currentAngle = angleStep.mul(float(i));
|
|
51
|
+
const cosAngle = cos(currentAngle);
|
|
52
|
+
const sinAngle = sin(currentAngle);
|
|
53
|
+
const sampleCoord = vec2(initialCoord.x.mul(cosAngle).sub(initialCoord.y.mul(sinAngle)), initialCoord.x.mul(sinAngle).add(initialCoord.y.mul(cosAngle))).add(center);
|
|
55
54
|
const sample = childTexture.sample(sampleCoord).mul(weight);
|
|
56
55
|
total.assign(total.add(sample));
|
|
57
56
|
totalWeight.assign(totalWeight.add(weight));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataTexture, NearestFilter, RGBAFormat, UnsignedByteType } from "three";
|
|
2
|
-
import
|
|
2
|
+
import { abs, any, ceil, convertToTexture, dot, float, floor, fract, greaterThan, or, screenUV, select, sqrt, texture, uniform, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
3
3
|
const componentDefinition = {
|
|
4
4
|
name: "Ascii",
|
|
5
5
|
category: "Stylize",
|
|
@@ -78,9 +78,8 @@ const componentDefinition = {
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
fragmentNode: ({ uniforms, childNode, onCleanup, onBeforeRender }) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const childTexture = convertToTexture$1(childNode);
|
|
81
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
82
|
+
const childTexture = convertToTexture(childNode);
|
|
84
83
|
onCleanup(() => {
|
|
85
84
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
86
85
|
});
|
|
@@ -188,9 +187,9 @@ const componentDefinition = {
|
|
|
188
187
|
atlasTexture.generateMipmaps = false;
|
|
189
188
|
atlasTexture.needsUpdate = true;
|
|
190
189
|
const atlasField = texture(atlasTexture);
|
|
191
|
-
const charCountUniform =
|
|
192
|
-
const cellSizeUniform =
|
|
193
|
-
const atlasScaleUniform =
|
|
190
|
+
const charCountUniform = uniform(atlasData.charCount);
|
|
191
|
+
const cellSizeUniform = uniform(atlasData.cellSize);
|
|
192
|
+
const atlasScaleUniform = uniform(atlasData.uvScale);
|
|
194
193
|
let lastCharacters = initialCharacters;
|
|
195
194
|
let lastCellSize = initialCellSize;
|
|
196
195
|
let lastFontFamily = initialFontFamily;
|
|
@@ -258,28 +257,28 @@ const componentDefinition = {
|
|
|
258
257
|
atlasTexture.dispose();
|
|
259
258
|
});
|
|
260
259
|
const effectiveCellSize = cellSizeUniform.mul(1.5);
|
|
261
|
-
const mainGridSize = viewportSize
|
|
262
|
-
const gridCoords = screenUV
|
|
263
|
-
const cellCoords = floor
|
|
260
|
+
const mainGridSize = viewportSize.div(effectiveCellSize);
|
|
261
|
+
const gridCoords = screenUV.mul(mainGridSize);
|
|
262
|
+
const cellCoords = floor(gridCoords);
|
|
264
263
|
const rawCellUV = fract(gridCoords);
|
|
265
|
-
const characterSize = uniforms.spacing?.uniform ??
|
|
266
|
-
const center = vec2
|
|
264
|
+
const characterSize = uniforms.spacing?.uniform ?? uniform(initialSpacing);
|
|
265
|
+
const center = vec2(.5);
|
|
267
266
|
const centeredUV = rawCellUV.sub(center);
|
|
268
267
|
const cellUV = centeredUV.div(characterSize).add(center);
|
|
269
|
-
const isOutsideBounds =
|
|
270
|
-
const cellCenter = cellCoords.add(vec2
|
|
268
|
+
const isOutsideBounds = any(greaterThan(abs(centeredUV), vec2(characterSize.mul(.5))));
|
|
269
|
+
const cellCenter = cellCoords.add(vec2(.5)).div(mainGridSize);
|
|
271
270
|
const cellColor = childTexture.sample(cellCenter);
|
|
272
|
-
const rawBrightness = dot
|
|
271
|
+
const rawBrightness = dot(cellColor.rgb, vec3(.299, .587, .114));
|
|
273
272
|
const charCount = charCountUniform;
|
|
274
|
-
const charIndex = floor
|
|
275
|
-
const atlasSize = ceil(sqrt
|
|
273
|
+
const charIndex = floor(rawBrightness.mul(.8).add(.1).mul(charCount).min(charCount.sub(1e-4)));
|
|
274
|
+
const atlasSize = ceil(sqrt(charCount));
|
|
276
275
|
const atlasCol = charIndex.mod(atlasSize);
|
|
277
|
-
const atlasRow = floor
|
|
278
|
-
const atlasCellSize =
|
|
279
|
-
const atlasSampleUV = vec2
|
|
276
|
+
const atlasRow = floor(charIndex.div(atlasSize));
|
|
277
|
+
const atlasCellSize = float(1).div(atlasSize).mul(atlasScaleUniform);
|
|
278
|
+
const atlasSampleUV = vec2(atlasCol, atlasRow).mul(atlasCellSize).add(cellUV.mul(atlasCellSize));
|
|
280
279
|
const asciiChar = atlasField.sample(atlasSampleUV);
|
|
281
|
-
const isBackground = dot
|
|
282
|
-
return vec4
|
|
280
|
+
const isBackground = dot(asciiChar.rgb, vec3(.299, .587, .114)).lessThan(.1);
|
|
281
|
+
return vec4(asciiChar.rgb.mul(cellColor.rgb), select(or(isBackground, isOutsideBounds), float(0), cellColor.a));
|
|
283
282
|
}
|
|
284
283
|
};
|
|
285
284
|
var Ascii_default = componentDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as transformColorSpace, o as transformPosition, r as transformColor, t as colorSpaceOptions } from "./transformations-
|
|
2
|
-
import { t as mixColors } from "./colorMixing-
|
|
3
|
-
import
|
|
1
|
+
import { i as transformColorSpace, o as transformPosition, r as transformColor, t as colorSpaceOptions } from "./transformations-Dv5JW9ck.js";
|
|
2
|
+
import { t as mixColors } from "./colorMixing-CZPFmiT4.js";
|
|
3
|
+
import { clamp, float, max, mix, pow, screenUV, smoothstep, sqrt, vec2, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "Beam",
|
|
6
6
|
category: "Base Layers",
|
|
@@ -105,34 +105,33 @@ const componentDefinition = {
|
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
fragmentNode: ({ uniforms, uvContext }) => {
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
const toPoint = vec2$1(aspectCorrectedUV.x.sub(aspectCorrectedStart.x), aspectCorrectedUV.y.sub(aspectCorrectedStart.y));
|
|
108
|
+
const baseUV = uvContext ?? screenUV;
|
|
109
|
+
const aspect = viewportSize.x.div(viewportSize.y);
|
|
110
|
+
const startPos = vec2(uniforms.startPosition.uniform.x, uniforms.startPosition.uniform.y.oneMinus());
|
|
111
|
+
const endPos = vec2(uniforms.endPosition.uniform.x, uniforms.endPosition.uniform.y.oneMinus());
|
|
112
|
+
const aspectCorrectedStart = vec2(startPos.x.mul(aspect), startPos.y);
|
|
113
|
+
const aspectCorrectedEnd = vec2(endPos.x.mul(aspect), endPos.y);
|
|
114
|
+
const aspectCorrectedUV = vec2(baseUV.x.mul(aspect), baseUV.y);
|
|
115
|
+
const lineVec = vec2(aspectCorrectedEnd.x.sub(aspectCorrectedStart.x), aspectCorrectedEnd.y.sub(aspectCorrectedStart.y));
|
|
116
|
+
const toPoint = vec2(aspectCorrectedUV.x.sub(aspectCorrectedStart.x), aspectCorrectedUV.y.sub(aspectCorrectedStart.y));
|
|
118
117
|
const dotProduct = toPoint.x.mul(lineVec.x).add(toPoint.y.mul(lineVec.y));
|
|
119
118
|
const lineLengthSq = lineVec.x.mul(lineVec.x).add(lineVec.y.mul(lineVec.y));
|
|
120
|
-
const t = clamp
|
|
121
|
-
const closestPoint = vec2
|
|
122
|
-
const distVec = vec2
|
|
123
|
-
const distance = sqrt
|
|
124
|
-
const thickness = mix
|
|
119
|
+
const t = clamp(dotProduct.div(max(lineLengthSq, float(1e-4))), float(0), float(1));
|
|
120
|
+
const closestPoint = vec2(aspectCorrectedStart.x.add(lineVec.x.mul(t)), aspectCorrectedStart.y.add(lineVec.y.mul(t)));
|
|
121
|
+
const distVec = vec2(aspectCorrectedUV.x.sub(closestPoint.x), aspectCorrectedUV.y.sub(closestPoint.y));
|
|
122
|
+
const distance$1 = sqrt(distVec.x.mul(distVec.x).add(distVec.y.mul(distVec.y)));
|
|
123
|
+
const thickness = mix(uniforms.startThickness.uniform.mul(.25), uniforms.endThickness.uniform.mul(.25), t);
|
|
125
124
|
const startSoft = uniforms.startSoftness.uniform;
|
|
126
125
|
const endSoft = uniforms.endSoftness.uniform;
|
|
127
|
-
const softness = mix
|
|
128
|
-
const normalizedDist = distance.div(max
|
|
129
|
-
const edgeEnd = float
|
|
130
|
-
const alpha = pow
|
|
131
|
-
const colorT = smoothstep(float
|
|
126
|
+
const softness = mix(startSoft, endSoft, t);
|
|
127
|
+
const normalizedDist = distance$1.div(max(thickness, float(1e-4)));
|
|
128
|
+
const edgeEnd = float(1).add(softness);
|
|
129
|
+
const alpha = pow(float(1).sub(smoothstep(float(1), edgeEnd, normalizedDist)), float(1).add(softness.mul(1.5)));
|
|
130
|
+
const colorT = smoothstep(float(1).sub(softness), float(1).add(softness), normalizedDist);
|
|
132
131
|
const insideCol = uniforms.insideColor.uniform;
|
|
133
132
|
const outsideCol = uniforms.outsideColor.uniform;
|
|
134
133
|
const beamColorRGB = mixColors(insideCol, outsideCol, colorT, uniforms.colorSpace.uniform).rgb;
|
|
135
|
-
return vec4
|
|
134
|
+
return vec4(beamColorRGB, insideCol.a.add(outsideCol.a).div(float(2)).mul(alpha));
|
|
136
135
|
}
|
|
137
136
|
};
|
|
138
137
|
var Beam_default = componentDefinition;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as createAnimatedTime } from "./time-CTJvRUZ4.js";
|
|
2
|
-
import { i as transformColorSpace, o as transformPosition, r as transformColor, t as colorSpaceOptions } from "./transformations-
|
|
3
|
-
import { t as mixColors } from "./colorMixing-
|
|
4
|
-
import
|
|
2
|
+
import { i as transformColorSpace, o as transformPosition, r as transformColor, t as colorSpaceOptions } from "./transformations-Dv5JW9ck.js";
|
|
3
|
+
import { t as mixColors } from "./colorMixing-CZPFmiT4.js";
|
|
4
|
+
import { dot, float, length, max, normalize, pow, reflect, screenUV, sin, smoothstep, vec2, vec3, vec4, viewportSize } from "three/tsl";
|
|
5
5
|
const componentDefinition = {
|
|
6
6
|
name: "Blob",
|
|
7
7
|
category: "Base Layers",
|
|
@@ -159,8 +159,7 @@ const componentDefinition = {
|
|
|
159
159
|
},
|
|
160
160
|
fragmentNode: (params) => {
|
|
161
161
|
const { uniforms, uvContext } = params;
|
|
162
|
-
const
|
|
163
|
-
const baseUV = uvContext ?? screenUV$1;
|
|
162
|
+
const baseUV = uvContext ?? screenUV;
|
|
164
163
|
const animTime = createAnimatedTime(params, uniforms.speed, uniforms.seed);
|
|
165
164
|
const colorA = uniforms.colorA.uniform;
|
|
166
165
|
const colorB = uniforms.colorB.uniform;
|
|
@@ -172,46 +171,46 @@ const componentDefinition = {
|
|
|
172
171
|
const highlightY = uniforms.highlightY.uniform;
|
|
173
172
|
const highlightZ = uniforms.highlightZ.uniform;
|
|
174
173
|
const highlightColor = uniforms.highlightColor.uniform;
|
|
175
|
-
const edgeWidth = softness.mul(float
|
|
176
|
-
const edgeCurve = softness.mul(float
|
|
177
|
-
const edgeComplexity = float
|
|
178
|
-
const aspect = viewportSize
|
|
179
|
-
const aspectCorrectedUV = vec2
|
|
180
|
-
const centerPos = vec2
|
|
181
|
-
const uv = aspectCorrectedUV.sub(centerPos);
|
|
182
|
-
const dist = length(uv);
|
|
174
|
+
const edgeWidth = softness.mul(float(.3));
|
|
175
|
+
const edgeCurve = softness.mul(float(2)).add(float(.5));
|
|
176
|
+
const edgeComplexity = float(.5);
|
|
177
|
+
const aspect = viewportSize.x.div(viewportSize.y);
|
|
178
|
+
const aspectCorrectedUV = vec2(baseUV.x.mul(aspect), baseUV.y);
|
|
179
|
+
const centerPos = vec2(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
180
|
+
const uv$1 = aspectCorrectedUV.sub(centerPos);
|
|
181
|
+
const dist = length(uv$1);
|
|
183
182
|
const baseRadius = size;
|
|
184
|
-
const noiseScale = float
|
|
185
|
-
const noise1 = sin$1
|
|
186
|
-
const noise2 = sin$1
|
|
187
|
-
const noise3 = sin$1
|
|
188
|
-
const noise4 = sin$1
|
|
189
|
-
const noise5 = sin$1
|
|
190
|
-
const noise6 = sin$1
|
|
183
|
+
const noiseScale = float(4);
|
|
184
|
+
const noise1 = sin(uv$1.x.mul(noiseScale.mul(float(.8))).add(animTime.mul(float(.8)))).mul(sin(uv$1.y.mul(noiseScale.mul(float(.7))).add(animTime.mul(float(.6))))).add(sin(uv$1.x.mul(noiseScale.mul(float(1.2))).sub(uv$1.y.mul(noiseScale.mul(float(.9))).add(animTime.mul(float(.4)))))).mul(float(.15)).mul(deformation);
|
|
185
|
+
const noise2 = sin(uv$1.x.mul(noiseScale.mul(float(1.4))).sub(animTime.mul(float(.5)))).mul(sin(uv$1.y.mul(noiseScale.mul(float(1.1))).add(animTime.mul(float(.7))))).mul(float(.12)).mul(deformation).mul(smoothstep(float(.15), float(.25), edgeComplexity));
|
|
186
|
+
const noise3 = sin(uv$1.x.mul(noiseScale.mul(float(1.8))).add(uv$1.y.mul(noiseScale.mul(float(1.6))).add(animTime.mul(float(.3))))).add(sin(uv$1.x.mul(noiseScale.mul(float(.6))).sub(animTime.mul(float(.9))))).mul(float(.1)).mul(deformation).mul(smoothstep(float(.3), float(.4), edgeComplexity));
|
|
187
|
+
const noise4 = sin(uv$1.x.mul(noiseScale.mul(float(2.2))).add(animTime.mul(float(.2)))).mul(sin(uv$1.y.mul(noiseScale.mul(float(1.9))).sub(animTime.mul(float(.8))))).mul(float(.08)).mul(deformation).mul(smoothstep(float(.45), float(.55), edgeComplexity));
|
|
188
|
+
const noise5 = sin(uv$1.x.mul(noiseScale.mul(float(2.8))).sub(uv$1.y.mul(noiseScale.mul(float(2.4))).add(animTime.mul(float(.6))))).mul(float(.06)).mul(deformation).mul(smoothstep(float(.6), float(.7), edgeComplexity));
|
|
189
|
+
const noise6 = sin(uv$1.x.mul(noiseScale.mul(float(3.2))).add(animTime.mul(float(1.1)))).add(sin(uv$1.y.mul(noiseScale.mul(float(3.5))).sub(animTime.mul(float(.4))))).mul(float(.04)).mul(deformation).mul(smoothstep(float(.75), float(.85), edgeComplexity));
|
|
191
190
|
const noiseAmount = noise1.add(noise2).add(noise3).add(noise4).add(noise5).add(noise6);
|
|
192
191
|
const organicRadius = baseRadius.add(noiseAmount);
|
|
193
|
-
const blobMask = pow
|
|
194
|
-
const distFromCenter = length(uv);
|
|
192
|
+
const blobMask = pow(smoothstep(organicRadius.add(edgeWidth), organicRadius.sub(edgeWidth), dist), edgeCurve);
|
|
193
|
+
const distFromCenter = length(uv$1);
|
|
195
194
|
const sphereRadius = organicRadius;
|
|
196
|
-
const normalTilt = smoothstep(float
|
|
197
|
-
const fakeZ = float
|
|
198
|
-
const surfaceNormal = normalize(vec3$1
|
|
199
|
-
const lightDir = normalize(vec3
|
|
200
|
-
const viewDir = vec3
|
|
195
|
+
const normalTilt = smoothstep(float(0), sphereRadius, distFromCenter);
|
|
196
|
+
const fakeZ = float(1).sub(normalTilt.mul(float(.1)));
|
|
197
|
+
const surfaceNormal = normalize(vec3(uv$1.x.mul(normalTilt.add(float(.2))), uv$1.y.mul(normalTilt.add(float(.2))), fakeZ));
|
|
198
|
+
const lightDir = normalize(vec3(highlightX, highlightY, highlightZ));
|
|
199
|
+
const viewDir = vec3(float(0), float(0), float(1));
|
|
201
200
|
const reflectDir = reflect(lightDir.negate(), surfaceNormal);
|
|
202
|
-
const specularPower = float
|
|
203
|
-
const specular = pow
|
|
204
|
-
const curvatureBoost = normalTilt.mul(float
|
|
201
|
+
const specularPower = float(32);
|
|
202
|
+
const specular = pow(max(float(0), dot(reflectDir, viewDir)), specularPower);
|
|
203
|
+
const curvatureBoost = normalTilt.mul(float(.5)).add(float(.5));
|
|
205
204
|
const finalHighlight = specular.mul(curvatureBoost).mul(highlightIntensity).mul(blobMask);
|
|
206
|
-
const posX = uv.x.mul(float
|
|
207
|
-
const posY = uv.y.mul(float
|
|
208
|
-
const colorNoise1 = sin
|
|
209
|
-
const colorNoise2 = sin
|
|
210
|
-
const combinedNoise = colorNoise1.mul(float
|
|
211
|
-
const finalColorRGB = mixColors(colorA, colorB, smoothstep(float
|
|
212
|
-
const avgAlpha = colorA.a.add(colorB.a).div(float
|
|
205
|
+
const posX = uv$1.x.mul(float(3));
|
|
206
|
+
const posY = uv$1.y.mul(float(3));
|
|
207
|
+
const colorNoise1 = sin(posX.add(animTime.mul(float(.4)))).mul(sin(posY.add(animTime.mul(float(.3))))).add(sin(posX.mul(float(.7)).add(posY.mul(float(.8))).add(animTime.mul(float(.2))))).mul(float(.5)).add(float(.5));
|
|
208
|
+
const colorNoise2 = sin(posX.mul(float(1.3)).sub(animTime.mul(float(.5)))).mul(sin(posY.mul(float(1.1)).add(animTime.mul(float(.6))))).add(sin(posX.mul(float(.5)).sub(posY.mul(float(.6)).sub(animTime.mul(float(.3)))))).mul(float(.5)).add(float(.5));
|
|
209
|
+
const combinedNoise = colorNoise1.mul(float(.6)).add(colorNoise2.mul(float(.4)));
|
|
210
|
+
const finalColorRGB = mixColors(colorA, colorB, smoothstep(float(.1), float(.9), combinedNoise), uniforms.colorSpace.uniform).rgb;
|
|
211
|
+
const avgAlpha = colorA.a.add(colorB.a).div(float(2));
|
|
213
212
|
const highlightContribution = highlightColor.rgb.mul(finalHighlight);
|
|
214
|
-
return vec4
|
|
213
|
+
return vec4(finalColorRGB.add(highlightContribution), avgAlpha.mul(blobMask));
|
|
215
214
|
}
|
|
216
215
|
};
|
|
217
216
|
var Blob_default = componentDefinition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Fn, convertToTexture, float, screenUV, vec2, vec4, viewportSize } from "three/tsl";
|
|
2
2
|
const componentDefinition = {
|
|
3
3
|
name: "Blur",
|
|
4
4
|
category: "Blurs",
|
|
@@ -17,9 +17,8 @@ const componentDefinition = {
|
|
|
17
17
|
}
|
|
18
18
|
} },
|
|
19
19
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const childTexture = convertToTexture$1(childNode);
|
|
20
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
21
|
+
const childTexture = convertToTexture(childNode);
|
|
23
22
|
onCleanup(() => {
|
|
24
23
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
25
24
|
});
|
|
@@ -40,15 +39,15 @@ const componentDefinition = {
|
|
|
40
39
|
];
|
|
41
40
|
const weightSum = 6.214;
|
|
42
41
|
const scaledIntensity = uniforms.intensity.uniform.mul(.06);
|
|
43
|
-
const horizontalTexture = convertToTexture
|
|
44
|
-
const uv = screenUV
|
|
42
|
+
const horizontalTexture = convertToTexture(Fn(() => {
|
|
43
|
+
const uv$1 = screenUV;
|
|
45
44
|
const blurRadius = scaledIntensity;
|
|
46
|
-
const pixelSize = vec2
|
|
47
|
-
const total = vec4
|
|
45
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
46
|
+
const total = vec4(0).toVar();
|
|
48
47
|
for (let x = -6; x <= 6; x++) {
|
|
49
|
-
const weight = float
|
|
50
|
-
const offset = vec2
|
|
51
|
-
const sampleCoord = uv.add(offset);
|
|
48
|
+
const weight = float(weights[x + 6] / weightSum);
|
|
49
|
+
const offset = vec2(float(x), float(0)).mul(blurRadius).mul(pixelSize);
|
|
50
|
+
const sampleCoord = uv$1.add(offset);
|
|
52
51
|
const sample = childTexture.sample(sampleCoord).mul(weight);
|
|
53
52
|
total.assign(total.add(sample));
|
|
54
53
|
}
|
|
@@ -58,14 +57,14 @@ const componentDefinition = {
|
|
|
58
57
|
if (horizontalTexture?.renderTarget?.dispose) horizontalTexture.renderTarget.dispose();
|
|
59
58
|
});
|
|
60
59
|
return Fn(() => {
|
|
61
|
-
const uv = screenUV
|
|
60
|
+
const uv$1 = screenUV;
|
|
62
61
|
const blurRadius = scaledIntensity;
|
|
63
|
-
const pixelSize = vec2
|
|
64
|
-
const total = vec4
|
|
62
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
63
|
+
const total = vec4(0).toVar();
|
|
65
64
|
for (let y = -6; y <= 6; y++) {
|
|
66
|
-
const weight = float
|
|
67
|
-
const offset = vec2
|
|
68
|
-
const sampleCoord = uv.add(offset);
|
|
65
|
+
const weight = float(weights[y + 6] / weightSum);
|
|
66
|
+
const offset = vec2(float(0), float(y)).mul(blurRadius).mul(pixelSize);
|
|
67
|
+
const sampleCoord = uv$1.add(offset);
|
|
69
68
|
const sample = horizontalTexture.sample(sampleCoord).mul(weight);
|
|
70
69
|
total.assign(total.add(sample));
|
|
71
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as applyEdgeHandling } from "./edges-
|
|
2
|
-
import { a as transformEdges, o as transformPosition } from "./transformations-
|
|
3
|
-
import
|
|
1
|
+
import { t as applyEdgeHandling } from "./edges-Djr_12SL.js";
|
|
2
|
+
import { a as transformEdges, o as transformPosition } from "./transformations-Dv5JW9ck.js";
|
|
3
|
+
import { convertToTexture, float, length, max, screenUV, smoothstep, vec2, vec4, viewportSize } from "three/tsl";
|
|
4
4
|
const componentDefinition = {
|
|
5
5
|
name: "Bulge",
|
|
6
6
|
category: "Distortions",
|
|
@@ -81,50 +81,48 @@ const componentDefinition = {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
uvTransformNode: ({ uv, uniforms, viewportSize: viewportSize$1 }) => {
|
|
85
|
-
const { vec2: vec2$1, length, smoothstep, float: float$1, max: max$1 } = TSL;
|
|
84
|
+
uvTransformNode: ({ uv: uv$1, uniforms, viewportSize: viewportSize$1 }) => {
|
|
86
85
|
const aspect = viewportSize$1.x.div(viewportSize$1.y);
|
|
87
|
-
const aspectCorrectedUV = vec2$1
|
|
88
|
-
const centerPos = vec2
|
|
86
|
+
const aspectCorrectedUV = vec2(uv$1.x.mul(aspect), uv$1.y);
|
|
87
|
+
const centerPos = vec2(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
89
88
|
const delta = aspectCorrectedUV.sub(centerPos);
|
|
90
|
-
const distance = length(delta);
|
|
89
|
+
const distance$1 = length(delta);
|
|
91
90
|
const effectRadius = uniforms.radius.uniform.mul(.5);
|
|
92
91
|
const falloffAmount = uniforms.falloff.uniform;
|
|
93
|
-
const smoothFalloff = smoothstep(effectRadius.mul(float
|
|
94
|
-
const normalizedDist = distance.div(effectRadius);
|
|
92
|
+
const smoothFalloff = smoothstep(effectRadius.mul(float(1).sub(falloffAmount).sub(float(.001)).max(float(0))), effectRadius, distance$1).oneMinus();
|
|
93
|
+
const normalizedDist = distance$1.div(effectRadius);
|
|
95
94
|
const distSq = normalizedDist.mul(normalizedDist);
|
|
96
|
-
const quadraticFalloff = max
|
|
95
|
+
const quadraticFalloff = max(float(0), float(1).sub(distSq));
|
|
97
96
|
const falloff = smoothFalloff.mul(quadraticFalloff);
|
|
98
97
|
const displacementAmount = uniforms.strength.uniform.negate().mul(falloff);
|
|
99
|
-
const scaleFactor = float
|
|
98
|
+
const scaleFactor = float(1).add(displacementAmount);
|
|
100
99
|
const bulgedDelta = delta.mul(scaleFactor);
|
|
101
100
|
const bulgedUV = centerPos.add(bulgedDelta);
|
|
102
|
-
return vec2
|
|
101
|
+
return vec2(bulgedUV.x.div(aspect), bulgedUV.y);
|
|
103
102
|
},
|
|
104
103
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const childTexture = convertToTexture$1(childNode);
|
|
104
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
105
|
+
const childTexture = convertToTexture(childNode);
|
|
108
106
|
onCleanup(() => {
|
|
109
107
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
110
108
|
});
|
|
111
|
-
const aspect = viewportSize
|
|
112
|
-
const aspectCorrectedUV = vec2
|
|
113
|
-
const centerPos = vec2
|
|
109
|
+
const aspect = viewportSize.x.div(viewportSize.y);
|
|
110
|
+
const aspectCorrectedUV = vec2(screenUV.x.mul(aspect), screenUV.y);
|
|
111
|
+
const centerPos = vec2(uniforms.center.uniform.x.mul(aspect), uniforms.center.uniform.y.oneMinus());
|
|
114
112
|
const delta = aspectCorrectedUV.sub(centerPos);
|
|
115
|
-
const distance = length(delta);
|
|
113
|
+
const distance$1 = length(delta);
|
|
116
114
|
const effectRadius = uniforms.radius.uniform.mul(.5);
|
|
117
115
|
const falloffAmount = uniforms.falloff.uniform;
|
|
118
|
-
const smoothFalloff = smoothstep(effectRadius.mul(
|
|
119
|
-
const normalizedDist = distance.div(effectRadius);
|
|
116
|
+
const smoothFalloff = smoothstep(effectRadius.mul(float(1).sub(falloffAmount).sub(float(.001)).max(float(0))), effectRadius, distance$1).oneMinus();
|
|
117
|
+
const normalizedDist = distance$1.div(effectRadius);
|
|
120
118
|
const distSq = normalizedDist.mul(normalizedDist);
|
|
121
|
-
const quadraticFalloff =
|
|
119
|
+
const quadraticFalloff = max(float(0), float(1).sub(distSq));
|
|
122
120
|
const falloff = smoothFalloff.mul(quadraticFalloff);
|
|
123
121
|
const displacementAmount = uniforms.strength.uniform.negate().mul(falloff);
|
|
124
|
-
const scaleFactor =
|
|
122
|
+
const scaleFactor = float(1).add(displacementAmount);
|
|
125
123
|
const bulgedDelta = delta.mul(scaleFactor);
|
|
126
124
|
const bulgedUV = centerPos.add(bulgedDelta);
|
|
127
|
-
const finalUV = vec2
|
|
125
|
+
const finalUV = vec2(bulgedUV.x.div(aspect), bulgedUV.y);
|
|
128
126
|
return applyEdgeHandling(finalUV, childTexture.sample(finalUV), childTexture, uniforms.edges.uniform);
|
|
129
127
|
}
|
|
130
128
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { convertToTexture, float, fract, length, screenUV, sin, smoothstep, vec2, vec3, vec4 } from "three/tsl";
|
|
2
2
|
const componentDefinition = {
|
|
3
3
|
name: "CRTScreen",
|
|
4
4
|
category: "Stylize",
|
|
@@ -74,9 +74,8 @@ const componentDefinition = {
|
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const childTexture = convertToTexture$1(childNode);
|
|
77
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
78
|
+
const childTexture = convertToTexture(childNode);
|
|
80
79
|
onCleanup(() => {
|
|
81
80
|
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
82
81
|
});
|
|
@@ -86,26 +85,26 @@ const componentDefinition = {
|
|
|
86
85
|
const scanlineFrequency = uniforms.scanlineFrequency.uniform;
|
|
87
86
|
const brightness = uniforms.brightness.uniform;
|
|
88
87
|
const contrast = uniforms.contrast.uniform;
|
|
89
|
-
const scaledColorShift = colorShift.mul(float
|
|
90
|
-
const redUV = screenUV
|
|
91
|
-
const greenUV = screenUV
|
|
92
|
-
const blueUV = screenUV
|
|
88
|
+
const scaledColorShift = colorShift.mul(float(.002));
|
|
89
|
+
const redUV = screenUV.add(vec2(scaledColorShift, float(0)));
|
|
90
|
+
const greenUV = screenUV;
|
|
91
|
+
const blueUV = screenUV.sub(vec2(scaledColorShift, float(0)));
|
|
93
92
|
const redSample = childTexture.sample(redUV).r;
|
|
94
93
|
const greenSample = childTexture.sample(greenUV).g;
|
|
95
94
|
const blueSample = childTexture.sample(blueUV).b;
|
|
96
|
-
const adjustedColor = vec3
|
|
97
|
-
const scanlineWave = sin
|
|
98
|
-
const scanlineEffect = float
|
|
95
|
+
const adjustedColor = vec3(redSample, greenSample, blueSample).sub(float(.5)).mul(contrast).add(float(.5)).mul(brightness);
|
|
96
|
+
const scanlineWave = sin(screenUV.y.mul(scanlineFrequency).mul(float(3.14159 * 2)));
|
|
97
|
+
const scanlineEffect = float(1).sub(scanlineIntensity.mul(scanlineWave.mul(float(.5)).add(float(.5))));
|
|
99
98
|
const scanlinedColor = adjustedColor.mul(scanlineEffect);
|
|
100
|
-
const phosphorScale = pixelSize.mul(float
|
|
101
|
-
const pixelPhase = fract(screenUV
|
|
102
|
-
const redMask = sin
|
|
103
|
-
const greenMask = sin
|
|
104
|
-
const blueMask = sin
|
|
105
|
-
const phosphorColor = vec3
|
|
106
|
-
const vignetteDistance = length(screenUV
|
|
107
|
-
const vignette = smoothstep(float
|
|
108
|
-
return vec4
|
|
99
|
+
const phosphorScale = pixelSize.mul(float(.5));
|
|
100
|
+
const pixelPhase = fract(screenUV.mul(phosphorScale));
|
|
101
|
+
const redMask = sin(pixelPhase.x.mul(float(6.28318))).mul(float(.1)).add(float(.95));
|
|
102
|
+
const greenMask = sin(pixelPhase.x.mul(float(6.28318)).add(float(2.09))).mul(float(.1)).add(float(.95));
|
|
103
|
+
const blueMask = sin(pixelPhase.x.mul(float(6.28318)).add(float(4.18))).mul(float(.1)).add(float(.95));
|
|
104
|
+
const phosphorColor = vec3(scanlinedColor.r.mul(redMask), scanlinedColor.g.mul(greenMask), scanlinedColor.b.mul(blueMask));
|
|
105
|
+
const vignetteDistance = length(screenUV.sub(vec2(.5, .5)));
|
|
106
|
+
const vignette = smoothstep(float(.8), float(.3), vignetteDistance);
|
|
107
|
+
return vec4(phosphorColor.mul(vignette), float(1));
|
|
109
108
|
}
|
|
110
109
|
};
|
|
111
110
|
var CRTScreen_default = componentDefinition;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Fn, convertToTexture, float, screenUV, vec2, vec4, viewportSize } from "three/tsl";
|
|
2
|
+
const componentDefinition = {
|
|
3
|
+
name: "ChannelBlur",
|
|
4
|
+
category: "Blurs",
|
|
5
|
+
description: "Independent blur for red, green, and blue channels",
|
|
6
|
+
requiresRTT: true,
|
|
7
|
+
requiresChild: true,
|
|
8
|
+
props: {
|
|
9
|
+
redIntensity: {
|
|
10
|
+
default: 0,
|
|
11
|
+
description: "Blur intensity for red channel",
|
|
12
|
+
ui: {
|
|
13
|
+
type: "range",
|
|
14
|
+
min: 0,
|
|
15
|
+
max: 100,
|
|
16
|
+
step: 1,
|
|
17
|
+
label: "Red Intensity"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
greenIntensity: {
|
|
21
|
+
default: 20,
|
|
22
|
+
description: "Blur intensity for green channel",
|
|
23
|
+
ui: {
|
|
24
|
+
type: "range",
|
|
25
|
+
min: 0,
|
|
26
|
+
max: 100,
|
|
27
|
+
step: 1,
|
|
28
|
+
label: "Green Intensity"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
blueIntensity: {
|
|
32
|
+
default: 40,
|
|
33
|
+
description: "Blur intensity for blue channel",
|
|
34
|
+
ui: {
|
|
35
|
+
type: "range",
|
|
36
|
+
min: 0,
|
|
37
|
+
max: 100,
|
|
38
|
+
step: 1,
|
|
39
|
+
label: "Blue Intensity"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
fragmentNode: ({ uniforms, childNode, onCleanup }) => {
|
|
44
|
+
if (!childNode) return vec4(0, 0, 0, 0);
|
|
45
|
+
const childTexture = convertToTexture(childNode);
|
|
46
|
+
onCleanup(() => {
|
|
47
|
+
if (childTexture?.renderTarget?.dispose) childTexture.renderTarget.dispose();
|
|
48
|
+
});
|
|
49
|
+
const weights = [
|
|
50
|
+
.056,
|
|
51
|
+
.135,
|
|
52
|
+
.278,
|
|
53
|
+
.487,
|
|
54
|
+
.726,
|
|
55
|
+
.923,
|
|
56
|
+
1,
|
|
57
|
+
.923,
|
|
58
|
+
.726,
|
|
59
|
+
.487,
|
|
60
|
+
.278,
|
|
61
|
+
.135,
|
|
62
|
+
.056
|
|
63
|
+
];
|
|
64
|
+
const weightSum = 6.214;
|
|
65
|
+
const redRadius = uniforms.redIntensity.uniform.mul(.1);
|
|
66
|
+
const greenRadius = uniforms.greenIntensity.uniform.mul(.1);
|
|
67
|
+
const blueRadius = uniforms.blueIntensity.uniform.mul(.1);
|
|
68
|
+
const horizontalTexture = convertToTexture(Fn(() => {
|
|
69
|
+
const uv$1 = screenUV;
|
|
70
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
71
|
+
const redTotal = float(0).toVar();
|
|
72
|
+
const greenTotal = float(0).toVar();
|
|
73
|
+
const blueTotal = float(0).toVar();
|
|
74
|
+
for (let x = -6; x <= 6; x++) {
|
|
75
|
+
const weight = float(weights[x + 6] / weightSum);
|
|
76
|
+
const xOffset = float(x).mul(pixelSize.x);
|
|
77
|
+
const redOffset = vec2(xOffset.mul(redRadius), float(0));
|
|
78
|
+
const greenOffset = vec2(xOffset.mul(greenRadius), float(0));
|
|
79
|
+
const blueOffset = vec2(xOffset.mul(blueRadius), float(0));
|
|
80
|
+
const redSample = childTexture.sample(uv$1.add(redOffset)).r.mul(weight);
|
|
81
|
+
const greenSample = childTexture.sample(uv$1.add(greenOffset)).g.mul(weight);
|
|
82
|
+
const blueSample = childTexture.sample(uv$1.add(blueOffset)).b.mul(weight);
|
|
83
|
+
redTotal.assign(redTotal.add(redSample));
|
|
84
|
+
greenTotal.assign(greenTotal.add(greenSample));
|
|
85
|
+
blueTotal.assign(blueTotal.add(blueSample));
|
|
86
|
+
}
|
|
87
|
+
return vec4(redTotal, greenTotal, blueTotal, float(1));
|
|
88
|
+
})());
|
|
89
|
+
onCleanup(() => {
|
|
90
|
+
if (horizontalTexture?.renderTarget?.dispose) horizontalTexture.renderTarget.dispose();
|
|
91
|
+
});
|
|
92
|
+
return Fn(() => {
|
|
93
|
+
const uv$1 = screenUV;
|
|
94
|
+
const pixelSize = vec2(1).div(viewportSize);
|
|
95
|
+
const redTotal = float(0).toVar();
|
|
96
|
+
const greenTotal = float(0).toVar();
|
|
97
|
+
const blueTotal = float(0).toVar();
|
|
98
|
+
for (let y = -6; y <= 6; y++) {
|
|
99
|
+
const weight = float(weights[y + 6] / weightSum);
|
|
100
|
+
const yOffset = float(y).mul(pixelSize.y);
|
|
101
|
+
const redOffset = vec2(float(0), yOffset.mul(redRadius));
|
|
102
|
+
const greenOffset = vec2(float(0), yOffset.mul(greenRadius));
|
|
103
|
+
const blueOffset = vec2(float(0), yOffset.mul(blueRadius));
|
|
104
|
+
const redSample = horizontalTexture.sample(uv$1.add(redOffset)).r.mul(weight);
|
|
105
|
+
const greenSample = horizontalTexture.sample(uv$1.add(greenOffset)).g.mul(weight);
|
|
106
|
+
const blueSample = horizontalTexture.sample(uv$1.add(blueOffset)).b.mul(weight);
|
|
107
|
+
redTotal.assign(redTotal.add(redSample));
|
|
108
|
+
greenTotal.assign(greenTotal.add(greenSample));
|
|
109
|
+
blueTotal.assign(blueTotal.add(blueSample));
|
|
110
|
+
}
|
|
111
|
+
const originalAlpha = childTexture.sample(uv$1).a;
|
|
112
|
+
return vec4(redTotal, greenTotal, blueTotal, originalAlpha);
|
|
113
|
+
})();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
var ChannelBlur_default = componentDefinition;
|
|
117
|
+
export { componentDefinition as n, ChannelBlur_default as t };
|