How it works
The classic Stripe hero gradient, rebuilt as a material. A tessellated sheet is tilted, twisted and displaced along its normal by slow simplex noise in long, sideways-stretched drapes, then painted with four colours over a base, in a fixed order, each with a smoothstep()^4 weight so every colour owns its own region instead of averaging into mud. Real normals from that displacement give the drapes relief and a satin sheen. Your cursor stirs a small viscous fluid that lives in the sheet's own coordinates. It presses a soft trough into the silk along your path and drags the colours with it, and both relax back over about three seconds.
Pipeline (per frame)
pointer segment (screen) ──▶ CPU: Newton-invert the sheet transform ──▶ segment in sheet coords
│
▼ only while a wake is alive (8 × linger + 1 s after the last move; then skipped entirely)
[splat] v ← mix(v, pointer velocity, 1 − (1 − capsule·grip)^(dt·60)) RGBA16F 168×128, sheet space
capsule r 0.42 from last segment to this one; grip = 0.36 × Wake strength
[viscous] 6 × Jacobi on (I − ν·dt·∇²) v = v₀ same grid
[project] divergence → 12 × Jacobi pressure (warm start × 0.8^(dt·60)) → v −= ∇p
[advect] v ← v(x − v·dt) / (1 + 0.6·dt)
[wake] D ← blur₅(D)(x − ½·v·dt) + 0.3·v·dt, D ×= e^(−dt/linger) RGBA16F 168×128
E ← blur₅(E)(x − ½·v·dt) + 0.3·|v|·dt, E ×= e^(−dt/linger) (xy = D, z = E)
blur weight 0.15 per 60 Hz frame, ramping to 0.95 as |∇drag(D)| goes 0.3 → 0.65
│
▼ every frame while the wake is alive, otherwise 30 fps (the canvas keeps the last frame)
[field] m = s − drag(D); m.y += 0.4·h(m) RGBA16F 480×360 (0.17 MP)
Oklab: base, then 4 layers w = smoothstep(lo_k, hi_k, n_k)^4, texture-space shading,
noise time + 0.12·ê (stir); later layers rarer and crisper; then generateMipmap
layer 3 only inside layer 2; mix + 75% chroma restore
│
▼
[sheet] VS 220×164 grid (36k verts): h = fold(m, t) − trough default framebuffer
fold: 2 octaves simplex at Fold frequency, x stretched 3× RGBA8, alpha off, depth
trough: 0.11 × Wake strength × ê, ê = E saturated to 0..1 1920×1080 at DPR 1.5
h scaled down where the sheet is seen at a grazing angle
tilt + twist about x, roll about the view axis, perspective
lighting normals one wake texel apart, fine octave damped
FS field → linear sRGB; wrap diffuse + satin lobe relative to
the flat sheet; light pages: shade with chroma, top-left
depth ramp; dark pages: glow from field mips 2.5 and 4;
shoulder + grain on the silk only;
page + soft shadow under the hem (band presets);
sRGB encode → TPDF dither ±1 LSB (last op; silk and shadow only)
The ideas that matter
- Big means low frequency, not high amplitude. The colour noise runs at under one mass per screen width and evolves at a few hundredths of a noise unit per second, so a colour mass takes 20 seconds or more to change identity. Typically two to four colour masses are in view, and raising Noise frequency is what turns this look into a lava-lamp screensaver. The folds have their own Fold frequency, about 2.3 times the colour's by default, and their noise is stretched three times along the sheet's x. That gives about three long drapes per screen height, like Stripe's one-dimensional fold wave, while the colour stays calm. With one shared frequency you had to choose between busy colour and folds too broad to read. A portrait phone sees a narrow slice of the sheet, so there both frequencies rise by 1/√aspect and the page gap under the hem narrows, and a phone shows as many masses as a desktop.
- Ordered over-painting with a fourth power. The colour starts at the base and each layer is
mix()ed over it in turn. The^4turns a broad noise hump into a compact blob with a soft rim, so colours stay separate. Layer sharpness sets the smoothstep window, and Layer coverage moves its centre so the w = 0.5 contour stays at the chosen threshold. That makes them two independent controls, which is how the dark presets keep negative space. Each later layer gets a higher threshold and a narrower window, so the first layer forms the large masses and the last one is a crisp accent. Midnight raises the last layer's threshold further, so its cyan appears only now and then, as a small accent. - The accent grows inside its neighbour. Layer 3 uses noise correlated with layer 2's (0.6 / 0.8 mix, so the spread is unchanged), and its weight is multiplied by a smoothstep of layer 2's. It can only burn as the core of a layer-2 region: amber inside coral, pink inside violet, gold inside ember. That removed the lime rim where amber used to paint straight over cyan. Nesting also makes the warm cores read as one flame rather than two unrelated blobs.
- Oklab, with the lost chroma given back. A straight line in Oklab between distant hues, such as amber and teal, still passes through low-chroma olive. After each mix the shader rescales the a/b channels 75% of the way toward the interpolated chroma. The gain is
want / max(have, want / 3): exactly 1 where nothing was lost, capped at 3, and continuous through zero chroma. An earlier soft-floor form,want · inversesqrt(have² + ε), quietly desaturated every pale colour by up to 60% over four layers, which is what made the pastel preset grey. - The fold is real geometry. Stripe's original displaced vertices in screen y so the colour bands bunch up and stretch. Here the sheet is displaced along its normal and viewed at a tilt, so the same band compression falls out of perspective, and the same displacement also gives true normals for lighting. A soft cap (
52° · tanh(a / 52°)) on tilt plus twist keeps the horizon from ever showing. Where the sheet is seen at a grazing angle (far, toward the top of a steep tilt), a fold steeper than the view ray would stand up into a hard, aliased silhouette. There the displacement scales down so that the steepest expected slope (about 4 × depth × fold frequency, plus the trough) stays below the tangent of the grazing angle. The lighting normal keeps half of its relief there, so far drapes still read. - Shade the colour in texture space. Four simplex layers per screen pixel at 1920×1080 are about 8 million noise evaluations a frame. The field is so smooth that computing it once over the sheet's own coordinates (0.17 MP, RGBA16F) and sampling it bilinearly looks identical, at about a twelfth of the work, and the half-float storage means it never bands. One
generateMipmapon that small target then provides the blurred levels the glow reads. - Light relative to the flat sheet. Diffuse and specular are normalised against the normal the sheet would have without folds. A flat patch therefore shows the exact brand colour, folds facing the light brighten, and folds turning away deepen. The satin lobe adds light only where a slope beats the flat sheet, divided by
max(1 − flat, 0.3)so a slight bump never flares where the flat sheet is already near the highlight. A smoothstep onset means highlights have no hard rim. The lighting normal damps the finer fold octave (30% on dark, 40% on light) and uses a broad lobe (exponent 14 / 12), so the satin is wide, and the edge-on rim term is weighted 0.5 on dark pages and 0.22 on light ones, where a whitened rim reads as glare. Where the tilted sheet is foreshortened (far, toward the top of the frame), a lobe of fixed angular width squeezes into a hairline on screen, so the satin fades out with the flat sheet'sN·Vthere. - No grey anywhere. On dark pages the sheen takes the albedo's own hue, at a brightness that tapers with it (
alb / √max(alb)), and fades out below about 2% linear. Black stays black, indigo silk gets an indigo sheen rather than a grey smudge, and the navy or wine ground of the dark presets still shows its drapes in shadow. On light pages the shaded side gains chroma as it loses value (colour by thickness), so Relief light reads as deeper fabric rather than dirt. Palettes whose mean Oklab L is above about 0.8 shade more gently, never below 86% of their light and with twice the shadow saturation gain, so a pastel fold deepens in colour instead of going grey. - Glow on dark pages, depth on light ones. On dark pages the fragment shader adds two blurred mip levels (2.5 and 4) of the colour field, weighted by their luminance and eased off where the silk is already bright. Bright masses therefore spill light into the shadowed fabric around them, which reads as glow rather than as defocused blobs on black. On light pages, where bloom does not read, a fifth-power ramp toward the top-left corner deepens and saturates the silk instead, as Stripe's top darken did, which gives the band depth at one edge.
- The wake lives on the silk. The pointer is mapped into sheet coordinates by Newton-inverting a CPU mirror of the vertex transform, so the wake is perspective-correct and travels with the material. A stable-fluids velocity field (grip splat, implicit viscosity, pressure projection) advects a material offset D. Both the colour field and the fold height are evaluated at
m = s − drag(D), so colours and folds are pulled together, and fold highlights bend around your path like pulled fabric. Dragging a field this low in frequency moves very little on screen, so the wake also gets something to act on: it dents the sheet. A third channel, the wake energy E, is carried and relaxed exactly like D but accumulates the distance the silk was pushed, so it is never negative. The height drops by0.11 × Wake strength × ê, with ê being E softly saturated to 0..1. A soft trough therefore follows the cursor, and the satin catches its walls. The trough is driven by E rather than |D| because where the path crosses itself D reverses through zero, and a trough built from D pinched there into a narrow ridge with a thin, stair-stepped highlight. E also advances the colour noise's time locally (the research's stir), so the colour boils slightly along your path. Both relax exponentially, which is overdamped (no springiness): the wake is visible for about three times Wake linger. With time frozen, one full-width stroke at 1280×720 changes 25% of the frame by more than 20 levels. Before the trough and the stir, the same stroke changed 12%. - Keeping the wake one-to-one. The material map only stays smooth while the drag's Jacobian stays below 1. If it reaches 1, colours fold over and mirror into V-shaped notches. Strain in the flow sharpens D's gradients exponentially, so D is carried by only half the flow, and the silk follows 30% of it. The departure-point blur is a light 0.15 per 60 Hz frame and strengthens to 0.95 where the gradient climbs past 0.3. Scaling or decaying D by its own local gradient was also tried and rejected, because those limiters ripple at texel scale. Reading the wake back over harness sweeps and taking the Jacobian determinant of
m(s)shows broad compression at the centres of loops and no fold anywhere: the minimum is about 0.24 at wake 1 and 0.21 at wake 1.5. Following 40% of the flow was no more legible once the trough existed, and it pinched loop centres to 0.15, which squeezes a colour mass into a small dot. The normals are central differences one wake texel apart. A sub-texel step reads the bilinear field's piecewise-constant gradient and gives faceted highlights. - Rates per second, not per frame. The grip, the departure blur and the pressure warm start are written as 60 Hz amounts and converted with
1 − (1 − a)^(dt·60). The splat uses the time since the previous pointer segment, because pointer events can arrive slower than frames. Grain re-seeds from elapsed time at 20 Hz. A 120 Hz display therefore gives the same wake as 60 Hz. - A hem that belongs to the sheet. In band presets the edge is a line in sheet coordinates, so it undulates with the folds. The page below and its soft shadow are drawn by the same fragment shader, antialiased with
fwidth, so there is no extra pass and the hem never bands. The highlight shoulder, the grain and the dither apply only to the silk and its shadow, so beyond the shadow the page is exactly the page colour (255 on Stripe classic) and meets a white article seamlessly. Where the band sits, its roll angle and how rare the last layer is are composition, so each preset sets them instead of a slider. - Dither is the last operation. Grain (monochrome, midtone-weighted) is applied in linear light, then the colour is sRGB-encoded, then triangular-PDF dither of ±1 LSB per channel is added, fading to uniform near 0 and 1. One pcg3d hash supplies all six dither randoms as 16-bit halves. Under a hard contrast stretch, the dark Midnight gradients show contour bands with Dither at 0 and none at 1.
Parameters
Presets
Performance & compatibility
- Measured in the verification harness at 1280×720 CSS px and DPR 2 (its 2560×1440 configuration; the page caps itself at DPR 1.5, so it renders 1920×1080) on an Apple M5 (10-core GPU), during a cursor sweep with the wake solver running: 59 to 60 fps, GPU 3.5 to 8.7 ms mean and 5.2 to 13.1 ms p95 across seven harness runs of the final page, JS 0.08 to 0.14 ms per frame. Other builds, including two other harness runs, were using the GPU at the same time, which inflates these numbers and causes the spread: the same code measured 4.2 / 5.2 ms and 8.6 / 13.1 ms ten minutes apart. Eight earlier runs this round, with the same passes, ranged from 2.6 to 5.9 ms mean and 5.1 to 12.2 ms p95, plus one outlier at 12.6 / 21.2 ms while another build saturated the GPU. Interleaved re-runs of identical code in one browser swing just as widely (3.5 to 10.6 ms mean), so the spread is contention, not the page. The least-contended interleaved A/B session in one browser measured 2.1 to 4.5 ms mean and 4.6 to 6.1 ms p95 at DPR 1.5, against 2.9 to 5.1 ms and 6.8 to 10.6 ms at DPR 2.
- Why DPR 1.5: the image has no detail finer than the hem's antialiased edge and the grain, so on a retina screen DPR 1.5 looks the same as 2 while shading 44% fewer fragments. The hem keeps its 2 px
fwidthedge, and the page under it is still exactly 255. - At rest (no wake alive, so the solver is skipped and the silk is drawn at 30 fps): 1.4 to 1.8 ms mean per display frame at DPR 1.5, against 1.9 to 3.1 ms at DPR 2 in the same session. Every other frame does no GPU work at all, and the browser keeps showing the last drawn frame. The dither seed still changes on every drawn frame, and the grain re-seeds at 20 Hz. The dark presets add two mip taps for the glow and measured 3.9 to 4.6 ms mean (5.5 to 5.8 ms p95) during a sweep and about 2.0 ms at rest.
- Where the time goes: almost all of it is the sheet's fragment pass over 2.1 MP: Oklab decode, lighting, two pcg3d hashes, sRGB encode and dither, plus the glow taps on dark pages. The colour field (0.17 MP) with its mip chain, and the 36k-vertex mesh, are small. The 24 solver passes (plus one splat per pointer move) add about 1 ms while a wake is alive. These splits come from A/B runs on the same contended GPU, so read them as proportions.
- What scales it: canvas pixels (the sheet's fragment pass), the mesh budget (36k vertices on desktop) and the field resolution (360 texels on the short side). Sizes follow the canvas and the sheet's bounds and are quantized to 8 texels (the mesh to 4 cells). A full sweep of the Tilt slider therefore re-allocates the solver only two or three times, rather than on nearly every step, and the wake survives live slider drags.
- Mobile: the same DPR 1.5 cap applies (a 390 px phone renders 585×1266), with a 96-cell solver (96×136 in portrait), a 240-texel field and a 20k-vertex mesh. On portrait screens both frequencies rise by 1/√aspect and the page gap under the hem halves, so a phone shows about four colour masses and mostly silk. The harness's touch run reports about 45 fps because it captures a screenshot mid-drag. An earlier 390×844 emulation without the capture measured 59.5 fps at about 2 to 4 ms of GPU time.
- Gallery embed: DPR 1, a 64-cell solver, a 150-texel field, a 9k-vertex mesh and half the page gap, with the ghost pointer running forever.
- Requirements: WebGL2 with
EXT_color_buffer_floatfor the half-float field and solver targets. Without them the page paints its own CSS still of the current preset in place of the shell's darkened poster: a radial-gradient stack of the palette over the base colour and, on band presets, the page under a hem that rises at the preset's angle, with a soft shadow. The shell's card explains why, and changing presets repaints the still. - Ambient behaviour: it runs continuously while visible and pauses off-screen or in a hidden tab. Time is integrated (
τ += 0.65 · dt · speed), so changing Speed never jumps. All wake rates are per second, so 120 Hz displays do not run fast. - Reduced motion: one calm still at the artistic first frame, with no wake and no animation, plus the shell's "Play anyway" button. Resizes, rotations, presets and slider changes re-render the still. A resized canvas would otherwise stay black, because no frame loop runs.
References & credits
- Kevin Hufnagl, "How to create the Stripe website gradient effect": kevinhufnagl.com/how-to-stripe-website-gradient-effect. No license stated. The source of the technique (displaced plane, ordered
^4layers, slow evolution). Its parameters informed this page; no code was copied. - Whatamesh: github.com/jordienr/whatamesh. No license, and derived from proprietary code, so it was read for structure only and nothing was used.
- Ian McEwan, Ashima Arts and Stefan Gustavson, webgl-noise: github.com/stegu/webgl-noise. MIT. The 3D simplex noise, inlined with attribution, using the 2022 C2-continuous kernel.
- Björn Ottosson, "A perceptual color space for image processing" (Oklab): bottosson.github.io/posts/oklab. The post puts its code in the public domain, and also offers it under MIT. The published conversion matrices are used as constants.
- Mark Jarzynski and Marc Olano, "Hash Functions for GPU Rendering", JCGT 9(3), 2020: jcgt.org/published/0009/03/02. The paper is published under CC BY-ND 3.0. The pcg3d hash used for dither and grain, a few lines of integer arithmetic, is implemented from its description.
- Mikkel Gjøl, "Banding in Games: A Noisy Rant": loopit.dk/banding_in_games.pdf. Slides, copyright the author, no license stated. Only its rules were used (TPDF, after the encode, last); no code.
- Jos Stam, "Stable Fluids", SIGGRAPH 1999: doi.org/10.1145/311535.311548. Paper, © ACM; only the algorithm was used. The wake solver follows the library's reference fluid trail (grip splats, implicit viscosity) and the pass structure popularised by Pavel Dobryakov's WebGL Fluid Simulation, MIT: github.com/PavelDoGreat/WebGL-Fluid-Simulation. It was written from scratch here.
- Alex Harri, "A flowing WebGL gradient, deconstructed": alexharri.com/blog/webgl-gradients. The site's MIT license covers its
/srconly and explicitly excludes the posts, so the article text has no license grant. It was read as background on layered gradient fields; nothing was used.