I wonder, if it would make sense to write a shader for (random )shuffling pixels that are already on the gpu or if it is better to shuffle the pixels on the cpu (like I am doing it now)…
std::shuffle(vector_data.begin(), vector_data.end(), rng);
for (int i = 0; i < xPieces * yPieces; i++) {
image_data.setColor(fmodf(i, xPieces), i / xPieces, ofFloatColor(fmodf(vector_data[i], xPieces) / xPieces, floor(vector_data[i] / xPieces) / yPieces, 0));
}
Hey @Jona setting the pixels in image_data could definitely be done with a shader. I’d vote for using the loop in this case. The loop is:
simple (the per-pixel calculation is not super intensive),
independent (only 1 texture and no shader chain),
runs intermittently (not every cycle).
But a shader becomes more interesting to me if any of these change, or if the cpu is busy with other stuff (a noticeable drop in frame rate) when this loop is trying to run.