Can I use FBO blitting https://www.opengl.org/registry/specs/EXT/framebuffer_blit.txt , to pass rendered FBO, as texture, to my resolve shader input?
Can I use FBO as input for shader "sampler2D"?
I mean, I render something to fbo. Now I want to post-process image, can I pass FBO as texture to shader?
You don't "pass FBO as texture".
What happens instead is that you create a FBO using textures as attachments (notably, to the color attachments); then you can draw normally (to the default FBO target, usually the screen) using the contents of such texture.
For typical full-screen post processing effects one usually draws a fullscreen quad, but of course you're pretty much limited to your own imagination (for instance you could draw the FBO contents on the mesh of a TV set, to simulate a live camera). At the same time, you could perform any kind of postprocessing in the fragment shader.
So, the simplest plan possible is:
GL_COLOR_ATTACHMENT0
) via glFramebufferTexture2D
Then
sampler2D
uniform in your shader programNote that the operations performed above are not what's meant for "framebuffer blitting". Blitting stands for the capability of copying a subrectangle of a FBO into a subrectangle of another FBO (of course, you can just blit the entire area). The FBO involved here may include the default FBO (i.e. the screen). There are no ways of performing post-processing via a blit, since there are no shaders involved.
Blitting is mostly useful in a specific scenario: copying the contents of a multisampled FBO into a non-multisampled FBO, then using the latter to perform post processing or as a texture source. The reason for this is usage is mostly historical -- older GL versions (< 3.2) provided a way to create a multisampled FBO by attaching a multisampled color Renderbuffer, but no way to read the values back in a shader (a Renderbuffer is a buffer you can attach to FBOs, just like textures, but unlike a texture, you can't sample its contents). Therefore, one created two FBOs -- a multisampled one to perform the drawing, which would then resolved into a second non-multisampled FBO via a blit operation. This second FBO had a texture attached as the color attachment, and you then could sample from it.
These days (>= 3.2, or with GL_ARB_texture_multisample
) OpenGL offers a way to create multisampled textures, which are usable directly in shaders (via sampler2DMS
samplers). No blit step is necessary.