FBO Blending

When I draw to the texture for my FBO, it won’t show textures behind the top texture. I read that GL_DEPTH_TEST is related to this. I tried that, but then I only was drawing the clear bit. I’ve actually already done a lot of research on this, and I’m still not finding the answer.

FBO setup:


	public void createMiniMap()
	{
	     final int WIDTH = 1600;	   
        final int HEIGHT = 900;
		
		  //frame buffer
		   int fbo;
		   int depthbuffer;
		   
	     //frame buffer
	      fbo = glGenFramebuffersEXT();
	      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
	      
	      //depth buffer
	      depthbuffer = glGenRenderbuffersEXT();
	      glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer);
	      
	      //allocate space for the renderbuffer
	      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, WIDTH, HEIGHT);
	      
	      //attach depth buffer to fbo
	      glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer);
	      
	      //create texture to render to
	      miniMapTexture = glGenTextures();
	      glBindTexture(GL_TEXTURE_2D, miniMapTexture);
	      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	      glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, (java.nio.ByteBuffer)null);
	      
	      //attach texture to the fbo
	      glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, miniMapTexture, 0);
	      
	      //check completeness
	      if(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT){
	         System.out.println("Frame buffer created sucessfully.");
	      }
	      else
	         System.out.println("An error occured creating the frame buffer.");
	      
	      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
	      
	      drawMM();
	      
	      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
	}

draw call:


public void drawMM()
		{
		    glEnable(GL_TEXTURE_2D);
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			<a bunch of draw calls not likely the issue>
}

This same drawCall in regular drawing works just fine. Blending is happy. On the FBO it will only ever draw the top texture. Can anyone help?

Other resources I found interesting FWIW:
Fixing saturation with additive blending by faking HDR
glBlendFunc
FBO and Blending

You’ll need to describe your problem better. Show us some screenshots of the problem and most important of all tell us exactly what result you’re expecting.

When I draw to the texture for my FBO, I want it to draw the textures behind the top texture. All I’m getting is the top-most texture.

If you have a map with no Fog of War, there is no blending needed and you can’t tell there is a problem. If you have a map with Fog of War, that FOW has opacity and you can see that it only keeps the top texture.

The FoW patches are basically a black oval with a solid center and the edges fade to nothing. Green is regular map. All the blue and brown under the black stuff isn’t supposed to show. All that blue and brown is from stuff drawing underneath the created FBO texture.

If the blending was just busted, the blue and brown would be green. This seems to only be keeping the top-most texture when I draw to my FBO texture.

I figured it out! ;D ;D ;D Thanks to this answer here.

I have blending on in the draw to the FBO texture. I then have blending on in the place where that texture is called to be drawn for display. I have to do glDisable(GL_BLEND) before I draw this texture and it behaves how I wanted. As that post explains, there are different blends happening with undesired computations.