manu·martínez-almeida

Graphics

I Broke My Ankle, Then Rendered It in a Browser

· Manu Martínez-Almeida

In October 2019 I went out for drinks with friends in Kreuzberg, a few minutes from my office in Berlin. I broke my ankle that night. Everything I’d been building stopped at once, and for the first time in years I had nothing to ship.

Fourteen days to think

I spent fourteen days in a Kreuzberg hospital, waiting for the swelling to go down before they could operate. Once I calmed down, it wasn’t all bad. I read the books I’d been meaning to get to, reached out to people I’d lost touch with, designed a tattoo for the ankle, and learned enough German to order a coffee with milk and no sugar.

Mostly, it switched off the autopilot. I’d gone years without a single week away from code, and the quiet was the first chance I’d had to think about what I wanted to build next.

My data was mine, and I couldn’t reach it

The surgery worried me even after the doctors said it had gone well. I wanted a second opinion, and that meant getting my own scans out of the hospital. It turned into a small ordeal. I left with my medical imaging burned onto a CD, then ordered a USB CD reader from Amazon so I could open my own body on my own laptop.

The second opinion sent me straight back to Spain, where my family is. There were real problems: the joint spacing was off, there was nerve damage from the suture, an unrepaired tendon, and a screw sitting in the wrong place. A second surgery fixed it, and I finally found some calm.

Somewhere in that mess the product idea formed. Patients own their medical data. Reaching it, reading it, and sharing it is absurdly hard.

Visualizing my own ankle

With no deadlines left, I opened my laptop and went back to something I hadn’t touched in years: writing rendering code from scratch, the way I used to build game engines. I wanted to see my own scan in 3D, in a browser, with nothing to install. The first time my ankle rotated on screen, rendered from the CD I’d fought to get, I knew this was the thing I wanted to work on.

Rendering gigabytes of voxels in a browser

A CT scan is a 3D grid of density samples, often hundreds of slices deep, which adds up to gigabytes. You can’t download all of it before drawing anything, and you can’t fit all of it in GPU memory. Yet a radiologist expects to spin and re-window the volume with no lag.

The rendering itself is ray casting through a 3D texture. For each pixel on screen, march a ray into the volume, sample density along the way, map each sample to color and opacity, and composite front to back until the pixel goes opaque.

// simplified: march a ray through the CT volume and accumulate color + opacity
vec4 raymarch(vec3 origin, vec3 dir) {
  vec4 acc = vec4(0.0);
  for (int i = 0; i < STEPS; i++) {
    vec3 p = origin + dir * (float(i) * stepSize);
    float density = texture(volume, p).r;    // sample one voxel
    vec4 s = transfer(density);              // density -> color + alpha
    acc.rgb += (1.0 - acc.a) * s.a * s.rgb;  // front-to-back compositing
    acc.a   += (1.0 - acc.a) * s.a;
    if (acc.a > 0.99) break;                 // early ray termination
  }
  return acc;
}

Three decisions made it run in real time on WebGL. We split each volume into smaller blocks, so the GPU only ever held the parts in view and could skip the empty space between them. We quantized the data, including the normal vectors used for shading, to shrink what had to live in texture memory. And we loaded progressively, coarse first and detail as you leaned in, so the first frame appeared fast even on a multi-gigabyte study.

Keeping the data safe by never seeing it

Medical data raises the stakes on security, so we ran end-to-end encryption on the client. A scan never left the device in the clear, which meant we couldn’t read it, and that was the point. The data we never held unencrypted is data we could never leak. That one decision collapsed a large amount of compliance and liability surface into something we could reason about.

What it became

Sethealth shipped as an SDK and a compliant backend across iOS, Android, and the web, and it ran until 2026. The use case that clicked was custom prosthetics. A doctor could shape an implant against a patient’s real anatomy, an engineer could validate it, and the two could hold a precise conversation inside the same 3D view, all running on our SDK.

I built it on a simple conviction. Healthcare carries more weight than most software, and patients are the rightful owners of their data even when the system makes that ownership painful to exercise. Sethealth was my bottom-up attempt to hand some of that ownership back.

The deeper lesson came from the ankle. For years I never went a week without coding, and I’d mistaken motion for progress. Stepping back to ask why, and not only how, paid off more than any sprint I can remember. You don’t need to break a bone to get there. Close the laptop for a week and notice which idea refuses to leave you alone.

← All writing