ofShader: Apply shader more than once

Hello,

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!

hi,

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:

http://softwarecommunity.intel.com/articles/eng/3780.htm
http://www.gamasutra.com/features/20040526/james-01.shtml
http://gamasutra.com/features/20061003/kylmamaa-01.shtml

Cheers,
P.

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:

http://forum.openframeworks.cc/t/render-to-texture/371/0