Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Sample Independent Blending onto Multisampled Framebuffer

  1. #1
    Junior Member Newbie Kastenfrosch2's Avatar
    Join Date
    May 2012
    Location
    Germany
    Posts
    15

    Sample Independent Blending onto Multisampled Framebuffer

    • 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)


    Click image for larger version. 

Name:	RaffIchNed.jpg 
Views:	135 
Size:	10.5 KB 
ID:	865

    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?
    Last edited by Kastenfrosch2; 09-05-2012 at 03:50 AM. Reason: Added additional Information

  2. #2
    Junior Member Newbie Kastenfrosch2's Avatar
    Join Date
    May 2012
    Location
    Germany
    Posts
    15
    OK, i tried the NVidia 306.02 Beta Driver and my minimal-Example (that i posted above) now works.
    So i guess it's just a Bug in the NVidia drivers.

    However if i change the Multisample-Texture's internal format to SRGB8_ALPHA8, the bug still persists.
    Strange....
    Last edited by Kastenfrosch2; 09-05-2012 at 05:59 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •