效果如下:
shader代码:
uniform float u_time;
varying vec2 TextureCoordsVarying;
uniform sampler2D texture;
vec2 uv;
float rnd(float x)
{
return fract(sin(dot(vec2(x+47.49,38.2467/(x+2.3)), vec2(12.9898, 78.233)))* (43758.5453));
}
float drawCircle(vec2 center, float radius )
{
return 1.0 - smoothstep(0.0, radius, length(uv - center));
}
void main( ){
const int _SnowflakeAmount = 200 ;// Number of snowflakes
const float _BlizardFactor = 0.2 ;// _BlizardFactor Fury of the storm !
gl_FragColor = texture2D(texture, TextureCoordsVarying);
uv = vec2(TextureCoordsVarying.x, 1.0 - TextureCoordsVarying.y);
float j;
for(int i=0; i<_SnowflakeAmount; i++)
{
j = float(i);
float speed = 0.3+rnd(cos(j))*(0.7+0.5*cos(j/(float(_SnowflakeAmount)*0.25)));
vec2 center = vec2((0.25-uv.y)*_BlizardFactor+rnd(j)+0.1*cos(u_time+sin(j)), mod(sin(j)-speed*(u_time*1.5*(0.1+_BlizardFactor)), 0.9));
gl_FragColor += vec4(0.2*drawCircle(center, 0.001+speed*0.012));
}
}
而命令更是简单, glshader 是自定义的 filter
ffmpeg.exe -i "D:\left\bbb.mp4" -filter_complex "glshader=fsource=snow.glsl" -y d:\left\333.mp4