@arraypress/effects-astro 0.0.0-stage → 0.1.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/AGENTS.md +85 -0
- package/COMPONENTS.md +1264 -0
- package/LICENSE +139 -0
- package/README.md +197 -2
- package/package.json +60 -4
- package/src/components/AsciiRain.astro +36 -0
- package/src/components/BorderSweep.astro +39 -0
- package/src/components/Caustics.astro +39 -0
- package/src/components/ColorPanels.astro +62 -0
- package/src/components/Cursor.astro +97 -0
- package/src/components/DotGrid.astro +34 -0
- package/src/components/DotSurface.astro +35 -0
- package/src/components/EffectCanvas.astro +152 -0
- package/src/components/FitText.astro +35 -0
- package/src/components/FlutedGlass.astro +36 -0
- package/src/components/Glass.astro +69 -0
- package/src/components/GlassGlyph.astro +38 -0
- package/src/components/GlowField.astro +177 -0
- package/src/components/Grain.astro +98 -0
- package/src/components/HaloRing.astro +38 -0
- package/src/components/HighlightSweep.astro +74 -0
- package/src/components/ImageRipple.astro +56 -0
- package/src/components/Ink.astro +37 -0
- package/src/components/InkField.astro +45 -0
- package/src/components/IsoCity.astro +54 -0
- package/src/components/LightField.astro +40 -0
- package/src/components/LiquidMetal.astro +41 -0
- package/src/components/Magnetic.astro +52 -0
- package/src/components/Marquee.astro +216 -0
- package/src/components/MosaicReveal.astro +196 -0
- package/src/components/NebulaLogo.astro +38 -0
- package/src/components/NeonSwarm.astro +38 -0
- package/src/components/Ocean.astro +40 -0
- package/src/components/OutlineWordmark.astro +222 -0
- package/src/components/PaperBackground.astro +40 -0
- package/src/components/PaperShader.astro +55 -0
- package/src/components/Parallax.astro +49 -0
- package/src/components/ParticleLogo.astro +37 -0
- package/src/components/PixelGlitchText.astro +70 -0
- package/src/components/PointCloud.astro +37 -0
- package/src/components/ProductStack.astro +298 -0
- package/src/components/PulseMark.astro +189 -0
- package/src/components/RadiantGlass.astro +38 -0
- package/src/components/RainOnGlass.astro +71 -0
- package/src/components/Reveal.astro +115 -0
- package/src/components/ScrambleText.astro +52 -0
- package/src/components/ScrollReveal.astro +38 -0
- package/src/components/ShaderBackground.astro +55 -0
- package/src/components/SignalLines.astro +41 -0
- package/src/components/SilkRibbon.astro +37 -0
- package/src/components/SpotlightText.astro +131 -0
- package/src/components/Tilt.astro +79 -0
- package/src/components/Topography.astro +38 -0
- package/src/components/Typewriter.astro +66 -0
- package/src/components/VariableType.astro +59 -0
- package/src/components/VoxelLogo.astro +46 -0
- package/src/components/WaveBars.astro +41 -0
- package/src/components/WorldRoutes.astro +41 -0
- package/src/components/style.js +19 -0
- package/src/index.d.ts +143 -0
- package/src/index.js +105 -0
- package/src/runtime/ascii-rain.d.ts +53 -0
- package/src/runtime/ascii-rain.js +355 -0
- package/src/runtime/audio-meter.d.ts +65 -0
- package/src/runtime/audio-meter.js +282 -0
- package/src/runtime/audio.d.ts +26 -0
- package/src/runtime/audio.js +453 -0
- package/src/runtime/blur.d.ts +2 -0
- package/src/runtime/blur.js +56 -0
- package/src/runtime/canvas2d.d.ts +23 -0
- package/src/runtime/canvas2d.js +105 -0
- package/src/runtime/caustics.d.ts +40 -0
- package/src/runtime/caustics.js +286 -0
- package/src/runtime/color.d.ts +33 -0
- package/src/runtime/color.js +213 -0
- package/src/runtime/curl.d.ts +5 -0
- package/src/runtime/curl.js +81 -0
- package/src/runtime/cursor.d.ts +9 -0
- package/src/runtime/cursor.js +80 -0
- package/src/runtime/device.d.ts +14 -0
- package/src/runtime/device.js +73 -0
- package/src/runtime/dot-grid.d.ts +27 -0
- package/src/runtime/dot-grid.js +245 -0
- package/src/runtime/dot-surface.d.ts +46 -0
- package/src/runtime/dot-surface.js +429 -0
- package/src/runtime/feedback.d.ts +18 -0
- package/src/runtime/feedback.js +131 -0
- package/src/runtime/fit-text.d.ts +5 -0
- package/src/runtime/fit-text.js +60 -0
- package/src/runtime/fluid.d.ts +55 -0
- package/src/runtime/fluid.js +504 -0
- package/src/runtime/fluted-glass.d.ts +27 -0
- package/src/runtime/fluted-glass.js +157 -0
- package/src/runtime/gl.d.ts +19 -0
- package/src/runtime/gl.js +104 -0
- package/src/runtime/glass-glyph.d.ts +49 -0
- package/src/runtime/glass-glyph.js +355 -0
- package/src/runtime/glass-sheen.d.ts +2 -0
- package/src/runtime/glass-sheen.js +30 -0
- package/src/runtime/glsl.d.ts +17 -0
- package/src/runtime/glsl.js +78 -0
- package/src/runtime/glyphs.d.ts +22 -0
- package/src/runtime/glyphs.js +107 -0
- package/src/runtime/halo-ring.d.ts +47 -0
- package/src/runtime/halo-ring.js +334 -0
- package/src/runtime/height-field.d.ts +50 -0
- package/src/runtime/height-field.js +176 -0
- package/src/runtime/image-ripple.d.ts +25 -0
- package/src/runtime/image-ripple.js +353 -0
- package/src/runtime/image.d.ts +11 -0
- package/src/runtime/image.js +81 -0
- package/src/runtime/in-view.d.ts +6 -0
- package/src/runtime/in-view.js +36 -0
- package/src/runtime/ink-field/shaders.js +258 -0
- package/src/runtime/ink-field/sim.js +582 -0
- package/src/runtime/ink-field.d.ts +39 -0
- package/src/runtime/ink-field.js +311 -0
- package/src/runtime/ink.d.ts +31 -0
- package/src/runtime/ink.js +109 -0
- package/src/runtime/instancing.d.ts +12 -0
- package/src/runtime/instancing.js +37 -0
- package/src/runtime/iso-camera.d.ts +35 -0
- package/src/runtime/iso-camera.js +85 -0
- package/src/runtime/iso-city/figures.d.ts +30 -0
- package/src/runtime/iso-city/figures.js +136 -0
- package/src/runtime/iso-city/look.d.ts +34 -0
- package/src/runtime/iso-city/look.js +105 -0
- package/src/runtime/iso-city/plan.d.ts +59 -0
- package/src/runtime/iso-city/plan.js +463 -0
- package/src/runtime/iso-city/roads.d.ts +64 -0
- package/src/runtime/iso-city/roads.js +320 -0
- package/src/runtime/iso-city/scene.d.ts +27 -0
- package/src/runtime/iso-city/scene.js +432 -0
- package/src/runtime/iso-city/shaders.d.ts +6 -0
- package/src/runtime/iso-city/shaders.js +233 -0
- package/src/runtime/iso-city/shadows.d.ts +13 -0
- package/src/runtime/iso-city/shadows.js +148 -0
- package/src/runtime/iso-city/traffic.d.ts +80 -0
- package/src/runtime/iso-city/traffic.js +457 -0
- package/src/runtime/iso-city.d.ts +37 -0
- package/src/runtime/iso-city.js +458 -0
- package/src/runtime/lens-map.d.ts +11 -0
- package/src/runtime/lens-map.js +146 -0
- package/src/runtime/light-field.d.ts +29 -0
- package/src/runtime/light-field.js +292 -0
- package/src/runtime/liquid-glass.d.ts +48 -0
- package/src/runtime/liquid-glass.js +423 -0
- package/src/runtime/liquid-metal/beads.js +217 -0
- package/src/runtime/liquid-metal/field.js +88 -0
- package/src/runtime/liquid-metal/look.js +64 -0
- package/src/runtime/liquid-metal/shaders.js +255 -0
- package/src/runtime/liquid-metal/wave.js +53 -0
- package/src/runtime/liquid-metal.d.ts +46 -0
- package/src/runtime/liquid-metal.js +366 -0
- package/src/runtime/loop.d.ts +7 -0
- package/src/runtime/loop.js +112 -0
- package/src/runtime/magnetic.d.ts +9 -0
- package/src/runtime/magnetic.js +46 -0
- package/src/runtime/marquee.d.ts +2 -0
- package/src/runtime/marquee.js +27 -0
- package/src/runtime/mesh.d.ts +30 -0
- package/src/runtime/mesh.js +217 -0
- package/src/runtime/mosaic-reveal.d.ts +34 -0
- package/src/runtime/mosaic-reveal.js +504 -0
- package/src/runtime/motion.d.ts +2 -0
- package/src/runtime/motion.js +21 -0
- package/src/runtime/mount.d.ts +13 -0
- package/src/runtime/mount.js +120 -0
- package/src/runtime/nebula-logo.d.ts +31 -0
- package/src/runtime/nebula-logo.js +282 -0
- package/src/runtime/neon-swarm.d.ts +31 -0
- package/src/runtime/neon-swarm.js +258 -0
- package/src/runtime/ocean/presets.d.ts +54 -0
- package/src/runtime/ocean/presets.js +184 -0
- package/src/runtime/ocean/shader.d.ts +14 -0
- package/src/runtime/ocean/shader.js +389 -0
- package/src/runtime/ocean/view.d.ts +24 -0
- package/src/runtime/ocean/view.js +98 -0
- package/src/runtime/ocean/waves.d.ts +29 -0
- package/src/runtime/ocean/waves.js +119 -0
- package/src/runtime/ocean.d.ts +31 -0
- package/src/runtime/ocean.js +173 -0
- package/src/runtime/palettes.d.ts +37 -0
- package/src/runtime/palettes.js +75 -0
- package/src/runtime/paper-look.d.ts +42 -0
- package/src/runtime/paper-look.js +91 -0
- package/src/runtime/paper-looks.d.ts +17 -0
- package/src/runtime/paper-looks.js +21 -0
- package/src/runtime/paper.d.ts +37 -0
- package/src/runtime/paper.js +303 -0
- package/src/runtime/particle-logo.d.ts +31 -0
- package/src/runtime/particle-logo.js +196 -0
- package/src/runtime/ping-pong.d.ts +43 -0
- package/src/runtime/ping-pong.js +175 -0
- package/src/runtime/pixel-glitch.d.ts +17 -0
- package/src/runtime/pixel-glitch.js +287 -0
- package/src/runtime/point-cloud.d.ts +33 -0
- package/src/runtime/point-cloud.js +287 -0
- package/src/runtime/pointer.d.ts +27 -0
- package/src/runtime/pointer.js +128 -0
- package/src/runtime/points.d.ts +25 -0
- package/src/runtime/points.js +130 -0
- package/src/runtime/pools.d.ts +2 -0
- package/src/runtime/pools.js +25 -0
- package/src/runtime/product-stack.d.ts +24 -0
- package/src/runtime/product-stack.js +210 -0
- package/src/runtime/radiant-glass.d.ts +29 -0
- package/src/runtime/radiant-glass.js +282 -0
- package/src/runtime/rain-on-glass/backdrop.d.ts +22 -0
- package/src/runtime/rain-on-glass/backdrop.js +185 -0
- package/src/runtime/rain-on-glass/shader.d.ts +2 -0
- package/src/runtime/rain-on-glass/shader.js +168 -0
- package/src/runtime/rain-on-glass/wipe.d.ts +16 -0
- package/src/runtime/rain-on-glass/wipe.js +65 -0
- package/src/runtime/rain-on-glass.d.ts +27 -0
- package/src/runtime/rain-on-glass.js +210 -0
- package/src/runtime/ramp.d.ts +2 -0
- package/src/runtime/ramp.js +30 -0
- package/src/runtime/random.d.ts +2 -0
- package/src/runtime/random.js +22 -0
- package/src/runtime/scroll-reveal.d.ts +22 -0
- package/src/runtime/scroll-reveal.js +73 -0
- package/src/runtime/shader-background.d.ts +42 -0
- package/src/runtime/shader-background.js +261 -0
- package/src/runtime/shader-backgrounds/band-lens.js +72 -0
- package/src/runtime/shader-backgrounds/common.js +53 -0
- package/src/runtime/shader-backgrounds/grain-gradient.js +87 -0
- package/src/runtime/shader-backgrounds/grid.js +33 -0
- package/src/runtime/shader-backgrounds/mesh-gradient.js +74 -0
- package/src/runtime/shader-backgrounds/silk.js +57 -0
- package/src/runtime/shader-backgrounds/waves.js +31 -0
- package/src/runtime/shape.d.ts +42 -0
- package/src/runtime/shape.js +313 -0
- package/src/runtime/silk-ribbon.d.ts +23 -0
- package/src/runtime/silk-ribbon.js +206 -0
- package/src/runtime/slideshow.d.ts +27 -0
- package/src/runtime/slideshow.js +234 -0
- package/src/runtime/spotlight.d.ts +9 -0
- package/src/runtime/spotlight.js +97 -0
- package/src/runtime/stack-poses.d.ts +53 -0
- package/src/runtime/stack-poses.js +273 -0
- package/src/runtime/stage.d.ts +47 -0
- package/src/runtime/stage.js +187 -0
- package/src/runtime/swarm.d.ts +49 -0
- package/src/runtime/swarm.js +199 -0
- package/src/runtime/text-motion.d.ts +41 -0
- package/src/runtime/text-motion.js +165 -0
- package/src/runtime/text.d.ts +11 -0
- package/src/runtime/text.js +90 -0
- package/src/runtime/tilt.d.ts +19 -0
- package/src/runtime/tilt.js +116 -0
- package/src/runtime/topography.d.ts +71 -0
- package/src/runtime/topography.js +650 -0
- package/src/runtime/trackers.d.ts +21 -0
- package/src/runtime/trackers.js +76 -0
- package/src/runtime/variable-type.d.ts +43 -0
- package/src/runtime/variable-type.js +358 -0
- package/src/runtime/voxel-logo.d.ts +31 -0
- package/src/runtime/voxel-logo.js +237 -0
- package/src/runtime/waves.d.ts +70 -0
- package/src/runtime/waves.js +799 -0
- package/src/runtime/world-labels.d.ts +29 -0
- package/src/runtime/world-labels.js +59 -0
- package/src/runtime/world-land.d.ts +8 -0
- package/src/runtime/world-land.js +105 -0
- package/src/runtime/world-map.d.ts +69 -0
- package/src/runtime/world-map.js +308 -0
- package/src/runtime/world-plan.d.ts +101 -0
- package/src/runtime/world-plan.js +333 -0
- package/src/runtime/world-routes.d.ts +75 -0
- package/src/runtime/world-routes.js +673 -0
- package/src/styles/border-sweep.css +82 -0
- package/src/styles/glass.css +104 -0
- package/src/styles/motion.css +218 -0
- package/src/styles/reveal.css +51 -0
- package/src/vendor/paper/LICENSE +201 -0
- package/src/vendor/paper/NOTICE +5 -0
- package/src/vendor/paper/README.md +8 -0
- package/src/vendor/paper/get-shader-color-from-string.js +100 -0
- package/src/vendor/paper/get-shader-noise-texture.js +17 -0
- package/src/vendor/paper/presets.js +3678 -0
- package/src/vendor/paper/shader-sizing.js +37 -0
- package/src/vendor/paper/shader-utils.js +130 -0
- package/src/vendor/paper/shaders/color-panels.js +223 -0
- package/src/vendor/paper/shaders/dithering.js +270 -0
- package/src/vendor/paper/shaders/dot-grid.js +109 -0
- package/src/vendor/paper/shaders/dot-orbit.js +122 -0
- package/src/vendor/paper/shaders/fluted-glass.js +360 -0
- package/src/vendor/paper/shaders/gem-smoke.js +572 -0
- package/src/vendor/paper/shaders/god-rays.js +132 -0
- package/src/vendor/paper/shaders/grain-gradient.js +300 -0
- package/src/vendor/paper/shaders/halftone-cmyk.js +294 -0
- package/src/vendor/paper/shaders/halftone-dots.js +320 -0
- package/src/vendor/paper/shaders/heatmap.js +383 -0
- package/src/vendor/paper/shaders/image-dithering.js +198 -0
- package/src/vendor/paper/shaders/lens-distortion.js +275 -0
- package/src/vendor/paper/shaders/liquid-metal.js +632 -0
- package/src/vendor/paper/shaders/mesh-gradient.js +130 -0
- package/src/vendor/paper/shaders/metaballs.js +110 -0
- package/src/vendor/paper/shaders/neuro-noise.js +76 -0
- package/src/vendor/paper/shaders/paper-texture.js +526 -0
- package/src/vendor/paper/shaders/perlin-noise.js +166 -0
- package/src/vendor/paper/shaders/pulsing-border.js +238 -0
- package/src/vendor/paper/shaders/simplex-noise.js +91 -0
- package/src/vendor/paper/shaders/smoke-ring.js +132 -0
- package/src/vendor/paper/shaders/spiral.js +82 -0
- package/src/vendor/paper/shaders/static-mesh-gradient.js +130 -0
- package/src/vendor/paper/shaders/static-radial-gradient.js +187 -0
- package/src/vendor/paper/shaders/swirl.js +103 -0
- package/src/vendor/paper/shaders/voronoi.js +138 -0
- package/src/vendor/paper/shaders/warp.js +129 -0
- package/src/vendor/paper/shaders/water.js +121 -0
- package/src/vendor/paper/shaders/waves.js +65 -0
- package/src/vendor/paper/vertex-shader.js +159 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arraypress/effects-astro/ink-field/shaders
|
|
3
|
+
*
|
|
4
|
+
* The ink field's GLSL (ES 1.00): the passes of its stable-fluids sim, and
|
|
5
|
+
* the display that draws the dye as ink in water, lit by a lamp.
|
|
6
|
+
*
|
|
7
|
+
* Adapted from Trirat's ink shader for LumiThemes (smoke-sim.ts), itself
|
|
8
|
+
* ported from a reference stable-fluids sim (Jos Stam's Stable Fluids). The
|
|
9
|
+
* GLSL is his, unchanged but for the display's `uGain` (the sound it
|
|
10
|
+
* follows brightening it): the display's noise is glsl.js's `GLSL_NOISE`,
|
|
11
|
+
* which is the same code, and every pass uses gl.js's `VERTEX`, which is his
|
|
12
|
+
* vertex shader with its precision written out.
|
|
13
|
+
*
|
|
14
|
+
* Velocity is in grid cells per second; `uTxl` converts cells to uv.
|
|
15
|
+
*
|
|
16
|
+
* Dye channels: r is the ink's density, g its density times a palette
|
|
17
|
+
* phase, b its density times a stripe pattern. The display maps the phase
|
|
18
|
+
* through the live palette, so new colours reach ink already on screen.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { GLSL_NOISE } from '../glsl.js';
|
|
22
|
+
|
|
23
|
+
/** Moves a quantity along the velocity, and lets it decay by `uDiss`. */
|
|
24
|
+
export const ADVECT = `
|
|
25
|
+
precision highp float;
|
|
26
|
+
varying vec2 vUv;
|
|
27
|
+
uniform sampler2D uVel, uQty;
|
|
28
|
+
uniform vec2 uTxl;
|
|
29
|
+
uniform float uDt, uDiss;
|
|
30
|
+
void main() {
|
|
31
|
+
vec2 v = texture2D(uVel, vUv).xy;
|
|
32
|
+
vec2 at = clamp(vUv - v * uTxl * uDt, 0.0, 1.0);
|
|
33
|
+
gl_FragColor = uDiss * texture2D(uQty, at);
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
/** The velocity's divergence: how much flows out of each cell. */
|
|
38
|
+
export const DIVERGENCE = `
|
|
39
|
+
precision highp float;
|
|
40
|
+
varying vec2 vUv;
|
|
41
|
+
uniform sampler2D uVel;
|
|
42
|
+
uniform vec2 uTxl;
|
|
43
|
+
void main() {
|
|
44
|
+
float l = texture2D(uVel, vUv - vec2(uTxl.x, 0.0)).x;
|
|
45
|
+
float r = texture2D(uVel, vUv + vec2(uTxl.x, 0.0)).x;
|
|
46
|
+
float b = texture2D(uVel, vUv - vec2(0.0, uTxl.y)).y;
|
|
47
|
+
float t = texture2D(uVel, vUv + vec2(0.0, uTxl.y)).y;
|
|
48
|
+
gl_FragColor = vec4(0.5 * (r - l + t - b), 0.0, 0.0, 1.0);
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
/** One Jacobi iteration of the pressure solve. */
|
|
53
|
+
export const PRESSURE = `
|
|
54
|
+
precision highp float;
|
|
55
|
+
varying vec2 vUv;
|
|
56
|
+
uniform sampler2D uPres, uDiv;
|
|
57
|
+
uniform vec2 uTxl;
|
|
58
|
+
void main() {
|
|
59
|
+
float l = texture2D(uPres, vUv - vec2(uTxl.x, 0.0)).x;
|
|
60
|
+
float r = texture2D(uPres, vUv + vec2(uTxl.x, 0.0)).x;
|
|
61
|
+
float b = texture2D(uPres, vUv - vec2(0.0, uTxl.y)).x;
|
|
62
|
+
float t = texture2D(uPres, vUv + vec2(0.0, uTxl.y)).x;
|
|
63
|
+
float d = texture2D(uDiv, vUv).x;
|
|
64
|
+
gl_FragColor = vec4((l + r + b + t - d) * 0.25, 0.0, 0.0, 1.0);
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
/** Subtracts the pressure's gradient, leaving the velocity divergence-free. */
|
|
69
|
+
export const GRADIENT = `
|
|
70
|
+
precision highp float;
|
|
71
|
+
varying vec2 vUv;
|
|
72
|
+
uniform sampler2D uPres, uVel;
|
|
73
|
+
uniform vec2 uTxl;
|
|
74
|
+
void main() {
|
|
75
|
+
float l = texture2D(uPres, vUv - vec2(uTxl.x, 0.0)).x;
|
|
76
|
+
float r = texture2D(uPres, vUv + vec2(uTxl.x, 0.0)).x;
|
|
77
|
+
float b = texture2D(uPres, vUv - vec2(0.0, uTxl.y)).x;
|
|
78
|
+
float t = texture2D(uPres, vUv + vec2(0.0, uTxl.y)).x;
|
|
79
|
+
gl_FragColor = vec4(texture2D(uVel, vUv).xy - 0.5 * vec2(r - l, t - b), 0.0, 1.0);
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
/** The velocity's curl. */
|
|
84
|
+
export const CURL = `
|
|
85
|
+
precision highp float;
|
|
86
|
+
varying vec2 vUv;
|
|
87
|
+
uniform sampler2D uVel;
|
|
88
|
+
uniform vec2 uTxl;
|
|
89
|
+
void main() {
|
|
90
|
+
float l = texture2D(uVel, vUv - vec2(uTxl.x, 0.0)).y;
|
|
91
|
+
float r = texture2D(uVel, vUv + vec2(uTxl.x, 0.0)).y;
|
|
92
|
+
float b = texture2D(uVel, vUv - vec2(0.0, uTxl.y)).x;
|
|
93
|
+
float t = texture2D(uVel, vUv + vec2(0.0, uTxl.y)).x;
|
|
94
|
+
gl_FragColor = vec4(0.5 * (r - l - (t - b)), 0.0, 0.0, 1.0);
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
|
|
98
|
+
/** Vorticity confinement: pushes along the curl, so eddies keep turning. */
|
|
99
|
+
export const VORTICITY = `
|
|
100
|
+
precision highp float;
|
|
101
|
+
varying vec2 vUv;
|
|
102
|
+
uniform sampler2D uVel, uCurl;
|
|
103
|
+
uniform vec2 uTxl;
|
|
104
|
+
uniform float uStrength, uDt;
|
|
105
|
+
void main() {
|
|
106
|
+
float l = abs(texture2D(uCurl, vUv - vec2(uTxl.x, 0.0)).x);
|
|
107
|
+
float r = abs(texture2D(uCurl, vUv + vec2(uTxl.x, 0.0)).x);
|
|
108
|
+
float b = abs(texture2D(uCurl, vUv - vec2(0.0, uTxl.y)).x);
|
|
109
|
+
float t = abs(texture2D(uCurl, vUv + vec2(0.0, uTxl.y)).x);
|
|
110
|
+
float c = texture2D(uCurl, vUv).x;
|
|
111
|
+
vec2 eta = normalize(vec2(t - b, r - l) + vec2(1e-5));
|
|
112
|
+
vec2 f = uStrength * vec2(eta.y, -eta.x) * c;
|
|
113
|
+
gl_FragColor = vec4(texture2D(uVel, vUv).xy + f * uDt, 0.0, 1.0);
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
|
|
117
|
+
/** Adds a soft round splat to a field: velocity in xy, or ink laid in stripes. */
|
|
118
|
+
export const SPLAT = `
|
|
119
|
+
precision highp float;
|
|
120
|
+
varying vec2 vUv;
|
|
121
|
+
uniform sampler2D uSrc;
|
|
122
|
+
uniform vec2 uAt;
|
|
123
|
+
uniform vec3 uVal;
|
|
124
|
+
uniform vec2 uStripe;
|
|
125
|
+
uniform float uRad, uAsp;
|
|
126
|
+
void main() {
|
|
127
|
+
vec2 d = vUv - uAt;
|
|
128
|
+
d.x *= uAsp;
|
|
129
|
+
float g = exp(-dot(d, d) / (uRad * uRad));
|
|
130
|
+
// Z is laid down in stripes (angle, frequency): layers inside the ink that
|
|
131
|
+
// the flow then stretches into folds. Velocity splats put nothing in Z.
|
|
132
|
+
vec2 dir = vec2(cos(uStripe.x), sin(uStripe.x));
|
|
133
|
+
float s = 0.5 + 0.5 * sin(dot(d, dir) * uStripe.y + uStripe.x * 7.0);
|
|
134
|
+
gl_FragColor = vec4(texture2D(uSrc, vUv).xyz + g * vec3(uVal.xy, uVal.z * s), 1.0);
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Ink in water, lit by the palette. The dye is read as the amount of ink in
|
|
140
|
+
* the light's path: soft pale veils where it is thin, deep saturated cores
|
|
141
|
+
* where it is thick, clear water between. It stands as a surface, lit by one
|
|
142
|
+
* lamp (a point above the plane): wrapped diffuse, soft shade from ink in
|
|
143
|
+
* front, light coming through the thin parts, and only the faintest sheen.
|
|
144
|
+
* The glint colour is unused here. `uGain` brightens it all (0 for as is).
|
|
145
|
+
*
|
|
146
|
+
* Tunable, at the top: BUMP (how steep the ink's surface is), LAMP_Z (how
|
|
147
|
+
* high the lamp hangs), AMBIENT (light left on the shadowed side) and SHEEN.
|
|
148
|
+
*/
|
|
149
|
+
export const DISPLAY = `
|
|
150
|
+
precision highp float;
|
|
151
|
+
varying vec2 vUv;
|
|
152
|
+
uniform sampler2D uDye;
|
|
153
|
+
uniform vec2 uRes;
|
|
154
|
+
uniform float uTime;
|
|
155
|
+
uniform vec3 uPal[3];
|
|
156
|
+
uniform vec3 uGlint;
|
|
157
|
+
uniform vec2 uDyeTxl;
|
|
158
|
+
uniform vec2 uLight;
|
|
159
|
+
uniform float uGain;
|
|
160
|
+
|
|
161
|
+
// Tunable: how steep the ink's surface is, how high the lamp hangs, how much
|
|
162
|
+
// of the ambient light is left on the shadowed side, and the (very soft) sheen.
|
|
163
|
+
const float BUMP = 0.05;
|
|
164
|
+
const float LAMP_Z = 0.5;
|
|
165
|
+
const float AMBIENT = 0.38;
|
|
166
|
+
const float SHEEN = 0.08;
|
|
167
|
+
|
|
168
|
+
// How much ink stands at a point: its amount and its layers.
|
|
169
|
+
float thick(vec2 q) {
|
|
170
|
+
vec4 d = texture2D(uDye, q);
|
|
171
|
+
return 0.75 * d.r + 0.5 * d.b;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
${GLSL_NOISE}
|
|
175
|
+
vec3 pal(float t) {
|
|
176
|
+
float x = fract(t) * 3.0;
|
|
177
|
+
float k = smoothstep(0.0, 1.0, fract(x));
|
|
178
|
+
if (x < 1.0) return mix(uPal[0], uPal[1], k);
|
|
179
|
+
if (x < 2.0) return mix(uPal[1], uPal[2], k);
|
|
180
|
+
return mix(uPal[2], uPal[0], k);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
void main() {
|
|
184
|
+
vec2 uv = (gl_FragCoord.xy - 0.5 * uRes) / uRes.y;
|
|
185
|
+
float t = uTime * 0.05;
|
|
186
|
+
|
|
187
|
+
// A light warp only: the sim makes the tendrils, this roughs them a little.
|
|
188
|
+
vec2 w = vec2(fbm(uv * 3.2 + vec2(0.0, t * 2.0)), fbm(uv * 3.2 + vec2(5.2, -t * 2.0))) - 0.5;
|
|
189
|
+
vec4 dye = texture2D(uDye, vUv + w * 0.014);
|
|
190
|
+
|
|
191
|
+
// How much ink is in the light's path. Clear water stays clear (the floor),
|
|
192
|
+
// thin ink is a pale veil, thick ink is deep and nearly opaque.
|
|
193
|
+
float ink = 1.0 - exp(-dye.r * 2.1);
|
|
194
|
+
ink = smoothstep(0.02, 1.0, ink);
|
|
195
|
+
// The layers inside the ink (Z of the dye, as a share of what is there).
|
|
196
|
+
float stri = clamp(dye.b / max(dye.r, 1e-3), 0.0, 1.2);
|
|
197
|
+
ink *= 0.72 + 0.4 * stri;
|
|
198
|
+
ink *= 0.94 + 0.12 * fbm(uv * 6.0 + w * 3.0 + t * 2.0);
|
|
199
|
+
|
|
200
|
+
// The ink as a surface: its thickness is the height, and the lamp lights
|
|
201
|
+
// it. Sampled a texel and a half out, so the dye's grid does not show.
|
|
202
|
+
vec2 q = vUv + w * 0.014;
|
|
203
|
+
vec2 e = 1.5 * uDyeTxl;
|
|
204
|
+
float h = thick(q);
|
|
205
|
+
vec2 slope = vec2(thick(q + vec2(e.x, 0.0)) - thick(q - vec2(e.x, 0.0)),
|
|
206
|
+
thick(q + vec2(0.0, e.y)) - thick(q - vec2(0.0, e.y))) / (2.0 * e);
|
|
207
|
+
vec3 n = normalize(vec3(-slope * BUMP, 1.0));
|
|
208
|
+
|
|
209
|
+
float aspect = uRes.x / uRes.y;
|
|
210
|
+
vec2 lamp = (uLight - 0.5) * vec2(aspect, 1.0);
|
|
211
|
+
vec3 toLamp = vec3(lamp - uv, LAMP_Z);
|
|
212
|
+
float lampDist = length(toLamp);
|
|
213
|
+
vec3 l = toLamp / lampDist;
|
|
214
|
+
|
|
215
|
+
// Wrapped diffuse, so the far side of a fold is dim, not black.
|
|
216
|
+
float diffuse = pow(clamp(dot(n, l) * 0.5 + 0.5, 0.0, 1.0), 1.5);
|
|
217
|
+
float reach = 0.55 + 0.9 / (1.0 + 2.2 * lampDist * lampDist);
|
|
218
|
+
|
|
219
|
+
// Ink in front of the lamp shades the ink behind it: three taps toward it.
|
|
220
|
+
vec2 toward = normalize(l.xy + 1e-4) * vec2(1.0 / aspect, 1.0);
|
|
221
|
+
float blocked = 0.0;
|
|
222
|
+
blocked += max(thick(q + toward * 0.012) - h - 0.02, 0.0);
|
|
223
|
+
blocked += max(thick(q + toward * 0.028) - h - 0.04, 0.0);
|
|
224
|
+
blocked += max(thick(q + toward * 0.055) - h - 0.06, 0.0);
|
|
225
|
+
float shade = exp(-blocked * 2.2);
|
|
226
|
+
|
|
227
|
+
// Ink deepens as it thickens: the colour is raised to a power, which
|
|
228
|
+
// darkens and saturates it, the way a thicker column of dye does.
|
|
229
|
+
float phase = dye.g / max(dye.r, 1e-4);
|
|
230
|
+
vec3 base = pal(phase + 0.1 * (fbm(uv * 2.4 + w * 2.0) - 0.5));
|
|
231
|
+
vec3 albedo = pow(base, vec3(0.75 + 1.0 * ink));
|
|
232
|
+
vec3 col = albedo * ink * (AMBIENT + 1.05 * diffuse * shade * reach);
|
|
233
|
+
|
|
234
|
+
// Light through the thin parts: a glow where the ink is half there.
|
|
235
|
+
col += base * (4.0 * ink * (1.0 - ink)) * 0.22 * shade * reach;
|
|
236
|
+
|
|
237
|
+
// A broad, soft sheen on the lit side, not a highlight.
|
|
238
|
+
vec3 hv = normalize(l + vec3(0.0, 0.0, 1.0));
|
|
239
|
+
col += vec3(1.0, 0.92, 0.95) * pow(max(dot(n, hv), 0.0), 10.0) * SHEEN * ink * shade;
|
|
240
|
+
|
|
241
|
+
// The water itself: a faint, slow glow the ink sits in, pushed aside by it.
|
|
242
|
+
vec3 water = mix(pal(t * 0.6 + 0.15 * uv.y), pal(t * 0.6 + 0.5 + 0.2 * fbm(uv * 1.3)), 0.5);
|
|
243
|
+
col += water * 0.07 * (1.0 - ink);
|
|
244
|
+
|
|
245
|
+
// Brighter with the sound the field follows, if any (0 without).
|
|
246
|
+
col *= 1.0 + uGain;
|
|
247
|
+
|
|
248
|
+
// Dim behind the copy, and towards the corners.
|
|
249
|
+
float copy = smoothstep(0.05, 0.8, length((uv - vec2(0.0, 0.02)) * vec2(1.05, 1.0)));
|
|
250
|
+
col *= mix(0.3, 1.0, copy);
|
|
251
|
+
col *= 1.0 - 0.45 * dot(uv * 0.55, uv * 0.55);
|
|
252
|
+
|
|
253
|
+
// Grain, so the dark ramps do not band.
|
|
254
|
+
col += (hash(gl_FragCoord.xy + fract(uTime)) - 0.5) * 0.035;
|
|
255
|
+
|
|
256
|
+
gl_FragColor = vec4(max(col, 0.0) + vec3(0.031, 0.031, 0.039), 1.0);
|
|
257
|
+
}
|
|
258
|
+
`;
|