I Tried Sorting Pixels
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
A deep dive into building a real-time pixel sorting shader for video games. Starting from the basics of GPU sorting with parallel bitonic merge sort, the author explains why naive approaches fail for image sorting, then develops a custom single-threaded GPU sorting approach using contrast masks and span detection. The post covers three levels of shader optimization: reducing memory bandwidth by 87.5% via pre-calculated sort values, leveraging group shared (local) memory to cut render time by ~90%, and imposing span length limits to cap worst-case performance. Despite these optimizations, the effect remains too slow for real-time gameplay but works well for photo modes. Visual results are demonstrated in Final Fantasy 14 with a stylized post-processing pipeline including dithering, bloom, and chromatic aberration.
Sort: