I'm trying to render my trees to an FBO to use as an impostor. I've got it working pretty well now, except that my leaves are ending up with nasty semi-transparent borders around them similar to what I saw rendering them directly to the screen before I found the right blending options. Here are comparison screenshots:
Bad
Good
The bad one is when I render to FBO, the good one is direct to the screen. As you can see instead of being completely opaque or completely transparent, the bad one has translucent parts that would need to be blended (which would be a nightmare). I'm using these calls to set up the alpha testing:
glAlphaFunc(GL_GREATER, 0.5);
glEnable(GL_ALPHA_TEST);
glBlendFunc(GL_ONE, GL_ZERO);
Since it works when I render without the FBO, is there something else I need to be doing when I'm setting up the FBO? Currently it looks like this:
glGenFramebuffersEXT(1, &impostorfbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, impostorfbo);
glGenRenderbuffersEXT(1, &depthbuffer);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, 512, 512);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer);
glGenTextures(1, &imptex);
glBindTexture(GL_TEXTURE_2D, imptex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, imptex, 0);
if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT)
cout << "Failed to create framebuffer in WorldObjects.\n" << glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) << endl;
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
and then simply binding it with glBindFramebufferEXT before rendering. Am I missing something here? Is it possibly just a driver bug? I'm stumped and this is sort of a major problem since it's bad to have a largely opaque group of leaves go partially transparent when it switches to the impostor.
TIA for any help.