跳到正文
网页珍奇柜Web Curio

GPU 实时像素排序

BitonicPixelSorter on WebGPU,Noboru Seto (ruccho),2020 年

正在布展…

本柜的现场复刻:按原作的技术思路从零编写,不含原作的代码和素材。原作请点上方「去看原作」。

它是怎么做的

  1. 第 1 步按亮度阈值把每一行切成若干“区间”
  2. 第 2 步在计算着色器中用双调排序网络对每个区间排序
  3. 第 3 步双调排序的每个比较-交换阶段都可大规模并行
  4. 第 4 步排序方向和阈值可调,生成不同的拉丝效果

复刻配方

一段技术配方,可以直接交给 AI 编程助手,也可以自己照着写。想指定技术栈、位置和性能预算,就把它加入实现方案。

For each row of the image, mark span boundaries wherever luminance crosses a lower or upper threshold, so only mid-brightness runs get sorted. Load each row into workgroup shared memory in a compute shader and run a bitonic sorting network over it, comparing keys only within the same span (using span id as the high bits of the sort key). Write the sorted pixels back and repeat per frame for video input. Expose threshold and sort direction (rotate the image before and after) as controls.

档案

技术

能不能拿来用

原作以 MIT 许可开源:可以阅读源码学习,按许可证条款使用;在自己的项目里引用时保留原作者署名。

性能开销

视觉强度

实现难度

尺度为策展判断(1 到 5),用于比较和推荐。

核实记录:Demo loads (title 'BitonicPixelSorter on WebGPU'); repo has MIT licence (core is a Unity package, demo is its WebGPU port).