textmode.filters.js 1.2.1 → 1.2.3-beta.1

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/README.md CHANGED
@@ -2,395 +2,95 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- <!-- Add your banner image here when ready -->
6
- <!-- <img alt="textmode_filters_banner" src="YOUR_BANNER_IMAGE_URL" /> -->
5
+ <img alt="textmode.filters.js — filter textmode at GPU speed" src=".github/assets/readme-og.png" />
7
6
 
8
- | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![WebGL](https://img.shields.io/badge/WebGL2-990000?logo=webgl&logoColor=white)](https://www.khronos.org/webgl/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) | [![npm version](https://img.shields.io/npm/v/textmode.filters.js.svg)](https://www.npmjs.com/package/textmode.filters.js) [![license](https://img.shields.io/npm/l/textmode.filters.js.svg)](https://github.com/humanbydefinition/textmode.filters.js/blob/main/LICENSE) | [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![GitHub-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
9
- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vitejs.dev/) [![WebGL2](https://img.shields.io/badge/WebGL2-990000?logo=webgl&logoColor=white)](https://www.khronos.org/webgl/) | [![API](https://img.shields.io/badge/API-typedoc-3178c6?logo=typescript&logoColor=white)](https://code.textmode.art/api/textmode.filters.js/) [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/docs/filters) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![GitHub-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
8
+ |:---|:---|:---|
10
9
 
11
10
  </div>
12
11
 
13
- textmode.filters.js is a GPU-accelerated image filters plugin for [textmode.js](https://code.textmode.art/). Built with [`WebGL2`](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext) fragment shaders, it provides a collection of customizable visual effects that run entirely on the GPU for maximum performance.
12
+ `textmode.filters.js` is an image-filter add-on for [`textmode.js`](https://code.textmode.art/) for shaping the atmosphere and finish of a scene. Its collection of customizable effects is implemented as [`WebGL2`](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext) fragment shaders, running on the GPU and fitting directly into textmode rendering workflows.
14
13
 
15
- [Installation](#installation) •
16
- [Usage](#usage) •
17
- [Filters](#filters) •
18
- [Contributing](#contributing)
14
+ Use built-in treatments to refine a scene, tune their parameters as it runs, or contribute a custom filter when the look calls for something new. `textmode.filters.js` makes shader-powered image processing approachable without requiring advanced graphics experience, giving a sketch a focused visual-effects toolkit.
19
15
 
20
16
  ## Features
21
17
 
22
- - 🚀 **GPU-accelerated** - All filters run on the GPU via WebGL2 fragment shaders
23
- - 🎛️ **Customizable parameters** - Fine-tune each filter to your needs
24
- - 📦 **Lightweight** - Minimal footprint, no external dependencies
25
- - 🤝 **Open to contributions** - Easy to add your own custom filters!
18
+ - **Fourteen built-in effects** - Color adjustment, distortion, CRT, glitch, bloom, scanlines, vignette, grain, and related treatments
19
+ - **GPU-native processing** - Execute every effect as a WebGL2 fragment-shader pass over rendered textmode textures
20
+ - **Scoped and stackable pipelines** - Apply ordered effects to individual layers, the composited scene, or the final presentation stage
21
+ - **Typed parameter control** - Configure effects through numeric shorthand or named option objects with documented defaults
26
22
 
27
- ## Installation
28
-
29
- ```bash
30
- npm install textmode.filters.js
31
- ```
32
-
33
- You can also use it via CDN:
34
-
35
- ```html
36
- <!-- ESM -->
37
- <script type="module" src="https://unpkg.com/textmode.js/dist/textmode.esm.js"></script>
38
- <script type="module" src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.esm.js"></script>
39
-
40
- <!-- UMD -->
41
- <script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
42
- <script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
43
- ```
44
-
45
- ## Usage
46
-
47
- ### ESM
48
-
49
- ```javascript
50
- import { textmode } from 'textmode.js';
51
- import { FiltersPlugin } from 'textmode.filters.js';
52
-
53
- const t = textmode.create({
54
- width: 800,
55
- height: 600,
56
- plugins: [FiltersPlugin],
57
- });
58
-
59
- t.draw(() => {
60
- // Apply filters to layers
61
- t.layers.base.filter('brightness', 1.2);
62
- t.layers.base.filter('contrast', { amount: 1.5 });
63
-
64
- t.background(0);
65
- // ... draw something ...
66
- });
67
- ```
68
-
69
- ### UMD
70
-
71
- ```html
72
- <script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
73
- <script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
74
- <script>
75
- const t = textmode.create({
76
- plugins: [FiltersPlugin],
77
- });
78
-
79
- t.draw(() => {
80
- t.layers.base.filter('brightness', 1.3);
81
- });
82
- </script>
83
- ```
84
-
85
- ## Filters
86
-
87
- ### `brightness`
88
-
89
- Adjust image brightness *(1.0 = normal, >1 = brighter, <1 = darker)*
90
-
91
- **Parameters:**
92
-
93
- - `amount` - Brightness multiplier
94
- Default: `1.0` | Range: `0.0` - `∞`
95
-
96
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
97
-
98
- ---
99
-
100
- ### `contrast`
101
-
102
- Adjust image contrast *(1.0 = normal, >1 = more contrast, <1 = less)*
103
-
104
- **Parameters:**
105
-
106
- - `amount` - Contrast multiplier
107
- Default: `1.0` | Range: `0.0` - `∞`
108
-
109
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
110
-
111
- ---
112
-
113
- ### `hueRotate`
114
-
115
- Shift colors around the color wheel
116
-
117
- **Parameters:**
118
-
119
- - `angle` - Rotation angle in degrees
120
- Default: `0.0` | Range: `0.0` - `360.0`
23
+ ## Try it online first
121
24
 
122
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
25
+ Open [editor.textmode.art](https://editor.textmode.art/), a browser-based live-coding environment for the
26
+ complete official `textmode.js` ecosystem. Sketches run as you edit, with no local toolchain required.
123
27
 
124
- ---
125
-
126
- ### `glitch`
127
-
128
- Digital glitch effect with RGB channel separation, scanlines, and noise
129
-
130
- **Parameters:**
131
-
132
- - `amount` - Glitch intensity
133
- Default: `0.0` | Range: `0.0` - `∞`
134
-
135
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
136
-
137
- ---
138
-
139
- ### `chromaticAberration`
140
-
141
- RGB color channel separation effect that simulates lens distortion
142
-
143
- **Parameters:**
144
-
145
- - `amount` - Offset amount in pixels
146
- Default: `5.0` | Range: `0.0` - `∞`
147
- - `direction` - Direction of the color separation as `[x, y]`
148
- Default: `[1.0, 0.0]` (horizontal)
149
-
150
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
151
-
152
- ---
153
-
154
- ### `pixelate`
155
-
156
- Reduce image resolution to create a mosaic/pixelated effect
28
+ The editor includes `textmode.js` and all four official add-ons: `textmode.export.js`, `textmode.filters.js`,
29
+ `textmode.figlet.js`, and `textmode.synth.js`.
157
30
 
158
- **Parameters:**
31
+ - Write with Monaco-powered completions, hover documentation, and diagnostics.
32
+ - Start with a blank sketch, an included example, or a community gallery sketch.
33
+ - Keep code and preferences saved in the browser, then share sketches through URL-based links.
34
+ - Use microphone or line-input analysis for audio-reactive work, and create on desktop or mobile.
159
35
 
160
- - `pixelSize` - Size of each pixel block in pixels
161
- Default: `4.0` | Range: `1.0` - `∞`
36
+ Use it to apply and tune GPU filters interactively while your sketch runs.
162
37
 
163
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
164
-
165
- ---
166
-
167
- ### `gridDistortion`
168
-
169
- Distort a monospaced character grid by varying the width and height of individual cells. Create wave effects, perspective distortions, or other grid warping effects by providing custom factor arrays.
170
-
171
- **Parameters:**
172
-
173
- - `gridSize` - Grid dimensions as `[columns, rows]`
174
- Default: `[80, 40]` | Maximum: `[128, 128]`
175
- - `widthFactors` - Array of distortion values (0-1) for each column
176
- Must contain at least as many elements as columns (max 128)
177
- - `heightFactors` - Array of distortion values (0-1) for each row
178
- Must contain at least as many elements as rows (max 128)
179
- - `widthVariationScale` - Intensity multiplier for width distortion
180
- Default: `0.5` | Range: `0.0` - `∞`
181
- - `heightVariationScale` - Intensity multiplier for height distortion
182
- Default: `0.5` | Range: `0.0` - `∞`
183
-
184
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
185
-
186
- ---
187
-
188
- ### `crtMattias`
189
-
190
- CRT monitor emulation effect with screen curvature, animated scanlines, blur, vignette, and film grain noise.
191
-
192
- **Parameters:**
193
-
194
- - `curvature` - Amount of screen curvature/barrel distortion
195
- Default: `0.5` | Range: `0.0` - `1.0`
196
- - `scanSpeed` - Speed of the scrolling scanline effect
197
- Default: `1.0` | Range: `0.0` - `10.0`
198
- - `time` - Animation time
199
- Default: `0.0`
200
-
201
- **Author:** [@mattiasgustavsson](https://github.com/mattiasgustavsson)
202
- **Source:** https://github.com/libretro/glsl-shaders/blob/master/crt/shaders/crt-mattias.glsl
203
-
204
- ---
205
-
206
- ### `scanlines`
207
-
208
- A standalone scanline effect that adds horizontal lines to the image to simulate a CRT display or old monitor. Adjustable density, thickness, and movement speed.
209
-
210
- **Parameters:**
211
-
212
- - `count` - Number of scanlines
213
- Default: `300.0` | Range: `10.0` - `∞`
214
- - `lineWidth` - Width of the lines relative to the spacing
215
- Default: `0.5` | Range: `0.0` - `1.0`
216
- - `intensity` - Opacity of the scanlines
217
- Default: `0.75` | Range: `0.0` - `1.0`
218
- - `speed` - Scrolling speed of the lines
219
- Default: `1.0` | Range: `0.0` - `∞`
220
- - `time` - Animation time
221
- Default: `0.0`
222
-
223
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
224
-
225
- ---
226
-
227
- ### `vignette`
228
-
229
- Darkens the edges and corners of the image, drawing focus to the center. Useful for creating a cinematic look or highlighting central content.
230
-
231
- **Parameters:**
232
-
233
- - `amount` - Intensity of the darkening effect
234
- Default: `0.5` | Range: `0.0` - `1.0`
235
- - `softness` - Falloff gradient softness (0 = hard edge, 1 = very soft)
236
- Default: `0.5` | Range: `0.0` - `1.0`
237
- - `roundness` - Shape of the vignette (0 = rectangular, 1 = circular)
238
- Default: `0.5` | Range: `0.0` - `1.0`
239
-
240
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
241
-
242
- ---
243
-
244
- ### `bloom`
245
-
246
- Creates a glow effect around bright areas of the image. Pixels above the brightness threshold emit a soft glow that spreads outward, perfect for creating neon, glowing text, or dreamy effects.
247
-
248
- **Parameters:**
249
-
250
- - `threshold` - Brightness level above which pixels will glow
251
- Default: `0.5` | Range: `0.0` - `1.0`
252
- - `intensity` - Strength of the glow effect
253
- Default: `1.0` | Range: `0.0` - `∞`
254
- - `radius` - Size of the glow spread in pixels
255
- Default: `4.0` | Range: `1.0` - `∞`
256
-
257
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
258
-
259
- ---
260
-
261
- ### `filmGrain`
262
-
263
- Adds an animated film grain/noise texture overlay to simulate vintage film stock or analog video. The multi-layered noise creates an organic, moving grain pattern that's less visible in darker areas, mimicking real film characteristics.
264
-
265
- **Parameters:**
266
-
267
- - `intensity` - Strength of the grain effect
268
- Default: `0.2` | Range: `0.0` - `1.0`
269
- - `size` - Size of grain particles
270
- Default: `2.0` | Range: `1.0` - `10.0`
271
- - `speed` - Animation speed of the grain
272
- Default: `1.0` | Range: `0.0` - `∞`
273
- - `time` - Animation time parameter
274
- Default: `0.0`
275
-
276
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
277
-
278
- ---
279
-
280
- ### `saturation`
281
-
282
- Adjust color intensity without affecting luminance. Perfect for creating vivid, oversaturated looks or desaturating to grayscale.
283
-
284
- **Parameters:**
285
-
286
- - `amount` - Saturation multiplier
287
- Default: `1.0` | Range: `0.0` (grayscale) - `∞` (vivid)
288
-
289
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
290
-
291
- ---
292
-
293
- ### `posterize`
294
-
295
- Reduces the color palette to a limited number of bands, creating a retro quantized look.
296
-
297
- **Parameters:**
298
-
299
- - `levels` - Number of color levels per channel
300
- Default: `4.0` | Range: `1.0` - `∞`
301
-
302
- **Author:** [@humanbydefinition](https://github.com/humanbydefinition)
303
-
304
- ---
305
-
306
- ### Usage examples
307
-
308
- ```javascript
309
- // Using a single value (shorthand)
310
- t.layers.base.filter('brightness', 1.5);
311
- t.layers.base.filter('hueRotate', 180);
312
-
313
- // Using an options object
314
- t.layers.base.filter('contrast', { amount: 0.8 });
315
- t.layers.base.filter('glitch', { amount: 2.0 });
316
-
317
- // Chaining multiple filters in sequence
318
- t.layers.base.filter('brightness', 1.2);
319
- t.layers.base.filter('contrast', 1.3);
320
- t.layers.base.filter('hueRotate', 90);
321
-
322
- // Chromatic aberration with custom direction
323
- t.layers.base.filter('chromaticAberration', { amount: 10, direction: [1, 1] });
324
-
325
- // Pixelate effect
326
- t.layers.base.filter('pixelate', 8);
327
-
328
- // Vignette with custom shape
329
- t.layers.base.filter('vignette', { amount: 0.7, softness: 0.4, roundness: 1.0 });
330
-
331
- // Bloom for glowing bright areas
332
- t.layers.base.filter('bloom', { threshold: 0.6, intensity: 1.5, radius: 8 });
333
-
334
- // Film grain with animation
335
- let time = 0;
336
- t.draw(() => {
337
- t.layers.base.filter('filmGrain', { intensity: 0.3, size: 2, speed: 1.0, time: time });
338
- time += 0.016;
339
- });
340
-
341
- // Saturation adjustments
342
- t.layers.base.filter('saturation', 0); // Grayscale
343
- t.layers.base.filter('saturation', 1.5); // Vivid colors
344
-
345
- // Posterize effect (quantize colors)
346
- t.layers.base.filter('posterize', { levels: 4 });
347
- ```
348
-
349
- ## Adding custom filters
350
-
351
- Want to create your own filter? Check out the [Contributing Guide](CONTRIBUTING.md) for detailed instructions on how to add new filters to this library!
352
-
353
- The basic structure of a filter shader:
354
-
355
- ```glsl
356
- #version 300 es
357
- precision highp float;
358
-
359
- uniform sampler2D u_texture; // Input texture
360
- uniform vec2 u_resolution; // Canvas resolution
361
- uniform float u_yourParam; // Your custom parameter
362
-
363
- in vec2 v_uv;
364
- out vec4 fragColor;
38
+ ## Installation
365
39
 
366
- void main() {
367
- vec4 color = texture(u_texture, v_uv);
40
+ Follow the [official installation guide](https://code.textmode.art/docs/installation) to install
41
+ `textmode.filters.js` alongside `textmode.js` with npm or browser-ready UMD bundles.
368
42
 
369
- // Your filter logic here
370
- vec3 result = color.rgb; // Modify this!
43
+ ## Next steps
371
44
 
372
- fragColor = vec4(result, color.a);
373
- }
374
- ```
45
+ - **[Read the filters documentation](https://code.textmode.art/docs/filters)** for filter scopes, parameters, and workflows.
46
+ - **[Browse the API reference](https://code.textmode.art/api/textmode.filters.js/)** for the complete typed API.
47
+ - **[Explore the examples](./examples/)** to see built-in filters and shader patterns in action.
48
+ - **[Try the live editor](https://editor.textmode.art/)** to tune filters interactively in the browser.
375
49
 
376
50
  ## Contributing
377
51
 
378
- Contributions are welcome and greatly appreciated! 🎉
379
-
380
- Whether you want to:
381
-
382
- - 🐛 Report a bug
383
- - 💡 Suggest a new filter
384
- - 🔧 Submit a pull request
385
- - 📖 Improve documentation
386
-
387
- Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
388
-
389
- ## Related projects
390
-
391
- - **[textmode.js](https://github.com/humanbydefinition/textmode.js)** - The main textmode.js library
392
- - **[code.textmode.art](https://code.textmode.art/)** - Documentation & examples
393
- - **[editor.textmode.art](https://editor.textmode.art/)** - textmode.js web editor
52
+ Thank you for considering contributing to this project! (✿◠‿◠)
53
+
54
+ Please read the [Contributing Guide](./CONTRIBUTING.md) to get started.
55
+
56
+ <!-- TEXTMODE-CONTRIBUTORS:START -->
57
+ <!-- prettier-ignore-start -->
58
+ <!-- Generated from https://github.com/humanbydefinition/code.textmode.art/blob/main/.vitepress/data/contributors.json and https://github.com/humanbydefinition/code.textmode.art/blob/main/.vitepress/data/contribution-types.json. Do not edit this section directly. -->
59
+ ## Contributors
60
+
61
+ Thanks to the people who contribute code, documentation, design, examples, ideas, infrastructure, and care
62
+ across the textmode.js ecosystem.
63
+
64
+ <!-- markdownlint-disable MD033 -->
65
+ <table>
66
+ <tbody>
67
+ <tr>
68
+ <td align="center" valign="top" width="14.28%">
69
+ <a href="https://github.com/humanbydefinition">
70
+ <img src="https://github.com/humanbydefinition.png?s=100" width="100px" alt="humanbydefinition avatar" />
71
+ <br /><sub><b>humanbydefinition</b></sub>
72
+ </a>
73
+ <br /><span title="Code: Commits and pull requests" aria-label="Code: Commits and pull requests">💻</span> <span title="Documentation: README, guides, and API documentation" aria-label="Documentation: README, guides, and API documentation">📖</span> <span title="Design: User experience, branding, and visual design" aria-label="Design: User experience, branding, and visual design">🎨</span> <span title="Examples: Usage examples and creative sketches" aria-label="Examples: Usage examples and creative sketches">💡</span> <span title="Ideas and planning: Feature proposals, planning, and feedback" aria-label="Ideas and planning: Feature proposals, planning, and feedback">🤔</span> <span title="Maintenance: Refactoring and project upkeep" aria-label="Maintenance: Refactoring and project upkeep">🚧</span> <span title="Infrastructure: Continuous integration, hosting, and build systems" aria-label="Infrastructure: Continuous integration, hosting, and build systems">🚇</span> <span title="Tools: Developer and community tooling" aria-label="Tools: Developer and community tooling">🔧</span> <span title="Plugins and libraries: Plugin and utility library development" aria-label="Plugins and libraries: Plugin and utility library development">🔌</span> <span title="Code review: Reviewing pull requests" aria-label="Code review: Reviewing pull requests">👀</span>
74
+ </td>
75
+ <td align="center" valign="top" width="14.28%">
76
+ <a href="https://github.com/trintlermint">
77
+ <img src="https://github.com/trintlermint.png?s=100" width="100px" alt="trintlermint avatar" />
78
+ <br /><sub><b>trintlermint</b></sub>
79
+ </a>
80
+ <br /><span title="Design: User experience, branding, and visual design" aria-label="Design: User experience, branding, and visual design">🎨</span> <span title="Examples: Usage examples and creative sketches" aria-label="Examples: Usage examples and creative sketches">💡</span>
81
+ </td>
82
+ </tr>
83
+ </tbody>
84
+ </table>
85
+ <!-- markdownlint-enable MD033 -->
86
+
87
+ Contribution details and profile links are maintained on the [textmode.js contributors page](https://code.textmode.art/docs/contributors).
88
+ <!-- prettier-ignore-end -->
89
+ <!-- TEXTMODE-CONTRIBUTORS:END -->
90
+
91
+ ## License
92
+
93
+ `textmode.filters.js` is licensed under the [MIT License](./LICENSE).
394
94
 
395
95
  ---
396
96
 
@@ -1,24 +1 @@
1
- const t = Array(128).fill(0.5), r = { name: "textmode.filters", version: "1.1.1", async install(e) {
2
- e.filters.register("brightness", `#version 300 es
3
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*u_amount;fragColor=vec4(B,A.a);}`, { u_amount: ["amount", 1] }), e.filters.register("contrast", `#version 300 es
4
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*u_amount+0.5;fragColor=vec4(B,A.a);}`, { u_amount: ["amount", 1] }), e.filters.register("hueRotate", `#version 300 es
5
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_angle;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+u_angle/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}`, { u_angle: ["angle", 0] }), e.filters.register("glitch", `#version 300 es
6
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=u_amount*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(u_amount*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*u_amount;O-=P;float Q=A(C+fract(u_amount))*0.1*u_amount;O+=Q;fragColor=vec4(O,N);}`, { u_amount: ["amount", 0] }), e.filters.register("chromaticAberration", `#version 300 es
7
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;uniform vec2 u_direction;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=u_direction*u_amount*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}`, { u_amount: ["amount", 5], u_direction: ["direction", [1, 0]] }), e.filters.register("pixelate", `#version 300 es
8
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_pixelSize;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(u_pixelSize)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}`, { u_pixelSize: ["pixelSize", 4] }), e.filters.register("gridDistortion", `#version 300 es
9
- precision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetDimensions;uniform float u_widthFactors[128];uniform float u_heightFactors[128];uniform float u_widthVariationScale;uniform float u_heightVariationScale;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-u_gridOffsetDimensions)/u_gridPixelDimensions;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(u_gridCellDimensions.x);int F=int(u_gridCellDimensions.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=u_widthFactors[H];G+=0.1+I*u_widthVariationScale;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=u_heightFactors[K];J+=0.1+L*u_heightVariationScale;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=u_widthFactors[H];float R=0.1+I*u_widthVariationScale;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=u_heightFactors[K];float W=0.1+L*u_heightVariationScale;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}`, { u_gridCellDimensions: ["gridCellDimensions", [80, 40]], u_gridPixelDimensions: ["gridPixelDimensions", [640, 320]], u_gridOffsetDimensions: ["gridOffsetDimensions", [0, 0]], u_widthFactors: ["widthFactors", t], u_heightFactors: ["heightFactors", t], u_widthVariationScale: ["widthVariationScale", 0.5], u_heightVariationScale: ["heightVariationScale", 0.5] }), e.filters.register("crtMattias", `#version 300 es
10
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_time;uniform float u_curvature;uniform float u_scanSpeed;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),u_curvature);vec3 T;float U=sin(0.1*u_time+Q.y*21.)*sin(0.23*u_time+Q.y*29.)*sin(0.3+0.11*u_time+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(u_time*u_scanSpeed)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*u_time);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*u_time),I(Q+0.0001*u_time+0.3),I(Q+0.0001*u_time+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}`, { u_curvature: ["curvature", 0.5], u_scanSpeed: ["scanSpeed", 1], u_time: ["time", 0] }), e.filters.register("scanlines", `#version 300 es
11
- precision highp float;uniform sampler2D u_texture;uniform float u_time;uniform float u_count;uniform float u_intensity;uniform float u_speed;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*u_count-u_time*u_speed)*3.141592*2.);B=B*0.5+0.5;float C=1.-(u_intensity*(1.-B));fragColor=vec4(A.rgb*C,A.a);}`, { u_count: ["count", 300], u_lineWidth: ["lineWidth", 0.5], u_intensity: ["intensity", 0.75], u_speed: ["speed", 1], u_time: ["time", 0] }), e.filters.register("vignette", `#version 300 es
12
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;uniform float u_softness;uniform float u_roundness;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,u_roundness);float G=mix(max(C,1.),length(vec2(C,1.)),u_roundness);F/=G;float H=1.-u_amount;float I=H+u_softness*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}`, { u_amount: ["amount", 0.5], u_softness: ["softness", 0.5], u_roundness: ["roundness", 0.5] }), e.filters.register("bloom", `#version 300 es
13
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_threshold;uniform float u_intensity;uniform float u_radius;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*u_radius*H.x,0.);vec2 O=vec2(0.,float(L)*u_radius*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,u_threshold)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,u_threshold)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*u_radius;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,u_threshold)*Z;I+=C(W,u_threshold)*Z;I+=C(X,u_threshold)*Z;I+=C(Y,u_threshold)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*u_intensity;fragColor=vec4(a,G.a);}`, { u_threshold: ["threshold", 0.5], u_intensity: ["intensity", 1], u_radius: ["radius", 4] }), e.filters.register("filmGrain", `#version 300 es
14
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_intensity;uniform float u_size;uniform float u_speed;uniform float u_time;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/u_size;M+=vec2(u_time*u_speed*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*u_intensity;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}`, { u_intensity: ["intensity", 0.2], u_size: ["size", 2], u_speed: ["speed", 1], u_time: ["time", 0] }), e.filters.register("saturation", `#version 300 es
15
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*u_amount,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}`, { u_amount: ["amount", 1] }), e.filters.register("posterize", `#version 300 es
16
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_levels;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*u_levels)/u_levels;fragColor=vec4(B,A.a);}`, { u_levels: ["levels", 4] });
17
- }, async uninstall(e) {
18
- e.filters.unregister("brightness"), e.filters.unregister("contrast"), e.filters.unregister("hueRotate"), e.filters.unregister("glitch"), e.filters.unregister("chromaticAberration"), e.filters.unregister("pixelate"), e.filters.unregister("gridDistortion"), e.filters.unregister("crtMattias"), e.filters.unregister("scanlines"), e.filters.unregister("vignette"), e.filters.unregister("bloom"), e.filters.unregister("filmGrain"), e.filters.unregister("saturation"), e.filters.unregister("posterize");
19
- } }, o = () => r;
20
- typeof window < "u" && (window.FiltersPlugin = r, window.createFiltersPlugin = o);
21
- export {
22
- r as FiltersPlugin,
23
- o as createFiltersPlugin
24
- };
1
+ var e=new Array(128).fill(.5),o={name:"textmode.filters",version:"1.1.1",async install(o){o.filters.register("brightness","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*U0;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),o.filters.register("contrast","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*U0+0.5;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),o.filters.register("hueRotate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U1;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+U1/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U1:["angle",0]}),o.filters.register("glitch","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=U0*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(U0*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*U0;O-=P;float Q=A(C+fract(U0))*0.1*U0;O+=Q;fragColor=vec4(O,N);}",{U0:["amount",0]}),o.filters.register("chromaticAberration","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform vec2 U4;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=U4*U0*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}",{U0:["amount",5],U4:["direction",[1,0]]}),o.filters.register("pixelate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uc)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}",{Uc:["pixelSize",4]}),o.filters.register("gridDistortion","#version 300 es\nprecision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 U5;uniform vec2 U7;uniform vec2 U6;uniform float Ul[128];uniform float U8[128];uniform float Um;uniform float U9;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-U6)/U7;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(U5.x);int F=int(U5.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];G+=0.1+I*Um;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=U8[K];J+=0.1+L*U9;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];float R=0.1+I*Um;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=U8[K];float W=0.1+L*U9;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}",{U5:["gridCellDimensions",[80,40]],U7:["gridPixelDimensions",[640,320]],U6:["gridOffsetDimensions",[0,0]],Ul:["widthFactors",e],U8:["heightFactors",e],Um:["widthVariationScale",.5],U9:["heightVariationScale",.5]}),o.filters.register("crtMattias","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uk;uniform float U3;uniform float Uf;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),U3);vec3 T;float U=sin(0.1*Uk+Q.y*21.)*sin(0.23*Uk+Q.y*29.)*sin(0.3+0.11*Uk+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(Uk*Uf)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*Uk);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*Uk),I(Q+0.0001*Uk+0.3),I(Q+0.0001*Uk+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}",{U3:["curvature",.5],Uf:["scanSpeed",1],Uk:["time",0]}),o.filters.register("scanlines","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uk;uniform float U2;uniform float Ua;uniform float Ui;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*U2-Uk*Ui)*3.141592*2.);B=B*0.5+0.5;float C=1.-(Ua*(1.-B));fragColor=vec4(A.rgb*C,A.a);}",{U2:["count",300],u_lineWidth:["lineWidth",.5],Ua:["intensity",.75],Ui:["speed",1],Uk:["time",0]}),o.filters.register("vignette","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform float Uh;uniform float Ue;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,Ue);float G=mix(max(C,1.),length(vec2(C,1.)),Ue);F/=G;float H=1.-U0;float I=H+Uh*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}",{U0:["amount",.5],Uh:["softness",.5],Ue:["roundness",.5]}),o.filters.register("bloom","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uj;uniform float Ua;uniform float Ud;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*Ud*H.x,0.);vec2 O=vec2(0.,float(L)*Ud*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,Uj)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,Uj)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*Ud;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,Uj)*Z;I+=C(W,Uj)*Z;I+=C(X,Uj)*Z;I+=C(Y,Uj)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*Ua;fragColor=vec4(a,G.a);}",{Uj:["threshold",.5],Ua:["intensity",1],Ud:["radius",4]}),o.filters.register("filmGrain","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ua;uniform float Ug;uniform float Ui;uniform float Uk;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/Ug;M+=vec2(Uk*Ui*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*Ua;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}",{Ua:["intensity",.2],Ug:["size",2],Ui:["speed",1],Uk:["time",0]}),o.filters.register("saturation","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*U0,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U0:["amount",1]}),o.filters.register("posterize","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*Ub)/Ub;fragColor=vec4(B,A.a);}",{Ub:["levels",4]})},async uninstall(e){e.filters.unregister("brightness"),e.filters.unregister("contrast"),e.filters.unregister("hueRotate"),e.filters.unregister("glitch"),e.filters.unregister("chromaticAberration"),e.filters.unregister("pixelate"),e.filters.unregister("gridDistortion"),e.filters.unregister("crtMattias"),e.filters.unregister("scanlines"),e.filters.unregister("vignette"),e.filters.unregister("bloom"),e.filters.unregister("filmGrain"),e.filters.unregister("saturation"),e.filters.unregister("posterize")}};"undefined"!=typeof window&&(window.FiltersPlugin=o);export{o as FiltersPlugin};
@@ -1,15 +1 @@
1
- var e,o;e=this,o=function(r){const u=Array(128).fill(.5),i={name:"textmode.filters",version:"1.1.1",async install(t){t.filters.register("brightness",`#version 300 es
2
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*u_amount;fragColor=vec4(B,A.a);}`,{u_amount:["amount",1]}),t.filters.register("contrast",`#version 300 es
3
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*u_amount+0.5;fragColor=vec4(B,A.a);}`,{u_amount:["amount",1]}),t.filters.register("hueRotate",`#version 300 es
4
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_angle;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+u_angle/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}`,{u_angle:["angle",0]}),t.filters.register("glitch",`#version 300 es
5
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=u_amount*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(u_amount*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*u_amount;O-=P;float Q=A(C+fract(u_amount))*0.1*u_amount;O+=Q;fragColor=vec4(O,N);}`,{u_amount:["amount",0]}),t.filters.register("chromaticAberration",`#version 300 es
6
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;uniform vec2 u_direction;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=u_direction*u_amount*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}`,{u_amount:["amount",5],u_direction:["direction",[1,0]]}),t.filters.register("pixelate",`#version 300 es
7
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_pixelSize;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(u_pixelSize)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}`,{u_pixelSize:["pixelSize",4]}),t.filters.register("gridDistortion",`#version 300 es
8
- precision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetDimensions;uniform float u_widthFactors[128];uniform float u_heightFactors[128];uniform float u_widthVariationScale;uniform float u_heightVariationScale;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-u_gridOffsetDimensions)/u_gridPixelDimensions;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(u_gridCellDimensions.x);int F=int(u_gridCellDimensions.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=u_widthFactors[H];G+=0.1+I*u_widthVariationScale;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=u_heightFactors[K];J+=0.1+L*u_heightVariationScale;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=u_widthFactors[H];float R=0.1+I*u_widthVariationScale;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=u_heightFactors[K];float W=0.1+L*u_heightVariationScale;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}`,{u_gridCellDimensions:["gridCellDimensions",[80,40]],u_gridPixelDimensions:["gridPixelDimensions",[640,320]],u_gridOffsetDimensions:["gridOffsetDimensions",[0,0]],u_widthFactors:["widthFactors",u],u_heightFactors:["heightFactors",u],u_widthVariationScale:["widthVariationScale",.5],u_heightVariationScale:["heightVariationScale",.5]}),t.filters.register("crtMattias",`#version 300 es
9
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_time;uniform float u_curvature;uniform float u_scanSpeed;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),u_curvature);vec3 T;float U=sin(0.1*u_time+Q.y*21.)*sin(0.23*u_time+Q.y*29.)*sin(0.3+0.11*u_time+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(u_time*u_scanSpeed)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*u_time);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*u_time),I(Q+0.0001*u_time+0.3),I(Q+0.0001*u_time+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}`,{u_curvature:["curvature",.5],u_scanSpeed:["scanSpeed",1],u_time:["time",0]}),t.filters.register("scanlines",`#version 300 es
10
- precision highp float;uniform sampler2D u_texture;uniform float u_time;uniform float u_count;uniform float u_intensity;uniform float u_speed;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*u_count-u_time*u_speed)*3.141592*2.);B=B*0.5+0.5;float C=1.-(u_intensity*(1.-B));fragColor=vec4(A.rgb*C,A.a);}`,{u_count:["count",300],u_lineWidth:["lineWidth",.5],u_intensity:["intensity",.75],u_speed:["speed",1],u_time:["time",0]}),t.filters.register("vignette",`#version 300 es
11
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;uniform float u_softness;uniform float u_roundness;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,u_roundness);float G=mix(max(C,1.),length(vec2(C,1.)),u_roundness);F/=G;float H=1.-u_amount;float I=H+u_softness*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}`,{u_amount:["amount",.5],u_softness:["softness",.5],u_roundness:["roundness",.5]}),t.filters.register("bloom",`#version 300 es
12
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_threshold;uniform float u_intensity;uniform float u_radius;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*u_radius*H.x,0.);vec2 O=vec2(0.,float(L)*u_radius*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,u_threshold)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,u_threshold)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*u_radius;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,u_threshold)*Z;I+=C(W,u_threshold)*Z;I+=C(X,u_threshold)*Z;I+=C(Y,u_threshold)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*u_intensity;fragColor=vec4(a,G.a);}`,{u_threshold:["threshold",.5],u_intensity:["intensity",1],u_radius:["radius",4]}),t.filters.register("filmGrain",`#version 300 es
13
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_intensity;uniform float u_size;uniform float u_speed;uniform float u_time;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/u_size;M+=vec2(u_time*u_speed*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*u_intensity;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}`,{u_intensity:["intensity",.2],u_size:["size",2],u_speed:["speed",1],u_time:["time",0]}),t.filters.register("saturation",`#version 300 es
14
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_amount;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*u_amount,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}`,{u_amount:["amount",1]}),t.filters.register("posterize",`#version 300 es
15
- precision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float u_levels;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*u_levels)/u_levels;fragColor=vec4(B,A.a);}`,{u_levels:["levels",4]})},async uninstall(t){t.filters.unregister("brightness"),t.filters.unregister("contrast"),t.filters.unregister("hueRotate"),t.filters.unregister("glitch"),t.filters.unregister("chromaticAberration"),t.filters.unregister("pixelate"),t.filters.unregister("gridDistortion"),t.filters.unregister("crtMattias"),t.filters.unregister("scanlines"),t.filters.unregister("vignette"),t.filters.unregister("bloom"),t.filters.unregister("filmGrain"),t.filters.unregister("saturation"),t.filters.unregister("posterize")}},n=()=>i;typeof window<"u"&&(window.FiltersPlugin=i,window.createFiltersPlugin=n),r.FiltersPlugin=i,r.createFiltersPlugin=n,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})},typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):o((e=typeof globalThis<"u"?globalThis:e||self).textmodeFilters={});
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).textmodeFilters={})}(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var o=new Array(128).fill(.5),t={name:"textmode.filters",version:"1.1.1",async install(e){e.filters.register("brightness","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=A.rgb*U0;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),e.filters.register("contrast","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=(A.rgb-0.5)*U0+0.5;fragColor=vec4(B,A.a);}",{U0:["amount",1]}),e.filters.register("hueRotate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U1;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.x=fract(J.x+U1/360.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U1:["angle",0]}),e.filters.register("glitch","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 C=v_uv;float D=U0*0.1;float E=floor(C.y*20.);float F=A(vec2(E,floor(U0*100.)));if(F>0.7){C.x+=(F-0.7)*D*2.;}float G=D*0.02;vec2 H=C+vec2(G,0.);vec2 I=C;vec2 J=C-vec2(G,0.);float K=texture(u_texture,H).r;float L=texture(u_texture,I).g;float M=texture(u_texture,J).b;float N=texture(u_texture,C).a;vec3 O=vec3(K,L,M);float P=sin(C.y*u_resolution.y*2.)*0.1*U0;O-=P;float Q=A(C+fract(U0))*0.1*U0;O+=Q;fragColor=vec4(O,N);}",{U0:["amount",0]}),e.filters.register("chromaticAberration","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform vec2 U4;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=1./u_resolution;vec2 B=U4*U0*A;float C=texture(u_texture,v_uv+B).r;vec4 D=texture(u_texture,v_uv);float E=D.g;float F=texture(u_texture,v_uv-B).b;float G=D.a;fragColor=vec4(C,E,F,G);}",{U0:["amount",5],U4:["direction",[1,0]]}),e.filters.register("pixelate","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uc;in vec2 v_uv;out vec4 fragColor;void main(){vec2 A=vec2(Uc)/u_resolution;vec2 B=floor(v_uv/A)*A+A*0.5;fragColor=texture(u_texture,B);}",{Uc:["pixelSize",4]}),e.filters.register("gridDistortion","#version 300 es\nprecision mediump float;in vec2 v_uv;out vec4 fragColor;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform vec2 U5;uniform vec2 U7;uniform vec2 U6;uniform float Ul[128];uniform float U8[128];uniform float Um;uniform float U9;const int A=128;const int B=128;void main(){vec2 C=v_uv*u_resolution;vec2 D=(C-U6)/U7;if(D.x<0.||D.x>1.||D.y<0.||D.y>1.){fragColor=vec4(0.);return;}int E=int(U5.x);int F=int(U5.y);float G=0.;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];G+=0.1+I*Um;}}float J=0.;for(int K=0;K<B;K++){if(K<F){float L=U8[K];J+=0.1+L*U9;}}float M=D.x;float N=D.y;float O=0.;float P=0.;float Q=M*G;for(int H=0;H<A;H++){if(H<E){float I=Ul[H];float R=0.1+I*Um;if(Q<P+R){float S=(Q-P)/R;O=(float(H)+S)/float(E);break;}P+=R;}}float T=0.;float U=0.;float V=N*J;for(int K=0;K<B;K++){if(K<F){float L=U8[K];float W=0.1+L*U9;if(V<U+W){float S=(V-U)/W;T=(float(K)+S)/float(F);break;}U+=W;}}vec2 X=vec2(O,T);fragColor=texture(u_texture,X);}",{U5:["gridCellDimensions",[80,40]],U7:["gridPixelDimensions",[640,320]],U6:["gridOffsetDimensions",[0,0]],Ul:["widthFactors",o],U8:["heightFactors",o],Um:["widthVariationScale",.5],U9:["heightVariationScale",.5]}),e.filters.register("crtMattias","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uk;uniform float U3;uniform float Uf;in vec2 v_uv;out vec4 fragColor;vec3 A(vec2 B){vec3 C=pow(texture(u_texture,B).rgb,vec3(2.2));return C;}vec3 D(vec2 B,float E){vec4 F=E*vec4(-2.,-1.,1.,2.)/u_resolution.x;vec4 G=E*vec4(-2.,-1.,1.,2.)/u_resolution.y;vec3 H=vec3(0.);H+=A(B+vec2(F.x,G.x))*0.00366;H+=A(B+vec2(F.y,G.x))*0.01465;H+=A(B+vec2(0.,G.x))*0.02564;H+=A(B+vec2(F.z,G.x))*0.01465;H+=A(B+vec2(F.w,G.x))*0.00366;H+=A(B+vec2(F.x,G.y))*0.01465;H+=A(B+vec2(F.y,G.y))*0.05861;H+=A(B+vec2(0.,G.y))*0.09524;H+=A(B+vec2(F.z,G.y))*0.05861;H+=A(B+vec2(F.w,G.y))*0.01465;H+=A(B+vec2(F.x,0.))*0.02564;H+=A(B+vec2(F.y,0.))*0.09524;H+=A(B+vec2(0.,0.))*0.15018;H+=A(B+vec2(F.z,0.))*0.09524;H+=A(B+vec2(F.w,0.))*0.02564;H+=A(B+vec2(F.x,G.z))*0.01465;H+=A(B+vec2(F.y,G.z))*0.05861;H+=A(B+vec2(0.,G.z))*0.09524;H+=A(B+vec2(F.z,G.z))*0.05861;H+=A(B+vec2(F.w,G.z))*0.01465;H+=A(B+vec2(F.x,G.w))*0.00366;H+=A(B+vec2(F.y,G.w))*0.01465;H+=A(B+vec2(0.,G.w))*0.02564;H+=A(B+vec2(F.z,G.w))*0.01465;H+=A(B+vec2(F.w,G.w))*0.00366;return H;}float I(vec2 J){float K=12.9898;float L=78.233;float M=43758.5453;float N=dot(J.xy,vec2(K,L));float O=mod(N,3.14);return fract(sin(O)*M);}vec2 P(vec2 Q){Q=(Q-0.5)*2.;Q*=1.1;Q.x*=1.+pow((abs(Q.y)/5.),2.);Q.y*=1.+pow((abs(Q.x)/4.),2.);Q=(Q/2.)+0.5;Q=Q*0.92+0.04;return Q;}void main(){vec2 R=gl_FragCoord.xy;vec2 S=v_uv;vec2 Q=S;Q=mix(Q,P(Q),U3);vec3 T;float U=sin(0.1*Uk+Q.y*21.)*sin(0.23*Uk+Q.y*29.)*sin(0.3+0.11*Uk+Q.y*31.)*0.0017;float V=2.*mod(R.y,2.)/u_resolution.x;U+=V;T.r=1.*D(vec2(Q.x+0.0009,Q.y+0.0009),1.2).x+0.005;T.g=1.*D(vec2(Q.x+0.000,Q.y-0.0015),1.2).y+0.005;T.b=1.*D(vec2(Q.x-0.0015,Q.y+0.000),1.2).z+0.005;T.r+=0.2*D(vec2(Q.x+0.0009,Q.y+0.0009),2.25).x-0.005;T.g+=0.2*D(vec2(Q.x+0.000,Q.y-0.0015),1.75).y-0.005;T.b+=0.2*D(vec2(Q.x-0.0015,Q.y+0.000),1.25).z-0.005;float W=0.05;T.r+=W*(1.-0.299)*D(0.75*vec2(0.01,-0.027)+vec2(Q.x+0.001,Q.y+0.001),7.).x;T.g+=W*(1.-0.587)*D(0.75*vec2(-0.022,-0.02)+vec2(Q.x+0.000,Q.y-0.002),5.).y;T.b+=W*(1.-0.114)*D(0.75*vec2(-0.02,-0.)+vec2(Q.x-0.002,Q.y+0.000),3.).z;T=clamp(T*0.4+0.6*T*T*1.,0.,1.);float X=(0.+1.*16.*Q.x*Q.y*(1.-Q.x)*(1.-Q.y));X=pow(X,0.3);T*=vec3(X);T*=vec3(0.95,1.05,0.95);T=mix(T,T*T,0.3)*3.8;float Y=clamp(0.35+0.15*sin(3.5*(Uk*Uf)+Q.y*u_resolution.y*1.5),0.,1.);float C=pow(Y,0.9);T=T*vec3(C);T*=1.+0.0015*sin(300.*Uk);T*=1.-0.15*vec3(clamp((mod(R.x+V,2.)-1.)*2.,0.,1.));T*=vec3(1.)-0.25*vec3(I(Q+0.0001*Uk),I(Q+0.0001*Uk+0.3),I(Q+0.0001*Uk+0.5));T=pow(T,vec3(0.45));if(Q.x<0.||Q.x>1.)T*=0.;if(Q.y<0.||Q.y>1.)T*=0.;fragColor=vec4(T,1.);}",{U3:["curvature",.5],Uf:["scanSpeed",1],Uk:["time",0]}),e.filters.register("scanlines","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform float Uk;uniform float U2;uniform float Ua;uniform float Ui;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);float B=sin((v_uv.y*U2-Uk*Ui)*3.141592*2.);B=B*0.5+0.5;float C=1.-(Ua*(1.-B));fragColor=vec4(A.rgb*C,A.a);}",{U2:["count",300],u_lineWidth:["lineWidth",.5],Ua:["intensity",.75],Ui:["speed",1],Uk:["time",0]}),e.filters.register("vignette","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;uniform float Uh;uniform float Ue;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec2 B=v_uv*2.-1.;float C=u_resolution.x/u_resolution.y;B.x*=C;float D=max(abs(B.x),abs(B.y));float E=length(B);float F=mix(D,E,Ue);float G=mix(max(C,1.),length(vec2(C,1.)),Ue);F/=G;float H=1.-U0;float I=H+Uh*0.5+0.01;float J=1.-smoothstep(H,I,F);vec3 K=A.rgb*J;fragColor=vec4(K,A.a);}",{U0:["amount",.5],Uh:["softness",.5],Ue:["roundness",.5]}),e.filters.register("bloom","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Uj;uniform float Ua;uniform float Ud;in vec2 v_uv;out vec4 fragColor;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}vec3 C(vec3 B,float D){float E=A(B);float F=max(0.,E-D)/max(E,0.001);return B*F;}void main(){vec4 G=texture(u_texture,v_uv);vec2 H=1./u_resolution;vec3 I=vec3(0.);float J=0.;float K[7];K[0]=0.227027;K[1]=0.194594;K[2]=0.121621;K[3]=0.054054;K[4]=0.016216;K[5]=0.006216;K[6]=0.002216;for(int L=-6;L<=6;L++){float M=K[abs(L)];vec2 N=vec2(float(L)*Ud*H.x,0.);vec2 O=vec2(0.,float(L)*Ud*H.y);vec3 P=texture(u_texture,v_uv+N).rgb;I+=C(P,Uj)*M;if(L!=0){vec3 Q=texture(u_texture,v_uv+O).rgb;I+=C(Q,Uj)*M;J+=M;}J+=M;}float R=0.1;for(int L=1;L<=4;L++){float S=float(L)*Ud;vec2 T=vec2(S,S)*H;vec2 U=vec2(S,-S)*H;vec3 V=texture(u_texture,v_uv+T).rgb;vec3 W=texture(u_texture,v_uv-T).rgb;vec3 X=texture(u_texture,v_uv+U).rgb;vec3 Y=texture(u_texture,v_uv-U).rgb;float Z=R/float(L);I+=C(V,Uj)*Z;I+=C(W,Uj)*Z;I+=C(X,Uj)*Z;I+=C(Y,Uj)*Z;J+=Z*4.;}I/=J;vec3 a=G.rgb+I*Ua;fragColor=vec4(a,G.a);}",{Uj:["threshold",.5],Ua:["intensity",1],Ud:["radius",4]}),e.filters.register("filmGrain","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ua;uniform float Ug;uniform float Ui;uniform float Uk;in vec2 v_uv;out vec4 fragColor;float A(vec2 B){return fract(sin(dot(B,vec2(12.9898,78.233)))*43758.5453);}float C(vec2 D){vec2 E=floor(D);vec2 F=fract(D);vec2 G=F*F*(3.-2.*F);float H=A(E);float I=A(E+vec2(1.,0.));float J=A(E+vec2(0.,1.));float K=A(E+vec2(1.,1.));return mix(mix(H,I,G.x),mix(J,K,G.x),G.y);}void main(){vec4 L=texture(u_texture,v_uv);vec2 M=v_uv*u_resolution/Ug;M+=vec2(Uk*Ui*0.1);float N=C(M);float O=C(M*2.+vec2(100.));float P=C(M*4.+vec2(200.));float Q=N*0.6+O*0.3+P*0.1;Q=(Q-0.5)*Ua;float R=dot(L.rgb,vec3(0.299,0.587,0.114));float S=Q*(0.5+R*0.5);vec3 T=L.rgb+S;fragColor=vec4(T,L.a);}",{Ua:["intensity",.2],Ug:["size",2],Ui:["speed",1],Uk:["time",0]}),e.filters.register("saturation","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float U0;in vec2 v_uv;out vec4 fragColor;float A(float B,float C,float D){if(D<0.)D+=1.;if(D>1.)D-=1.;if(D<1./6.)return B+(C-B)*6.*D;if(D<1./2.)return C;if(D<2./3.)return B+(C-B)*(2./3.-D)*6.;return B;}vec3 E(vec3 F){float G=max(max(F.r,F.g),F.b);float H=min(min(F.r,F.g),F.b);float I=G-H;vec3 J=vec3(0.);J.z=(G+H)/2.;if(I==0.){J.x=0.;J.y=0.;}else{J.y=J.z<0.5?I/(G+H):I/(2.-G-H);if(F.r==G){J.x=(F.g-F.b)/I+(F.g<F.b?6.:0.);}else if(F.g==G){J.x=(F.b-F.r)/I+2.;}else{J.x=(F.r-F.g)/I+4.;}J.x/=6.;}return J;}vec3 K(vec3 J){float L=J.x;float M=J.y;float N=J.z;if(M==0.){return vec3(N);}float C=N<0.5?N*(1.+M):N+M-N*M;float B=2.*N-C;float O=A(B,C,L+1./3.);float P=A(B,C,L);float Q=A(B,C,L-1./3.);return vec3(O,P,Q);}void main(){vec4 F=texture(u_texture,v_uv);vec3 J=E(F.rgb);J.y=clamp(J.y*U0,0.,1.);vec3 R=K(J);fragColor=vec4(R,F.a);}",{U0:["amount",1]}),e.filters.register("posterize","#version 300 es\nprecision highp float;uniform sampler2D u_texture;uniform vec2 u_resolution;uniform float Ub;in vec2 v_uv;out vec4 fragColor;void main(){vec4 A=texture(u_texture,v_uv);vec3 B=floor(A.rgb*Ub)/Ub;fragColor=vec4(B,A.a);}",{Ub:["levels",4]})},async uninstall(e){e.filters.unregister("brightness"),e.filters.unregister("contrast"),e.filters.unregister("hueRotate"),e.filters.unregister("glitch"),e.filters.unregister("chromaticAberration"),e.filters.unregister("pixelate"),e.filters.unregister("gridDistortion"),e.filters.unregister("crtMattias"),e.filters.unregister("scanlines"),e.filters.unregister("vignette"),e.filters.unregister("bloom"),e.filters.unregister("filmGrain"),e.filters.unregister("saturation"),e.filters.unregister("posterize")}};"undefined"!=typeof window&&(window.FiltersPlugin=t),e.FiltersPlugin=t});