Not sure if there's any use/interest in the following -- or if it's cool to use, since I largely stole it from Shadertoy and modified it to work in AM. (Attribution included in shader file, fwiw.) In any case, it's a simple radial blur filter:
radialBlur.fsh
//
// Radial blur (simplified) for AM
//
// Modified for AM based on "Radial Blur (simplified)" by hunter
// (https://www.shadertoy.com/view/4ts3Ws), itself, per hunter's
// comment, "A simplified version of: https://www.shadertoy.com/view/4sfGRn"
//
uniform sampler2D sampleTex;
uniform float amount = float(80.0); // 80
uniform vec2 start_pos = vec2(0.0, 0.0); // -1.0 to 1.0 for x, y
uniform vec2 rez; // typically fe.layout.width. fe.layout.height
uniform float g_punch = float(1.01); // Subtle gamma boost (use < 1.0 for gamma reduction?) [Currently not user-defineable]
vec3 deform( in vec2 p )
{
vec2 uv;
uv.x = sin( 0.0 + 1.0 ) + p.x;
uv.y = sin( 0.0 + 1.0 ) + p.y;
return texture( sampleTex, uv * 0.5 ).xyz;
}
void main()
{
vec2 position = -1.0 + 2.0 * gl_FragCoord.xy / rez.xy;
vec2 current_step = position;
vec2 direction = ( start_pos - position ) / amount;
vec3 total = vec3( 0.0 );
for( int i = 0; i < int( amount ); i++ )
{
vec3 result = deform( current_step );
result = smoothstep( 0.0, 1.0, result );
total += result;
current_step += direction;
}
total /= amount;
gl_FragColor.rgb = vec4(total * g_punch, smoothstep(0.0, 1.0, b));
}
I even added a class for keilmillerjr's Shader module:
class RadialBlur {
//
// Accepts the following arguments (order matters!) (defaults are listed in parens):
// amount (100)
// origin (0.5, 0.5) [coords are 0, 0, to 1, 1]
// resolution (layout dimensions)
//
shader = null;
constructor(...) {
shader = fe.add_shader(Shader.Fragment, shadersDir + "radialBlur.fsh");
if (vargv.len() == 0) set_default();
if (vargv.len() == 1) set_default(vargv[0]);
if (vargv.len() == 3) set_default(vargv[0], vargv[1], vargv[2]);
if (vargv.len() == 5) set_default(vargv[0], vargv[1], vargv[2], vargv[3], vargv[4]);
}
function set_default(a=100, sx=0.5, sy=0.5, rx=::fe.layout.width, ry=::fe.layout.height) {
// Get normalized coords for blur origin (0.0~1.0 vs. -1.0~1.0):
// (Adjusting center introduces some weird edge stuff sometimes?)
sx=-((2 - (sx * 2)) - 1);
sy=((2 - (sy * 2)) - 1);
shader.set_texture_param("sampleTex");
shader.set_param("amount", a);
shader.set_param("start_pos", sx, sy);
shader.set_param("rez", rx, ry);
}
}
And here's how I'm using it (after loading the Shader module and adding radialBlur.vsh to the shaders folder):
local radialBlur = RadialBlur(150, 0.31, 0.37);
paBackground.shader = radialBlur.shader;
I'm attaching the shader and an example image to this post. I'd like to try to introduce some more dynamism: on images (or videos) with large swaths of static content, it's not terribly impressive. Maybe introducing noise or something would spice it up some? The thing is, I only know enough about GLSL to usually muck things up! Part of learning, I guess! ;-) [Full disclosure: I was trying to get a 2-pass Gaussian blur filter to work, but I couldn't trick it into working!]