IrisBackgroundsSilk Weft
Silk Weft
Silk Drape turned on its side — the same fold math running left to right instead of top to bottom, pale at the left, deepening to umber on the right.
Silk Weft
A variation on `silk-drape` that turns the drapery on its side: the exact same two-scale fold math and fbm warp, the exact same live amber ramp, only reading its phase off the vertical axis instead of the horizontal one — so the bands run left to right across the frame rather than hanging top to bottom. The gradient turns with them: pale gold anchored on the left edge, deepening through gold and umber into deep umber on the right, instead of pale-at-base/deep-at-top.
The pointer's contract is identical to `silk-drape`'s, just turned ninety degrees with everything else: it parts the bands nearest it and leaves a soft warm bloom, as if the fabric were touched from behind.
Install
No installation needed — self-contained, paste-in code.
Usage
Drop it straight into a page.
import { SilkWeftField } from "./SilkWeftField";
export default function Example() {
return (
// Fills its nearest positioned ancestor (it renders itself `absolute
// inset-0`) — give it a sized, relatively positioned box.
<div className="relative isolate h-[32rem] w-full overflow-hidden rounded-2xl">
<SilkWeftField />
</div>
);
}Component
The real source, exactly as it ships — multiple files, kept together.
"use client";
import { useEffect, useRef } from "react";
import { mountShaderSurface } from "@/lib/shader-surface";
/**
* A variation on `SilkField` that turns the drapery on its side: the exact
* same fold math (two-scale sine bands riding a low-frequency fbm warp),
* the exact same pointer contract, and the exact same live amber ramp — the
* only thing that changes is which axis the bands run along. `silk-drape`'s
* folds hang top to bottom; these run left to right, "weft" being the
* crosswise thread in a woven fabric where "warp" (confusingly, in the
* weaving sense, not the shader sense) runs the other way.
*
* The gradient turns with the bands: pale gold anchored on the left,
* deepening through gold and umber into deep umber on the right, instead of
* pale-at-base/deep-at-top.
*
* The pointer's contract is unchanged from `silk-drape`: it parts the bands
* nearest it and leaves a soft warm bloom, as if the fabric were touched
* from behind — just turned ninety degrees with everything else.
*
* Drop it into any `position: relative`/`isolate` parent — it fills the box.
* Same degradation contract as `SilkField`: no WebGL, a blocked or lost
* context, a hidden tab, or `prefers-reduced-motion` all leave the CSS
* `.iris-silkweftfield__floor` underneath visible.
*/
const FRAG = `
uniform vec2 u_res;
uniform float u_time;
uniform float u_scale;
uniform vec3 u_pointer; /* x, y (0 bottom .. 1 top), presence 0..1 */
uniform vec3 u_deep; /* --color-accent-950, the right edge of the field */
uniform vec3 u_umber; /* --color-accent-800, right-mid */
uniform vec3 u_gold; /* --color-accent-600, left-mid */
uniform vec3 u_pale; /* --color-accent-300, the left edge */
uniform vec4 u_readA;
uniform float u_guard;
/* Bands across the height, at two scales — a slow, wide sway and a finer
thread count riding on top of it. Identical constants to SilkField;
only the axis they read along changes. */
const float FOLDS = 6.0;
const float THREADS = 22.0;
void main() {
vec2 res = u_res / u_scale;
vec2 uv = gl_FragCoord.xy / u_scale / res; /* 0..1, y up */
float aspect = res.x / res.y;
vec2 P = (uv - 0.5) * vec2(aspect, 1.0);
vec2 ptr = (u_pointer.xy - 0.5) * vec2(aspect, 1.0);
vec2 toP = P - ptr;
float dP = length(toP);
float pull = u_pointer.z * exp(-dP * dP * 50.0);
/* the touch parts the weft: bands near the cursor bend toward it, as if
the fabric were being pulled from behind the cursor */
vec2 wp = P - toP * pull * 1.1;
/* the same low-amplitude warp as silk-drape, just reading its primary
coordinate off wp.y instead of wp.x, so it perturbs horizontal bands
rather than vertical ones */
float warp = fbm(vec2(wp.y * 1.4, wp.x * 0.8 + u_time * 0.02)) * 0.30;
float phase = wp.y * FOLDS + warp + u_time * 0.035;
float coarse = sin(phase * 3.14159265);
float fine = sin((wp.y * THREADS + warp * 1.6) * 3.14159265);
float weft = clamp(coarse * 0.72 + fine * 0.28, -1.0, 1.0);
weft = sign(weft) * pow(abs(weft), 0.82); /* widen the bright peaks a touch */
/* ---- the horizontal gradient, pale at the left, deep at the right ---- */
vec3 base = u_pale;
base = mix(base, u_gold, smoothstep(0.10, 0.52, uv.x));
base = mix(base, u_umber, smoothstep(0.42, 0.80, uv.x));
base = mix(base, u_deep, smoothstep(0.70, 1.05, uv.x));
vec3 col = base * (0.58 + 0.62 * (0.5 + 0.5 * weft));
/* the touch: a soft warm bloom, and the nearest bands catch extra light */
col += u_pale * pull * 0.42;
col += base * pull * (0.5 + 0.5 * weft) * 0.5;
col = max(col, 0.0);
/* ---- the reading guard (see TileField for the full rationale) ---- */
vec2 rd = abs(uv - u_readA.xy) / max(u_readA.zw, vec2(0.02));
float m = mix(max(rd.x, rd.y), length(rd), 0.4);
float band = 1.0 - smoothstep(0.72, 2.1, m);
col = mix(col, holdUnder(col, 0.09), band * u_guard);
col += (bayer8(gl_FragCoord.xy) - 0.5) * (2.2 / 255.0);
gl_FragColor = vec4(col, 1.0);
}
`;
export interface SilkWeftFieldProps {
className?: string;
/**
* CSS selector for the block the reading guard should keep readable,
* resolved against `document`. `null` (the default) turns the guard off.
*/
guardSelector?: string | null;
}
export function SilkWeftField({ className, guardSelector = null }: SilkWeftFieldProps) {
const canvasRef = useRef<HTMLCanvasElement>(null);
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const guardOn = guardSelector != null;
let guardEl: Element | null | undefined;
const readGuardEl = () => {
if (guardEl === undefined) {
guardEl = guardOn ? document.querySelector(guardSelector as string) : null;
}
return guardEl;
};
return mountShaderSurface(canvas, {
fragment: FRAG,
colors: {
u_deep: "--color-accent-950",
u_umber: "--color-accent-800",
u_gold: "--color-accent-600",
u_pale: "--color-accent-300",
},
uniforms: ["u_readA", "u_guard"],
onInit: (gl, u) => {
if (u.u_readA) gl.uniform4f(u.u_readA, 0.5, 0.5, 0.44, 0.32);
if (u.u_guard) gl.uniform1f(u.u_guard, guardOn ? 1 : 0);
},
onFrame: (gl, u, s) => {
if (!guardOn || !u.u_readA) return;
let cx = 0.5, cy = 0.5, hw = 0.44, hh = 0.32;
const el = readGuardEl();
const { rect } = s;
if (el && rect.width > 0 && rect.height > 0) {
const r = el.getBoundingClientRect();
const padX = rect.width * 0.09;
const padY = rect.height * 0.11;
cx = (r.left + r.width / 2 - rect.left) / rect.width;
cy = 1 - (r.top + r.height / 2 - rect.top) / rect.height;
hw = (r.width / 2 + padX) / rect.width;
hh = (r.height / 2 + padY) / rect.height;
}
gl.uniform4f(u.u_readA, cx, cy, hw, hh);
},
onPainted: () => canvas.setAttribute("data-shader", "on"),
/* No onIdle — same contract as `SilkField`: once the field has painted
once, its last frame stays on screen while the surface is parked
off-view, instead of crossfading to the static floor on every
scroll-away/back. A lost context still clears it below. */
onLost: () => canvas.removeAttribute("data-shader"),
maxPixels: 2_200_000,
dprCap: 1.5,
});
}, [guardSelector]);
return (
<div className={`absolute inset-0 overflow-hidden${className ? ` ${className}` : ""}`} aria-hidden="true">
<div className="iris-silkweftfield__floor absolute inset-0 [background:linear-gradient(_90deg,var(--color-accent-300)_0%,var(--color-accent-600)_28%,var(--color-accent-800)_58%,var(--color-accent-950)_100%_)]" />
<canvas ref={canvasRef} className="absolute inset-0 w-full h-full opacity-0 transition-opacity duration-[--duration-slow] ease-[--ease-standard] data-[shader=on]:opacity-100" />
</div>
);
}Custom work
Need one that isn't in the catalogue?
Describe what you're after and I'll reply by email — no promise on turnaround yet, this is a new channel, not a service with a set price or queue.
Fardin Omor Afnan
Reads and answers every request himself