ofShader: Apply shader more than once


I am currently experimenting with image post processing shaders such as blur and sharpen.- Anyways since most of the time the shader itself uses a standard 3x3 Kernel I was wondering what is the best way to apply a shader more than once. Do I have to save every step into another texture and run it over and over again? that doest not really seem to be efficient to me.

Thanks in advance!


What you’re looking for is usually called “ping-ponging” of texture targets. In this process you keep a pair of textures, one for reading and the other for writing, and you swap them at each render pass.

For an added performance boost, you should also look into using a separable convolution kernel. Although geared towards directx, the following links should help you get on your way:



thank you. I allready thought abut that but my mainproblem right now is that I propapbly cant stick with ofTexture class since I can only access the pixels modified by the shader using ofTextures loadScreenData method.

For this sort of application your best bet is to use an FBO texture target for rendering. See this thread for some helpful code that extends ofTexture: