// zebra.frag 
#define BAND_SIZE 0.05

#extension GL_OES_EGL_image_external:enable

precision mediump float;

varying mediump vec2 vTexCoordOut;
uniform samplerExternalOES texture;

void main() {
	gl_FragColor = texture2D(texture, vTexCoordOut);
	if((gl_FragColor[0]>0.95) && (gl_FragColor[1]>0.95) && (gl_FragColor[2]>0.95)) // Saturated
	{
		float manhattanDist = vTexCoordOut[0]+vTexCoordOut[1];
		float band = floor(manhattanDist/BAND_SIZE);
		if(mod(band,2.0)<0.5) // THK: I had some trouble with casting to int... so float it is
		{
			gl_FragColor[0]=0.0;
			gl_FragColor[1]=0.0;
			gl_FragColor[2]=0.0;
		}
		else
		{
			gl_FragColor[0]=1.0;
			gl_FragColor[1]=1.0;
			gl_FragColor[2]=1.0;
		}
	}
}
