0
\$\begingroup\$

My rendering pipeline goes something like this-

Bind multisampled FBO

Render GameObjects

Render Transparent Objects

Blit multisampled FBO to normal FBO

perform any Post processing

Render a quad with the result

Render GUI

I've found I can render transparent objects in the "Render transparent Objects" function, but alpha blending against the post processing quad doesn't work. Is there any reason why this would be? This draw call is used regardless of whether it is being rendered to the FBO, or to the screen buffer It is a button in particular I'm trying to render, here is the draw call:

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glFrontFace(GL_CW);

glUseProgram(thisConfig.guiShaders->getProgramID());

//Bind uniforms..... code skipped

glBindVertexArray(VAO);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);

glDrawArrays(GL_QUADS, 0, 4);

glFrontFace(GL_CCW);

Let me know if there is anything I need to provide to help. Again, same shaders are used in both cases, so I don't think the shaders are the problem, but here they are anyway:

#version 330
uniform sampler2D textureImage;

// input packet

in packet{
    vec2 textureCoord;
} inputFragment;


// output packet
layout(location = 0) out vec4 fragmentColour;


void main(void) {

vec3 gamma = vec3(1.0 / 2.2);
vec4 tempFragmentColour = texture2D(textureImage,     inputFragment.textureCoord);
    fragmentColour = vec4(pow(tempFragmentColour.xyz, gamma),     tempFragmentColour.a);
//  fragmentColour = vec4(tempFragmentColour.a);

}

I have tried writing in the alpha values manually in the shaders and I get the same effect.

Working with OpenGL 4.6 on PC with c++

\$\endgroup\$
  • 1
    \$\begingroup\$ I don't know which platform you're working on, but usually, if you're rendering to multisample-enabled FBOs, you need to use multisample-enabled depth and stencil buffers. Likewise, if you're rendering to non-multisample-enabled color buffers (like the screen), you need to use non-multisample-enabled depth and stencil buffers. May I suggest you double check all your buffers are correctly setup? \$\endgroup\$ – Panda Pajama Apr 14 at 16:09
  • \$\begingroup\$ Sorry, will add to question I'm working with openGL 4.6 on PC. I'm fairly sure because I'm drawing straight to the screen, there are no buffers to tweak? How does one define what specs the screen buffer has? \$\endgroup\$ – Will Hain Apr 14 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.