// expt.frag 
#define DELTA 0.002
#define GAIN 5.0

#extension GL_OES_EGL_image_external:enable

precision mediump float;

varying mediump vec2 vTexCoordOut;
uniform samplerExternalOES texture;

void main() {
	vec2 left  = vec2(-DELTA, 0.0);
	vec2 right = vec2( DELTA, 0.0); 
	vec2 up    = vec2(0.0,-DELTA);
	vec2 down  = vec2(0.0, DELTA); 
	vec4 l = texture2D(texture, vTexCoordOut+left);
	vec4 r = texture2D(texture, vTexCoordOut+right);
	vec4 u = texture2D(texture, vTexCoordOut+up);
	vec4 d = texture2D(texture, vTexCoordOut+down);
	
	vec4 c = texture2D(texture, vTexCoordOut);
	gl_FragColor = GAIN*0.25*(abs(l-c)+abs(r-c)+abs(u-c)+abs(d-c));
}
