Friday 12 April 2013

It's Could Be Motion Bur, Or You Could Just Be Drunk

You stagger forward through the dark alleys of some dirty, polluted city. You should not have had that drinking contest with that russian at the pub but the look on his face as he passed out was priceless. Your vision beings to blur, each movement of everything you see blending with the next. You wonder what is happening; its simple, its called being drunk. Now when this happens to a character in a videogame its called motion blur. There are a few ways of creating motion blur such as through the accumulation buffer or through the use of per-pixel motion vectors. I will be briefly going over both.


First let us go over the accumulation buffer method of creating motion blur. Firstly what is the accumulation buffer? the accumulation buffer is essentially a feature of Opengl that stores images from the draw buffer (the draw buffer takes in images in whatever perspective the user is currently set to). But the thing about the accumulation buffer is that it takes the images it got from the draw buffer  multiplies them by a decay value (the decay value is how much of the image or frame is left visible) before inputting them into the current draw buffer. So when the scene is finally drawn on the computer screen you see multiple frames at once but with varying opacity. This method is easy to implement but presents an unrefined look. 

Per-pixel motion vectors on the other hand give a much more smoother blur as oppose the accumulation buffer. How it does this is that it first uses a pixel shader with values taken from the depth buffer to calculate the location of each pixel in a scene relative to the world and in alignment with the view-projection matrix presently being used. Now the difference in pixel positions from the previous frame and the current frame is calculated to give a vector, a per-pixel velocity vector. This can be used to accumulate samples from the frame buffer which are then averaged to create the blur. 




References

No comments:

Post a Comment