Perfect Uniform Motion Blur v1.2

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Perfect Uniform Motion Blur v1.2

Post by xXxMoNkEyMaNxXx »

This shader creates perfect uniform 2D motion blur! Feel free to use it for your own projects, with credit. For each pixel, the shader considers the colours from every pixel on the image that passes under the pixel on the screen. For this reason, the computation time is proportional to the Manhattan distance of the blur.
What it should look like
What it should look like
Motion Blur.png (1.18 MiB) Viewed 5453 times
In this demo, there's a 25 pixel radius safe zone in the centre of the screen where the blur effect demonstrates what happens if you set the Offset to 0. Use your mouse to control the blur. Notice that it is NOT IN ANY WAY calculated by summing identical copies of the image along the blur line, because that would never be perfect.

For love 0.9.0
Motion Blur v1.2.love
Tell me your thoughts!
(3.92 MiB) Downloaded 623 times
v1.1:
-At least 50% better performance!
-More commentary in the shader
-MIT Licence

v1.2:
-Changed variable names
-Uses texture coordinates
-More shader commentary
Attachments
Motion Blur v1.1.love
Old version
(3.92 MiB) Downloaded 230 times
Last edited by xXxMoNkEyMaNxXx on Tue Feb 04, 2014 11:09 pm, edited 3 times in total.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Perfect Uniform Motion Blur

Post by kikito »

  • You probably want to include a license of some kind somewhere.
  • Is *.frag the correct file extension for a shader? Shouldn't it be something like *.glsl or something similar?
  • There is a lot of code repetition on the shader code. Isn't there a way to make it a bit more Don't Repeat Yourself? (I'm asking, I don't speak shader)
  • I like your humor.
When I write def I mean function.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Perfect Uniform Motion Blur

Post by slime »

kikito wrote:
  • Is *.frag the correct file extension for a shader? Shouldn't it be something like *.glsl or something similar?
.glsl is usually used for generic shader code which can be used in vertex or pixel shaders. .vert and .frag (and .vs and .fs and .ps) are generally used for vertex shader and pixel/fragment shader code.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Perfect Uniform Motion Blur

Post by xXxMoNkEyMaNxXx »

kikito wrote:You probably want to include a license of some kind somewhere.
I have never tried or even thought of doing that before, so I wouldn't know where to start.
kikito wrote:There is a lot of code repetition on the shader code. Isn't there a way to make it a bit more Don't Repeat Yourself? (I'm asking, I don't speak shader)
The shader is relatively short, and it also has the potential to get laggy with more extreme blurs. I think this justifies the code repetition. Rather than reduce the number of lines, I'd rather have it run faster. I don't know if all the choices I make actually benefit the speed, but there's always more ways to make a program faster. One choice I made was to transfer the colours already stored in the four colour values so that only half as many texture lookup operations had to be done.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Perfect Uniform Motion Blur

Post by Robin »

xXxMoNkEyMaNxXx wrote:
kikito wrote:You probably want to include a license of some kind somewhere.
I have never tried or even thought of doing that before, so I wouldn't know where to start.
This may help: http://choosealicense.com/
Help us help you: attach a .love.
User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: Perfect Uniform Motion Blur v1.1

Post by xXxMoNkEyMaNxXx »

I made a simplification that: shortens the code, makes it more efficient, reduces texture look-ups, and is more difficult to follow. :awesome:
Feeling like a genius level: >9000
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests