Reputation: 43
I'm trying to get a blur working using a glsl shader. I have looked for it on the internet but found only found fragment shaders with a texture input. What if I want to blur things without a texture though? How would I do that?
Should look something like that:
Upvotes: 1
Views: 1169
Reputation: 72539
A shader cannot read from a framebuffer directly. Textures are the primary way for reading images from within a shader (there's also SSBO but I wouldn't suggest using it here).
Thus, put it short, the answer to "how to blur an image without a texture" is: create a texture! You can either copy your image from the framebuffer to the texture with glCopyTextureSubImage2D
; or, even better, render to an off-screen FBO backed by the texture from the start.
EDIT: example of copying from current framebuffer to a texture (in C):
GLuint tex;
glCreateTextures(GL_TEXTURE_2D, 1, &tex);
glTextureStorage2D(tex, 1 /*levels*/, GL_SRGB8_ALPHA8, width, height);
glCopyTextureSubImage2D(tex, 0, 0, 0, 0, 0, width, height);
// tex now contains the content of framebuffer
Upvotes: 2