Damn, thought PacBard already animated at constant speed but just discovered I'd already had changed the copy I made.
Here's what I changed in Zao's version, I took out the sampler to make him permanent yellow, gave him an eye,
added the constant animation and tweaked some numbers to make edges more sharp
the d.x is from the viewport delta calculation in PS, instead of two single floats I changed that to a float2 d.xy or d.yx depending on orientation.
same with the swizzle in the below code.
float4 pac_bar( float pos, float2 tc, float4 c0, float2 d )
{
float4 c = float4(1.0,1.0,0,0);
float2 vp = horizontal ? viewportSize.xy : viewportSize.yx;
float2 pixel_tc = (float2(pos, 0) - tc) * float2(1, 0.5) * vp / vp.y;
float2 eye_tc = (float2(pos+d.x*6, 0.45) - tc) * float2(1, 0.5) * vp / vp.y;
float2 pac_tc = pixel_tc + float2(0.5, 0.5);
if (pac_tc.x >= 0 && pac_tc.x <= 1 && pac_tc.y >= 0 && pac_tc.y <= 1)
{
float2 dir = normalize(pixel_tc);
float2 pixel_ang = acos(dot(dir, float2(-1,0)));
float2 ang = 0.45*sin(1000*pos*(trackDuration/200));
c.a = smoothstep(0.40, 0.45, pixel_ang - ang);
c.a -= smoothstep(0.45, 0.40, length(eye_tc)*8);
c.a *= smoothstep(0.40, 0.39, length(pixel_tc));
}
return float4(lerp(c0.rgb, c.rgb, c.a), c.a);
}