Jump to content
  • Advertisement
Sign in to follow this  

OpenGL blur a texture using accumulation buffer

This topic is 3671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I am new to opengl and working on "Blurring a texture using accumulation buffer". I need your help in doing the same. I have the following piece of code to display the BMP image: glEnable(GL_TEXTURE_2D); //enable texture after RTT glBindTexture(GL_TEXTURE_2D, conic_texture); //the texture RTT'ed glBegin(GL_QUADS); glTexCoord3f (0, 1, -1); glVertex3f (-1, -1, -1); glTexCoord3f (0, 0, -1); glVertex3f (-1,1 , -1); glTexCoord3f (1, 0, -1); glVertex3f (1, 1, -1); glTexCoord3f (1, 1, -1); glVertex3f (1, -1, -1); glEnd(); I understand that using LoadBMP(filename) i can get the texture data. i.e: AUX_RGBImageRec *TextureImage = NULL; if (TextureImage=LoadBMP(path)) { Status = TRUE; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX - 1, TextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data); } So we have texture data in TextureImage->data. Now how should i blur this data using accumulation buffer? Your help is really appreciated. Thanks Gangadhar

Share this post

Link to post
Share on other sites
The accumulation buffer is simple enough, renders x times, transport all x times the colorbuffer with a factor 1/x to the acummbuffer, when done return the accum buffer (set to colorbuffer), which now contains the x images blended together equally.
more fancy methods of blurring are of course up to you.
Just look up the related calls relating to glAccum, and you see that its not even a handfull.

Share this post

Link to post
Share on other sites
Hi Kincaid
Thanks for the response. As per your email, I understand how i need to use accumulation buffer and blur a particular geometry. i.e:
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearAccum(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i < 360; i++){
glColor3f(1.0, 1 - (float)i / 180, 1 - (float)i / 360);
glTranslatef(0, -6, -10);
glRotatef(i,0, 1, 0);
glAccum(GL_ACCUM, 0.01);
glAccum(GL_RETURN, 1.0) ;

Here i am creating a teapot and blurring the same.
But consider a case where i have an input image (bmp/jpg) and then i want to use accumulation buffer to blur it. I have the texture->data for the image. I dont know how to use accumulation buffer over this texture->data in Opengl.

Let me know
Thank You in advance.

Share this post

Link to post
Share on other sites
not sure if this is what you mean, but youre having trouble with how to distort the images ?
to blur one image render it x times, BUT, each time place a little different.
how to offset is up to you:
e.g. depth of field blur: simple case: focus is center screen, more outside, more blur, so you distort each image by randomly 'twisting' the camera a bit, but with all images the same focus point.
for just an overal vlue, ofset each rendering a few units in either direction

etc etc.

in simple code something like
render image
translate (random(x,y))
render image
translate (random(x,y))

and render pertains to anything, if you want a texture, render a texutred quad to the screen and blur that this way.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!