Skip to main content
gamedev.net
🔒 Locked

Accumulation Buffer Problem

Started by AfroFire 5 replies 600+ views
Original Post
AfroFire
AfroFire
Hey guys, im trying to do a simple motion blurring effect on a moving/spinning square. Here is an excerpt of the code:

glClear(...); // clear color, depth, and accum buffer
for(int i = 0; i < AMT; i++)
{
        box->move(0, 0 ,amt);
        box->angle += 3;
        box->draw();
	glAccum(GL_MULT, 0.5); // 0.5 is the decay factor
}

glAccum(GL_RETURN, 1.0);
// flip screen

However, no matter what the decay factor is (even 0) it resembles 1.0! I mean, this is basically all the code for the motion blurring of this one little box. And because you guys like pictures:
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
RichardS
RichardS
Can you give a bit more info? What happens when you call glAccum just once with glAccum(GL_MULT, 1.0) (ie, accum buffer should exactly match the color buffer), and then return?

Even better, clear the color buffer before the return just so you know exactly what the RETURN is doing. The color buffer should obviously not change much.
AfroFire
AfroFire
Alright, so I cleared the color buffer right before drawing the accumulation buffer, and now... there is nothing - so am I just forgetting to enable something?


I did a glGetError()

Its returning the code for GL_INVALID_OPERATION

and according to my reference guide, this means 1 of 2 things -
1) GL_INVALID_OPERATION is generated if there is no accumulation buffer
or
2) "" is generated if glAccum is executed between the execution of glBegin and the corresponding execution of glEnd.

Its not between a glBegin, that much is obvious - so there is no accumulation buffer? Did I not enable it? DO I have to enable it? I have a Radeon 9600....
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
AfroFire
AfroFire
Im using SDL... does this count for anything?
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
AfroFire
AfroFire
So I was scowering the SDL docs for details, came upon setting the accumulation buffer bit size - I mimicked the setting of setting the color buffers bit size

SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );

and so I have that and:

SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 5);
SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 5);


as well.

Now, all I get is a big black screen.
Even when I try to draw the entire scene to the accum buffer -
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
AfroFire
AfroFire
Alright, so it seems I have misinterpreted the purpose of the GL_MULT.

It doesnt actually accumulate anything to the buffer, it just multiplies its contents by the number.

Anyways, after figuring this out - it is a very slow way to do this, and I probably wont be doing it this way anyways. Its just a good learning lesson :)

So my new code does this:

Draws the scene to the accumulation buffer
Multiplies that by .5
Draws the scene again after moving the objects
Multiplies that by .5
draws the scene again with the accumulation buffer
flips.

Thats just two motion blurs as well.

FPS drops big time.
AfroFire | Brin"The only thing that interferes with my learning is my education."-Albert Einstein
bzroom
bzroom
I think you should only be drawing the scene to the accumulation buffer once, and just dont clear it ever. As you keep multiplying by .5, the image will eventualy decay to ~0. I think your trying to draw the whole blur trail each frame, instead of actualy allowing it to "accumulate". I have not experimented with this effect yet, but that is my assumption.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.