I am developing a camera application, where I am applying simple RGB shift filter which is below:
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
vec2 uv = fragCoord.xy / iResolution.xy;
vec3 col;
float eps = 1.0/28.0*sin(iTime*2.0);
col.r = texture(iChannel0, vec2(uv.x + eps, -uv.y)).r;
col.g = texture(iChannel0, vec2(uv.x, -uv.y)).g;
col.b = texture(iChannel0, vec2(uv.x, -uv.y)).b;
fragColor = vec4(col, 1.0);
}
The above code works good and its shifting frame based on time passed. But now I want to apply the filter if and only if any something inside texture is moving so that moving part has RGB shift and if not then it should return the actual frame.
Can anybody help to achieve this or give some idea?