
// Uniform variables for texturing
uniform sampler2D 	aaa_tex2d[4];

// Dimension of textures : 0, 1, 2, 3 dimension, -1 if unused per Tex Unit
uniform	int			aaa_tex_dim[4];

// Size of Texture for each texture unit
uniform vec2		aaa_tex_0_size;

// 0 = time
// 1 = mouse X
// 2 = mouse Y
uniform float		aaa_pu_float[6];


void main(void)
{
	vec3 c[9];
	for (int i=0; i < 3; ++i)
	{
		for (int j=0; j < 3; ++j)
		{
			c[3*i+j] = texture2D(aaa_tex2d[0], (gl_FragCoord.xy+vec2(i-1,j-1)) / aaa_tex_0_size.xy).rgb;
		}
	}
	
	vec3 Lx = 2.0*(c[7]-c[1]) + c[6] + c[8] - c[2] - c[0];
	vec3 Ly = 2.0*(c[3]-c[5]) + c[6] + c[0] - c[2] - c[8];
	vec3 G = sqrt(Lx*Lx+Ly*Ly);
	
	gl_FragColor = vec4(G, 1.0);
}