Jing
Jing

Reputation: 1901

iPhone post-processing with a single FBO with Opengl ES 2.0?

I am trying to implement post-processing (blur, bloom, etc.) on the iPhone using OpenGL ES 2.0. I am running into some issues. When rendering during my second rendering step, I end up drawing a completely black quad to the screen instead of the scene (it appears that the texture data is missing) so I am wondering if the cause is using a single FBO. Is it incorrect to use a single FBO in the following fashion?

For the first pass (regular scene rendering),

For the second pass (post-processing),

Upvotes: 0

Views: 2982

Answers (2)

Brad Larson
Brad Larson

Reputation: 170309

As Matias states, your design looks fine. I've done something similar myself and had it work well.

I wrote a sample application which uses shaders to process camera images, which can be downloaded here, but that uses glReadPixels() to pull offscreen values into a processing routine rather than directly mapping the result to a texture onscreen. You might be able to modify it to do that.

Otherwise, I made a more complex shader sample application here that in one part renders a scene to a cube mapped texture, then feeds that texture into a second stage of processing. This should illustrate the rendering to, and use of, a texture with OpenGL ES 2.0 shaders.

Maybe these could shed light on where your implementation is failing.

Upvotes: 1

Dr. Snoopy
Dr. Snoopy

Reputation: 56347

No, that FBO usage is fine. The cause is very likely to be that you didn't set the MIN/MAG filters of your texture (texturebuffer), after binding, set the GL_MIN_FILTER and GL_MAG_FILTER to GL_NEAREST or GL_LINEAR using glTexParameter, and your texture should be working.

Upvotes: 1

Related Questions