FFMPEG 通过OPENGL 给视频添加震荡波特效
这个代码也是通过在 shadertoy 上版本稍微修改了版本.
uniform sampler2D texture;
uniform float u_time;
uniform vec2 u_resolution;
void main()
{
vec2 uv = gl_FragCoord.xy/u_resolution.xy;
vec2 pos = u_resolution.xy/2.;
float duration = 1.9;
float time = mod(u_time, duration);
float radius = 2000.* time*time;
float thickness_ratio = .5;
float time_ratio = time/duration;
float shockwave = smoothstep(radius, radius-2.0, length(pos - gl_FragCoord.xy));
shockwave *= smoothstep((radius-2.)*thickness_ratio, radius-2.0,length(pos - gl_FragCoord.xy));
shockwave *= 1.-time_ratio;
vec2 disp_dir = normalize(gl_FragCoord.xy-pos);
uv += 0.02*disp_dir*shockwave;
vec3 col = texture2D(texture, uv).rgb;
gl_FragColor = vec4(col,1.0);
}