forked from numberwolf/FFmpeg-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjitter_shader.gl
More file actions
27 lines (21 loc) · 817 Bytes
/
jitter_shader.gl
File metadata and controls
27 lines (21 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//precision highp float;
uniform sampler2D tex;
varying vec2 TextureCoordsVarying;
uniform float playTime;
const float PI = 3.1415926;
float rand(float n) {
return fract(sin(n) * 43758.5453123);
}
void main() {
float duration = 0.7;
float maxScale = 1.1;
float offset = 0.02;
float progress = mod(playTime, duration) / duration; // 0~1
vec2 offsetCoords = vec2(offset, offset) * progress;
float scale = 1.0 + (maxScale - 1.0) * progress;
vec2 ScaleTextureCoords = vec2(0.5, 0.5) + (TextureCoordsVarying - vec2(0.5, 0.5)) / scale;
vec4 maskR = texture2D(tex, ScaleTextureCoords + offsetCoords);
vec4 maskB = texture2D(tex, ScaleTextureCoords - offsetCoords);
vec4 mask = texture2D(tex, ScaleTextureCoords);
gl_FragColor = vec4(maskR.r, mask.g, maskB.b, mask.a);
}