

// Validated -> to tweek !!!


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

// 0 = time
// 1 = mouse X
// 2 = mouse Y
// 3 = ray center on X axis
// 4 = ray center on Y axis
uniform float		aaa_fu_float[8];

// 0 = iterations
uniform int			aaa_fu_int[4];


// balance between texture and effect
uniform float		aaa_fu_src;
uniform float		aaa_fu_out;


// Colors factors
// 0 = src colors
// 1 = out color
uniform vec4		aaa_fu_vec4[8];


void main()
{
	// vec3 p 		= vec3( gl_TexCoord[0].st, 0.0 );
	// vec4 tex 	= texture2D( aaa_tex2d[0], (p.xy*=1.0-aaa_fu_float[3]) );
	// vec3 o 		= tex.rbb;

	// vec2 center = vec2( aaa_fu_float[4]*0.1, aaa_fu_float[5]*0.1 );
	// //vec2 center = vec2( 0.5, aaa_fu_float[5]*0.1 );

	// for( float i=0.0; i<float(aaa_fu_int[0]); i++ )
	// {
		// p.xy -= center;
		// p.xy *= 1.0-aaa_fu_float[3];
		// p.xy += center;
		// tex   = texture2D( aaa_tex2d[0], p.xy );

		// p.z += pow( max(0.0, 0.5-length(tex.rg)), 2.0 ) * exp( -i*0.1 );
	// }

	// vec4 src = texture2D( aaa_tex2d[0], gl_TexCoord[0].st ) * aaa_fu_vec4[0];
	// vec4 fx  = vec4( o*o+p.z, 1.0 ) * aaa_fu_vec4[1];

	// gl_FragColor = vec4( (src + fx) * 0.5 );


	vec2 deportXY = vec2(aaa_fu_float[3], aaa_fu_float[4]);


	vec3 p = vec3( gl_TexCoord[0].st, 0.0 );
	vec4 tex = texture2D( aaa_tex2d[0], (p.xy*=0.98));
	vec3 o = tex.rbb;

	for (float i=0.;i<50.0;i++)
	{
		tex  = texture2D(aaa_tex2d[0], (p.xy*=0.98));

		p.z += pow(max(0.0, 0.5-length(tex.rg)),2.0)*exp(-i*0.1);
	}

	//gl_FragColor=vec4(o*o+p.z,1.0);

	vec4 src = texture2D( aaa_tex2d[0], gl_TexCoord[0].st ) * aaa_fu_src * aaa_fu_vec4[0];
	vec4 fx  = vec4( o*o+p.z, 1.0 ) * aaa_fu_out * aaa_fu_vec4[1];

	gl_FragColor = vec4( (src + fx) * 0.5 );
}









