Hi,
I use framebuffer object to build a blurred shadow texture, using 2 fragment shaders(one for horizontal blur and one for vertical blur).
The first time I build the blurred texture, it is good.
But when I re-build the texture a second time, I get a crack in the texture (see top right corner of the attached file).
If I don’t use the framebuffer objects, but instead read the texture from the color buffer with a glTexImage2D the texture is always fine, so the problem should be the framebuffer object.
Any ideas on where could be the problem?
Maybe I’m doing something wrong with the framebuffers?
This is my (simplified) code:
fbo = gl.GenFramebuffersEXT();
gl.BindFramebufferEXT(gl.FRAMEBUFFER_EXT, fbo);
gl.FramebufferTexture2DEXT(gl.FRAMEBUFFER_EXT, gl.COLOR_ATTACHMENT0_EXT, gl.TEXTURE_2D, sharpTextureName, 0);
DrawShadow(...); // draw the geometry on the sharp texture
gl.FramebufferTexture2DEXT(gl.FRAMEBUFFER_EXT, gl.COLOR_ATTACHMENT0_EXT, gl.TEXTURE_2D, blurredTextureName, 0);
// activates texture ID zero
gl.ActiveTexture(gl.TEXTURE0);
// source texture for the shader (1st pass)
gl.BindTexture(gl.TEXTURE_2D, sharpTextureName);
gl.UseProgram(horizontalShaderProgram);
DrawQuad(...); // draw a quad with the sharp texture, to do the horizontal blur
//source texture for the shader (2nd pass)
gl.BindTexture(gl.TEXTURE_2D, blurredTextureName);
gl.UseProgram(verticalShaderProgram);
DrawQuad(...); // draw a quad with the previous texture to do the vertical blur
gl.UseProgram(0);
// rendering is directed back to original buffer
gl.BindFramebufferEXT(gl.FRAMEBUFFER_EXT, 0);
gl.DeleteFramebuffersEXT(fbo); // destroys FBO