I made a 2D game, with basic shaders and now i wish to add motion blur, i am beginner with shaders so i have hard time to implement it.
My shaders -
Vertex shader :
attribute vec4 a_color;
attribute vec2 a_position;
attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying vec4 v_color;
varying vec2 v_texCoord0;
void main() {
v_color = a_color;
v_texCoord0 = a_texCoord0;
gl_Position = u_projTrans * vec4(a_position, 0.0f, 1.0f);
}
Fragment shader :
varying vec4 v_color;
varying vec2 v_texCoord0;
uniform vec2 screenSize;
uniform sampler2D u_texture;
uniform vec4 v_time;
const float RADIUS = 0.75;
const float SOFTNESS = 0.6;
void main() {
vec4 texColor = texture2D(u_texture, v_texCoord0);
vec4 timedColor = (v_color + v_time);
vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
float len = length(position);
float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);
texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
gl_FragColor = vec4(texColor.rgb * timedColor.rgb, texColor.a);
}
What should I add to the shaders to create the motion blur effect?
Or maybe I can create the motion blur effect in libgdx without the shaders?
Any ideas?
Thanks in advance