How to get started with realtime & fast pixel manipulation, shifting, randomizing,

Hi guys

I’m looking for some advice on how to get started with manipulating existing footage like a video or an image and throwing around pixels in real time (for lets say a vj set).
I’ve been using ofPixels a few times and I noticed that when I try to do a little bit more advanced stuff like Pixel Sorting or Pixel displacement, the framerate starts dropping very fast.
Then I figured I needed to go the shaders route, but since they process their pixels in parallel, I can’t seem to figure out how to do calculations which use each pixel’s neighbouring pixels.

Am I missing out on something? Or is the complexity of these pixel manipulations the reason why there aren’t many examples out there? :smiley:
Here’s an example of what I’m trying to accomplish: https://vimeo.com/58448692

Thanks!

Hi polyclick,

I haven’t needed to do this before with a shader specifically. But I thought the gaussian blur example must do this (examples/shaders/09_gaussianBlurFilter). And indeed it looks like it loads in the entire texture at the top:

uniform sampler2DRect tex0;

and then accesses various pixel neighbors to blur it together:

vec4 color;
color += 1.0 * texture(tex0, texCoordVarying + vec2(0.0, blurAmnt * 4.0));
color += 2.0 * texture(tex0, texCoordVarying + vec2(0.0, blurAmnt * 3.0));
color += 3.0 * texture(tex0, texCoordVarying + vec2(0.0, blurAmnt * 2.0));
color += 4.0 * texture(tex0, texCoordVarying + vec2(0.0, blurAmnt * 1.0));

Here is how the texture function is listed in the glsl documentation

gvec4 texture(gsampler2D sampler, vec2 P [, float bias])

Perhaps you can use the same technique for your application?