For performance reasons I have separated my 2D and 3D rendering. I have two QGLFramebufferObjects for each type because QGLFramebuffer does not support multisampling with GL_TEXTURE_2D
as a target, so once drawing is done into the multisampled buffer, it is blitted into a 'normal' QGLFramebufferObject where the pixel values are resolved. Once this has been done for one/both of the render types, the buffers are used as texture inputs to a shader that blends the 2D 'layer' onto the 3D one.
I should mention that I'm locked into using QGLFramebufferObjects instead of pure OpenGL objects because I use QPainter for all 2D work, and QPainter can only paint onto Qt types.
This process works fine, except the anti-aliasing is too dark, it almost looks like a dark outline:
After doing some research I discovered this was down to using linear colour space instead sRGB (here and here). So I enabled GL_FRAMEBUFFER_SRGB
for my FBO blitting, set the texture target internal type for my all FBOs to GL_SRGB8_ALPHA8
, and performed sRGB->Linear before the blending calculations in my shader (and back again before the final output).
But it is isn't working; it either looks too bright, too dark, or exactly the same. Whenever the whole frame is too dark/light, I know it's because I've missed a colour-space conversion. But when it looks exactly the same - what is going on!?
I could really do with someone explaining the order of operations for enabling the GL_FRAMEBUFFER_SRGB
state, if blitting will affect the colour space, and which FBOs need to be in sRGB for the anti-aliasing to look correct. Or am I totally wrong, and is it something else entirely that is causing these multisampling artifacts?