I am doing a two-pass blur into a framebuffer object. To make sure that in the FBO, the whole scene is covered with the image I am trying to blur. Here is the process.
- I have setup an
FBOwith the dimensions of the image I need to blur. I am setting up an
Orthographic Projectionusing the following function (called assetupOrtho(FBO's dimensions)):glViewport(0, 0, w, h) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0,1,0,1,-1,1) glMatrixMode(GL_MODELVIEW) glLoadIdentity()
- Draw to the
FBO, using this projection. Unbind theFBO(back to the screen). - Switch to the
Perspective Viewby callingsetupPerspective(window's dimensions)and replacing theglOrthoabove withglFrustum.
If I draw simple white quads, the view switching works as expected. One quad is drawing in Orthographic Projection and other in a Perspective View. Now take the rendered texture from the FBO (let id be RENDEREDTEXTURE).
If I bind the RENDEREDTEXTURE in an Orthographic Projection in my main scene, it shows the blurred Image. If I bind it into the Perspective View in my main scene, the previously visible white quad (which was drawn in the Perspective View) disappears.
SOLUTION: Posted as an answer.
NOTE : Never forget MIPMAP generation when using textures.
What could be the issue here?
Please suggest any alternative means such that in the FBO, only the image I want to process on is visible (for which I did the orthographic projection), and in the main scene, the processed image is just like any other texture loaded from an image file.
setupPerspective. Anyway, you could run your program trough gDEBugger and verify that indeed all the required state (matrices, FBO) are set back to the desired values before you render with perspective again. - Bartek BanachewiczViewmatrices. I usedsetupOrthoandsetupPerspective, and drew two quads. They were drawn as expected. When I bind the rendered texture into a quad in orthographic projection, it is shown with the blur I expected. But after switching to perspective matrix, without texture quad is drawn, but disappears if I bind the texture. What could be the problem here? - activatedgeek