
varying vec3 norm;
uniform sampler2D texture;
varying vec3 magic;

void main(void)
{
	
	vec3 m = normalize(magic);
	vec2 uv = vec2(0.5,0.5)+m.xy*0.5;
	vec4 tex = texture2D(texture, uv);
	
	tex += vec4(.6,0.6,0.6,1);
	
	float noise = fract(sin(dot(magic.xy ,vec2(12.9898,78.233))) * 43758.5453)*2.0-0.8;
	
	//noise = sin(magic.x*10)*cos(magic.y*10);

	float no = sin(noise+magic.y*8.0) ;//+ cos(noise+magic.x*5.0);;
	float no2 = sin(3.14 + noise+magic.y*8.0) ;//+ cos(noise+magic.x*5.0);;
	
	
	gl_FragColor = tex*vec4(1,0,0,1)*0.5*no + tex*vec4(1.8,1.8,4,1)*0.5*no2 ;// +n*0.09;
}


/*	vec3 m = normalize(magic);
	vec2 uv = vec2(0.5,0.5)+m.xy*0.5;
	vec4 tex = texture2D(texture, uv);
			
	vec3 ln = vec3(0,0,1);
	float d = dot(ln, normalize(norm));
	+
	vec3 ln2 = vec3(0,0,1);
	float d2 = dot(ln2, normalize(norm));

	vec4 n = vec4(1,1,1,1)*sin(d*3.14*0.7);
	vec4 n2 = vec4(1,1,1,1)*sin(d2*3.14*0.5);
*/