Per-Pixel Motion Blur

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
thatcosmonaut
Prole
Posts: 9
Joined: Sun Nov 06, 2016 6:04 pm

Per-Pixel Motion Blur

Post 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?
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Per-Pixel Motion Blur

Post 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
User avatar
thatcosmonaut
Prole
Posts: 9
Joined: Sun Nov 06, 2016 6:04 pm

Re: Per-Pixel Motion Blur

Post 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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Per-Pixel Motion Blur

Post 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.
User avatar
thatcosmonaut
Prole
Posts: 9
Joined: Sun Nov 06, 2016 6:04 pm

Re: Per-Pixel Motion Blur

Post by thatcosmonaut »

Thanks, I think that makes sense. I'll give it a try.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests