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 6 of 6

Thread: accumulation buffer - antialiasing

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    7

    accumulation buffer - antialiasing

    hello together,

    i use the accumulation buffer to get antialiasing for my scene.
    but i feel like i doesnt work.

    here is my code so far, for the antialiased part,
    Code :
    	glClear(GL_ACCUM_BUFFER_BIT);
    	for(unsigned int i = 0; i < 10; i++) {
    		for(unsigned int j = 0; i < 10; i++) {
    			glClear(GL_DEPTH_BUFFER_BIT);
    			glTranslatef((i * 0.002f) - 0.002f, (j * 0.002f) - 0.002f, 0.0f);
     
    	glBindTexture(GL_TEXTURE_2D, space_box);									// bind space box texture
    	glBegin(GL_QUADS);
    		glNormal3f(0.0f, 0.0f, 1.0f);											// space box front; normal vector
    		glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.5f, -0.5f,  0.5f);
    		glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.5f, -0.5f,  0.5f);
    		glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.5f,  0.5f,  0.5f);
    		glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.5f,  0.5f,  0.5f);
     
    		/*glNormal3f(0.0f, 0.0f, -1.0f);											// space box back; normal vector
    		glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, -0.5f, -0.5f);
    		glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f,  0.5f, -0.5f);
    		glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f,  0.5f, -0.5f);
    		glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, -0.5f);
     
    		glNormal3f(0.0f, 1.0f, 0.0f);											// space box top; normal vector
    		glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.5f,  0.5f, -0.5f);
    		glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.5f,  0.5f, -0.5f);
    		glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.5f,  0.5f,  0.5f);
    		glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.5f,  0.5f,  0.5f);
     
    		glNormal3f(0.0f, -1.0f, 0.0f);											// space box bottom; normal vector
    		glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.5f, -0.5f,  0.5f);	
    		glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.5f, -0.5f,  0.5f);
    		glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.5f, -0.5f, -0.5f);
    		glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.5f, -0.5f, -0.5f);
     
    		glNormal3f(1.0f, 0.0f, 0.0f);											// space box right; normal vector
    		glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, -0.5f,  0.5f);
    		glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f,  0.5f,  0.5f);
    		glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.5f,  0.5f, -0.5f);
    		glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.5f, -0.5f, -0.5f);
     
    		glNormal3f(-1.0f, 0.0f, 0.0f);											// space box left; normal vector
            glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f,  0.5f);
            glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.5f, -0.5f, -0.5f);
            glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.5f,  0.5f, -0.5f);
            glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f,  0.5f,  0.5f);*/
    	glEnd();
     
    			glTranslatef(-((i * 0.002f) - 0.002f), -((j * 0.002f) - 0.002f), 0.0f);
    			glAccum(GL_ACCUM, 1.0f / 100);
    		}
    	}
    	glAccum(GL_RETURN, 1.0f);

    how u can see, id draw one quad inside it.
    and here a pic of how it looks like,
    http://s1.directupload.net/file/d/2995/yg2m58l5_jpg.htm

    i hope u can help me and tell me what i did wrong, thanks.

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    355
    How did you choose 0.002f? You should cover the whole pixel, not a 1/20th part of it.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    7
    It were just a test - value. Id read I have to cover just a part of a pixel.

    So, U mean.. it should work 100% with 0.04f?

  4. #4
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    355
    Ehm.. wait I was wrong. With +1 you are moving one unit away, so the whole screen in your case.. Not good.

    You should cover a whole pixel in screen space, so the offset depend on viewport and distance.
    I never tried cause it's an old technique but you should modify the W coordinate to achieve a correct result.

    Also use better sampling, regular grid give other types of aliasing.

    Bwt, with cheap video card with 1GiB of memory why don't you use supersampling? or better technique? Just go on video panel and enable FXAA.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    7
    Ah ok, thanks ... it were just a test for me, actuall Im using msaa, GL_MULTISAMPLE.
    Maybe I can use later for some blurring.

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    Quote Originally Posted by Rosario Leonardi View Post
    Bwt, with cheap video card with 1GiB of memory why don't you use supersampling? or better technique? Just go on video panel and enable FXAA.
    Or better yet, do it via GL
    http://www.opengl.org/wiki/Multisampling
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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