Home

Awesome

BufferSorter

This is a very simple tool for in-place sorting of ComputeBuffers of ints or uints on the GPU, meant for use in Unity. I wrote this to use with a basic GPU particle system I'm working on, which needs to always be sorted consistently between frames.

This is based on the great work of nobnak, available here. I simply wanted to make it a little more user friendly for my own needs. The fundamental sorting algorithm is their own work.

My additions are:

How to Use

Like this:

image

It couldn't be simpler, really. Reverse, sublist length, and sort key buffer are optional parameters.

The project included is Unity version 2020.3.0f1, but there's nothing in the project other than the C# file and compute shader (as well as some unit tests in a demo script), and nothing especially version dependent. Just copy the scripts and meta files over and you're good to go.