Page 1 of 1

Per-Pixel Motion Blur

Posted: Wed Aug 30, 2017 11:38 pm
by thatcosmonaut
I'm trying to figure out how to do nice-looking motion blur. Right now I have a hack that involves maintaining a list of canvases and fading them out over each frame, but that's more of a trail than actual motion blur and it looks bad when objects are moving at high speeds.

Most of the research I've done indicates that for actual motion blur you need to compare the model-view matrix of the previous frame to the current frame, but I'm not aware of any way to access this information in LOVE. There's probably some kind of simplifying assumption I'm missing since we're working in 2D but I'm stumped. Has anyone looked into this before?

Re: Per-Pixel Motion Blur

Posted: Wed Aug 30, 2017 11:52 pm
by Sir_Silver
Have you looked into/know what a shader is at all? Post processing effects, like motion blur, are usually done through the use of shaders.
I personally haven't tried to replicate motion blur with shaders (I always turn the effect off in games because it's dizzying and distracting), however a quick google search for "motion blur shader love2d" yielded this result

https://love2d.org/forums/viewtopic.php?t=77170

Re: Per-Pixel Motion Blur

Posted: Thu Aug 31, 2017 12:04 am
by thatcosmonaut
Yeah I'm familiar with shaders, I've written a few for this project.

I'm trying to implement the technique detailed in this post: http://john-chapman-graphics.blogspot.c ... s-are.html

But I'm running into a wall. Particularly the part regarding sending model-view matrices to the shader.

Re: Per-Pixel Motion Blur

Posted: Thu Aug 31, 2017 1:10 am
by raidho36
The matrix is already in the shader by default. For 2d you can go simpler than that however. You make a normal blur shader that uses a blur map. Then you just make a blur map that would produce appropriate looking blur. Using two color channels in the map you can encode both magnitude and direction of blur, in vector form. Channel x encodes magnitude for x, and channel y for y, and direction apparently emerges from applying both simultaneously.

Re: Per-Pixel Motion Blur

Posted: Fri Sep 01, 2017 6:07 pm
by thatcosmonaut
Thanks, I think that makes sense. I'll give it a try.