Grain Gradient Field

group .........
3D and WebGL scenes

── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────

A section background where the grain lives inside the gradient instead of on top of it. A raymarched signed-distance shape is flat-shaded by one key light, smeared twice by noise-steered blur at quarter and half resolution, warped by a slow standing wave, dragged by a decaying pointer trail, and finally scattered by 24 random taps per pixel. Because that last pass samples the frame rather than overlaying a texture, the grain thickens where the image has contrast and disappears where it is flat, which is the tell no noise PNG can fake. Seven WebGL2 passes plus a ping-pong trail buffer, all eight shaders reproduced byte-for-byte, and every knob art-directable.

── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────

  • * The grain is a pass, not an overlay

    The final shader takes 24 random taps of the frame it just rendered and averages them. Because it samples the image rather than adding a texture, the scatter concentrates where there is contrast and disappears across flat ground, so the grain belongs to the gradient instead of sitting on it.

  • * The two blur passes run at different resolutions on purpose

    The first noise smear renders at a quarter of the canvas and the second at a half, so a 32-tap blur reaches across the whole frame for the cost of a small one. Running both at full size is slower AND tighter, which reads as a different picture.

  • * Nothing loops; only two clocks move

    Four of the six layers hold their clock at zero forever. The shape never rotates and the grain pattern never crawls; only the noise smear and the standing wave advance, which is why the field drifts instead of animating.

  • * Time is counted in frames, not seconds

    Each animating layer advances by a fixed step per rendered frame behind a 30fps gate, never by wall-clock delta. Swapping in a delta-based clock makes the drift speed depend on the display's refresh rate.

  • * The trail is stored as hue and value

    A ping-pong buffer writes pointer direction into hue and speed into value, decaying every frame. The pass above it converts that back into a displacement, which is how the field keeps bending for a moment after the cursor has gone.

  • * The scene has a fixed aspect and the box does not

    The field is drawn at a 1440x1800 ratio and anchored to the container's top-left corner, so the lit shape holds its proportions through a reflow instead of stretching with the section.