Facet & Filament ← Back to site
The making-of

A diamond, raymarched.

How a single fragment shader turns a slab of black velvet into a slowly-rotating, dispersion-throwing gem — and the art direction that frames it.

Palette
Type
Cormorant Garamond · Archivo
Stack
Three.js · GLSL · GSAP

The concept

The brief was "Light, set in stone." — a haute-jewelry house on the coast of Virginia. Jewelry photography lives or dies on one thing: how a stone eats light and gives it back as fire. So instead of photographing a diamond, we simulated one: a refractive gem rendered per-pixel, turning forever against near-black velvet.

Everything else defers to that. The palette is 60% near-black (#060607), 30% warm ivory ink, and a 10% split of champagne (#CFC7B4) and Chesapeake blue (#8FB6C9) — the two accent colours the shader also refracts. Cormorant Garamond carries the display voice (thin, optical, editorial); Archivo handles the quiet labels and body.

The signature technique

The hero is one full-screen triangle and one fragment shader — no gem geometry, no model file. The gem is defined mathematically as a signed distance field (SDF) and drawn by raymarching: for each pixel we shoot a ray and step it forward until it lands on the surface.

1 · Modelling the cut

A brilliant-cut diamond is close to an octahedron with a flattened top (the table) and a deep point (the pavilion). We start from an octahedron SDF and squash the vertical axis asymmetrically — sharp crown, deep pavilion — then slice a flat table with a plane and bevel the girdle:

float gemSDF(vec3 p){
  vec3 q = p;
  q.y *= (q.y > 0.0) ? 1.35 : 0.72;   // sharp crown, deep pavilion
  float o = sdOcta(q, 1.0);
  float table = p.y - 0.34;            // flatten the top
  return max(o, table);
}

2 · Refraction & total internal reflection

At the hit point we compute the surface normal from the SDF gradient, then refract() the ray into the gem. A second short march finds where it exits, we refract again on the way out, and sample a tiny procedural environment (black velvet plus a handful of razor-sharp studio glints). When a ray can't escape the dense medium, refract() returns zero-length and we fall back to reflect() — that's real total internal reflection, the thing that makes a diamond sparkle rather than glow.

3 · Dispersion — the fire

White light splits because a gem's refractive index depends on wavelength. We fake it cheaply and convincingly by tracing three rays — one each for the R, G, and B channels — at slightly different IOR values, then recombining them. The tiny separation smears the spectrum across every facet edge, so the gem throws prismatic colour exactly where a real one does.

Why three rays, not thirty? A full spectral render would sample dozens of wavelengths. At 60fps on a laptop that's not free. Three well-placed channel offsets buy 90% of the perceived fire for a fraction of the cost — a classic real-time-graphics trade.

4 · Rotation, caustics & grade

The whole world (not the gem) rotates on u_time, with a soft mouse tilt layered in via u_mouse. A faint caustic wash drifts on the velvet beneath the stone. Finally a filmic tone-map, a warm/cool grade, a vignette, and a pinch of grain keep it from ever looking clinical.

Tools & why

Reusable takeaways

  1. Simulate the hero, don't photograph it. A procedural SDF gem is resolution-independent, weightless to ship, and impossible to source as stock.
  2. Dispersion on a budget. Three per-channel rays at offset IOR reads as full spectral fire. Spend detail where the eye looks — facet edges — not everywhere.
  3. Let the accent colours live in the shader. The champagne and Chesapeake-blue glints are the same two hex values as the UI accents, so the whole page feels cut from one stone.
  4. Always keep the loop honest. Pause rAF off-screen and on document.hidden, clamp DPR to 2, and render a single static frame for prefers-reduced-motion.
  5. Never ship a blank hero. WebGL creation is wrapped; if it fails, a CSS conic-gradient gem spins in its place so the page still opens beautifully.