39
←→

Upgrading pixel sorts and flow fields

Pixel sorting in Fragments now uses bitonic sorting, converges in a single frame, and sorts video — plus flow fields (finally) render as lit 3D mesh particles.

Loading...
←Blurs, distortion effects, and image adjustments
←

Ready to start learning?

What's included in the course ↓

Access to the course: master shader techniques, use workflow-enhancing utilities, learn from shader breakdowns with full code, and get downloadable R3F and vanilla projects.

One single payment. No subscription required. 30-day money-back guarantee. No questions asked.

Not sure which to pick? Most people choose Pro for the full collection and all future updates. Fundamentals is a focused, lower-cost starting point you can upgrade from any time.

“Knowing shaders is your unreasonable advantage in UI. Ben has worked super hard on this course, recommended!”
Joshua Crowley - Designer and Educator
Loading...

Fragments

Learn creative coding with shaders. For design engineers, creative coders and shader artists: techniques, tools, deep dives. Powered by ThreeJS and TSL.

New techniques, breakdowns and shader experiments — straight to your inbox.

2026 Phobon

phobon.ioShadercraft

Pages

HomeTechniquesUtilitiesBreakdownsWorksWriting

Contact

X @thenoumenonhey@fragments.supplyOKAY DEV @phobon
All rights reserved.
Curriculum
Works171
Writing39

Two favourites just got an upgrade

Pixel sorting and flow fields are two of the most popular techniques in Fragments — and two of the ones I get asked about most. Thanks to the awesome work of the Three.js team, both just got huge upgrades under the hood.

I've always loved the extreme, glitchy looks you can get with pixel sorting — particularly when it comes to animation. The original sorter I made did the job, but it was both slow and limited to still images. This upgrade finally makes it practical, with a much faster bitonic sort algorithm and the ability to sort video frames independently.

For flow fields, the upgrade is a bit more subtle, but it's still a big deal. Previously, particles were always rendered as flat sprites — just camera-facing dots. Now you can render them as lit 3D geometry.

This means you can now create some really interesting, sculptural effects, where the particles have real form and can catch and reflect light.

Here's what changed, and why it's worth a look.

Pixel sorting is faster — and works on video

The original sorter did one comparison pass per frame, so a wide image took hundreds of frames to fully sort. It looked great as a slow crawl, but it wasn't practical for anything moving. Three things changed:

  • Bitonic sorting. A new sort mode that fully sorts a row in far fewer passes — around 36 instead of 256 for a 256-wide image. It gives the same look for a fraction of the work.
  • Single-frame convergence. The sorter can now finish an entire sort in one frame. Want the slow crawl back? Drop passesPerFrame to a small number and watch it settle in real time.
  • Media and video inputs. Feed it a photo or a live video and it sorts every frame independently — so a sorted clip actually plays back as a sorted clip.

Pixel sorting a video frame by frame

The full write-up, with code, lives in the pixel sorting technique.

Flow fields you can light

Flow field particles used to be sprites — flat, camera-facing dots. Lovely for glowing, painterly pieces, but a sprite can't catch light or point anywhere. That was mostly a limitation in Three.js and TSL, but it's now caught up.

Now there's a mesh mode:

  • Particles render as real 3D geometry — little metallic boxes or gems — one instance each.
  • Each one orients along the flow and stretches with speed, so fast particles read as sharp shards.
  • They're physically lit, with metalness and roughness, so you get proper highlights and reflections instead of flat colour.
  • Sprites are still the default, so nothing you've already made will change.

From here you can create some beautiful fields of particles. I've been heavily inspired by the work of Jaume Sanchez Elias (@thespite) here, and have had a lot of fun trying to capture some of his style:

Flow field particles rendered as lit 3D meshes

Details and the full component are in the flow field technique.

Why this matters

Both of these started as nice to have experiments and turned into things I now use all the time. Faster pixel sorting means you can treat it as a live effect, not a render-and-wait. Lit mesh particles push flow fields from 2D glow into something that feels physical and sculptural.

These are relatively small changes to the API, but big changes to what you can make. Both are live in Fragments now.

Get the course ↵
FundamentalsAccess to foundational shader techniques and utilities
  • ✓ 5 foundational long-form technique lessons
  • ✓ 7 fundamentals lessons
  • ✓ 24 foundational workflow enhancing utilities
  • ✓ 71 full shader breakdowns
  • ✓ Downloadable R3F and Vanilla projects
  • ✓ Access to community Discord
Get Fundamentals →$99USD
ProMost popularFull access to the entire Fragments collection. Includes all techniques, utilities, breakdowns and all future updates
  • ✓ 12 long-form technique lessons
  • ✓ 7 fundamentals lessons
  • ✓ 60 workflow enhancing utilities
  • ✓ 171+ full shader breakdowns
  • ✓ Downloadable R3F and Vanilla projects
  • ✓ Access to community Discord
Get Pro →$199USD
You'll be redirected to our secured payment platform and get instant access.