- I draw a triangle to a Multisample Texture without blending.
- Then i draw another triangle to the same buffer with alpha blending.
- Then i extract only subsample 0 to my final image
- In the results it looks like the subsamples are not blended together independently (see the undesired anti-aliasing for each subsample in the following images)
Is this expected behavior? Isn't it said in the documentation that blending should be done independently for every sample?!
I have a GeForce GTX 560 and use the newester driver (301.42) (tried it before with a 29x.xx version)
Edit: Tried it with a Radeon Card and there the blending is correctly done sample-independently.
Does this seem to be a Driver-Bug or is it more likely, that i introduced undefined behaviour anywhere (the provided code that follows this post is almost the whole program code)
(My Code is embeded in a freeglut project using glew with an 4.2 compatibility context)
Initialization of the Framebuffer:
Code :glGenFramebuffers(1,&fbo); glGenTextures(1, &texMS); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE,texMS); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2 ,GL_RGBA, windowWidth, windowHeight,true); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, texMS,0);
Drawing of Geometry
Code :glEnable(GL_MULTISAMPLE); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glDrawBuffer(GL_COLOR_ATTACHMENT0); glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1,1,-1,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glUseProgram(0); glBegin(GL_TRIANGLES); glColor4f(0.0,0.0,1.0,0.5); glVertex2f(-1.0,-1.0); glColor4f(0.0,1.0,1.0,0.5); glVertex2f(1.0,-0.7); glColor4f(1.0,1.0,1.0,0.5); glVertex2f(0.5,1.0); glEnd(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0.1,0.05,0.0); glUseProgram(0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_TRIANGLES); glColor4f(1.0,0.0,0.0,0.5); glVertex2f(-1.0,-1.0); glColor4f(1.0,1.0,0.0,0.5); glVertex2f(1.0,-0.7); glColor4f(1.0,0.0,1.0,0.5); glVertex2f(0.5,1.0); glEnd(); glDisable(GL_BLEND);
Fragment Shader that extracts sample 0 (drawn as a fullscreen quad)
Code :#version 330 out vec4 myPixelColor; uniform sampler2DMS tex; void main() { myPixelColor.rgb = texelFetch(tex, ivec2(gl_FragCoord.xy), 0).rgb; myPixelColor.a = 1.0; }
Am i missing something?



