Hi.

I'm not terribly happy with it, but this is something I use when a UFO character fires a laser:

local kernel = { category = "generator", group = "enemy_attack", name = "beam" }
kernel.vertexData = {
{
name = "width",
default = .07, min = 0, max = 1,
index = 0
},
{
name = "taper",
default = .34, min = 0, max = 1,
index = 1
},
{
name = "frequency",
default = .017, min = 0, max = 1,
index = 2
},
{
name = "falloff",
default = 3.7, min = 0, max = 5,
index = 3
}
}
kernel.isTimeDependent = true
kernel.fragment = [[
// Created by inigo quilez - iq/2013
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
P_DEFAULT float hash1 (P_DEFAULT float n)
{
#if !defined(GL_ES) || defined(GL_FRAGMENT_PRECISION_HIGH)
return fract(sin(n) * 43758.5453);
#else
return fract(sin(n) * 43.7585453);
#endif
}
// Created by inigo quilez - iq/2013
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
P_DEFAULT float IQ (P_DEFAULT vec2 x)
{
P_DEFAULT vec2 p = floor(x);
P_DEFAULT vec2 f = fract(x);
f = f * f * (3.0 - 2.0 * f);
P_DEFAULT float n = p.x + p.y * 57.0;
return mix(mix(hash1(n + 0.0), hash1(n + 1.0), f.x),
mix(hash1(n + 57.0), hash1(n + 58.0), f.x), f.y);
}
P_POSITION float Height (P_POSITION vec2 to_uv)
{
P_POSITION float t = 256. - abs(256. - mod(CoronaTotalTime, 512.));
P_POSITION float taper_base = max(0., CoronaVertexUserData.y);
P_POSITION float x = smoothstep(taper_base, .5, abs(to_uv.x));
P_POSITION float y = CoronaVertexUserData.x * (1. - x * x);
return y * (.875 + IQ(-to_uv.xx * (1024. * CoronaVertexUserData.z) + vec2(8.9, sign(to_uv.y) * 1.7) * t) * .125);
}
P_COLOR vec4 FragmentKernel (P_UV vec2 uv)
{
P_COLOR vec4 color = CoronaColorScale(vec4(1.));
P_POSITION vec2 to_uv = uv - .5;
P_POSITION float h = Height(to_uv);
P_POSITION float ratio = abs(to_uv.y) / max(h, .0001);
h *= .17 * (1. + IQ(vec2(uv.x, h)));
P_COLOR float white = 1. + pow(max(1. - ratio, 0.), .47);
P_COLOR vec3 mixed = mix(vec3(white), color.rgb, 1. - exp(-CoronaVertexUserData.w * ratio) * (1. - h));
return vec4(min(mixed, 1.), color.a) * smoothstep(-.2671, 0., 1. - ratio);
}
]]
graphics.defineEffect(kernel)
local r = display.newRect(display.contentCenterX, display.contentCenterY, 500, 300)
r:setFillColor(1, 0, 0)
r.fill.effect = "generator.enemy_attack.beam"
-- none: r.fill.effect.taper = .5
-- less decay: r.fill.effect.width = .3

**uv.x** runs along the length of the beam and **uv.y** from side-to-side. I'd have to refresh myself on the rest.