Grow a Snowflake
A snow crystal grows live on the GPU from a hexagonal prism by the Gravner-Griffeath vapour model, its arms recording every change of temperature and humidity on the Nakaya diagram, rendered as backlit ice. Steer the conditions, speed and zoom.
Made in Claude Code (Claude subscription) with claude-opus-5.5. The agent wrote code, looked at the preview and fixed it over several iterations. This is not a single-shot result: comparisons on this site show models in one attempt.
Starting prompt
Build "Grow a Snowflake": a real-time simulation of a snow crystal growing as it falls through a cloud, rendered to look like real snow-crystal macro photography: one crystal of clear ice, backlit on a dark blue background. Every shape emerges from the physics; nothing is drawn. Single self-contained HTML file using WebGL2 (raw, or Three.js r170 from a CDN via an import map); everything procedural, no external images or textures. The physics, the heart of the piece: - Grow the crystal on the GPU on a hexagonal lattice of about 512 × 512 cells (axial coordinates, float ping-pong render targets) with the Gravner–Griffeath model. Each cell holds an attached flag, boundary (quasi-liquid) mass, crystal mass and diffusing vapour. Each step the vapour diffuses (the average of the cell and its six neighbours, reflected at the crystal), freezes into boundary cells, attaches by thresholds that depend on how many crystal neighbours a cell has (tips and facets need far more mass than kinks) and partly melts back. When the humidity changes, rescale the whole vapour field to the new far-field density, so the change reaches the crystal at once. - Start from a small hexagonal prism. The six arms, side branches, plates, sectors, ridges and ribbing must emerge from the diffusion-limited instability on their own, and all six arms share one history. - Temperature and humidity set the parameters as in the Nakaya diagram (excess vapour density over ice, 0 to 0.30 g/m³, with the water-saturation line): thin plates near −2 °C; needles and columns around −5 °C, where growth in the plane stalls and the crystal thickens; plates again near −10 °C, sectored at high humidity; stellar and fern-like dendrites near −15 °C at high humidity; plates and columns below about −22 °C. Temperature mainly sets the tip and facet attachment threshold and the thickening rate (near −5 °C the prism faces hardly keep the molecules that land on them); humidity sets the far-field vapour. - Record in every cell when it froze and how thick the growing edge was at that moment, so each change of conditions is written into the arms as a ridge, a terrace or a plate. That is why no two crystals are alike. - Scale: a cell is about 7 µm; a finished crystal about 3 mm across. The look, like the best snow-crystal photographs: - Treat the ice as a thick transparent slab whose thickness comes from the simulation: cells that froze as advancing tips leave the central ridges and the ribbing (keep only straight tracks along the lattice axes), the recorded edge thickness gives nested growth outlines, a cell closed in on all sides traps a tiny air bubble, and the centre is a hollow hexagon. Interpolate the lattice into a smooth field so edges stay crisp at every zoom. - Shade it as backlit glass: refraction of the background, dark-field lighting so that tilted surfaces catch off-axis lamps, one warm and one cool (bright rims, glassy ridges, paired bright and dark lines along every edge), faint thin-film rainbow fringes in the thin hollow centre, and tiny glints travelling along the edges. - A near-black deep blue background with a soft glow behind the crystal and faint out-of-focus bokeh. Clear plates, darker refracted edges, crisp white-to-ice-blue rims. A slow camera drift (pan, rotation and a slight tilt) with gentle depth of field. Subtle bloom only on the glints and rims; ACES filmic tone mapping and sRGB output. Never muddy, never washed out. The film runs by itself and loops forever: - The very first frame already shows a partly grown crystal (a young star whose six arms have just begun to branch) filling the frame. By 8 seconds it is a clear, beautiful six-armed star. - Over about 45 seconds it grows while the conditions drift: a sectored centre, branching near −15 °C, a short spell near −12 °C that grows plates at the tips, then rich fern-like branching just above water saturation. The result is a large fern-like stellar dendrite whose sectors and side plates record its history. The camera pulls back as it grows, and the slider handles move with the conditions. - It holds the finished crystal for a few seconds, then dissolves with a focus pull into the next one, already grown in the background along a different path. - Any input takes over. After about 20 seconds without input the film resumes smoothly. Interface (a compact, elegant glass panel with readable values and units, thumb-sized on a phone): - Sliders for temperature (−25 to −1 °C) and humidity; growth speed buttons for pause, 1×, 4× and 16×; a New crystal button. - Zoom from the whole crystal down to the fine branch tips at high magnification with the mouse wheel, pinch, and + / − buttons; drag to pan. A live scale bar in mm and µm. - A small live Nakaya diagram with its regions, the water-saturation line, a dot for the current conditions and the path this crystal has taken; click or drag on it to set both conditions. - One line of physics at a time in a small caption. A tiny hint lists the keyboard shortcuts. - Every change is eased; nothing jumps. It works on a phone, with pinch zoom on the canvas that does not zoom the page. Engineering rules (the page must work on the first load, with no fixes): - Use WebGL2 with float render targets (check EXT_color_buffer_float). Declare every uniform, constant and varying the shaders use, and check every shader compile and framebuffer. - Drive everything by wall-clock time. Run as many simulation steps per frame as the frame budget allows, warm up the shaders and pre-grow the first crystal before the first frame, and allocate nothing per frame. - Declare each identifier once. Guard every animated value against NaN. - The page runs in a sandboxed iframe: no storage, dialogs, navigation, pointer lock or fullscreen. - Answer with the complete file exactly once, in a single ```html code block: no drafts, partial snippets or notes. Keep planning brief and write the code. Aim for roughly 900 to 1,300 lines, compact and well structured.