varying vec2 	texcoord;

uniform sampler2D 	waveHeights0;
uniform sampler2D 	waveHeights1;
uniform sampler2D 	waveHeights2;
uniform sampler2D 	waveHeights3;
uniform sampler2D 	waveHeights4;
uniform sampler2D 	waveHeights5;

uniform sampler2D 	waveNormals0,
					waveNormals1,
					waveNormals2,
					waveNormals3,
					waveNormals4,
					waveNormals5;

void main()
{	

	vec3 waves=	texture2D(waveHeights0,(texcoord.st)).xzy +
				texture2D(waveHeights1,(texcoord.st*0.5)).xzy +
				texture2D(waveHeights2,(texcoord.st*0.25)).xzy +
				texture2D(waveHeights3,(texcoord.st*0.125)).xzy +
				texture2D(waveHeights4,(texcoord.st*0.0625)).xzy +
				texture2D(waveHeights5,(texcoord.st*0.03125)).xzy;
				
	vec3 wavesNormal=	texture2D(waveNormals0,(texcoord.st)).xyz+
						texture2D(waveNormals1,(texcoord.st*0.5)).xyz+
						texture2D(waveNormals2,(texcoord.st*0.25)).xyz+
						texture2D(waveNormals3,(texcoord.st*0.125)).xyz+
						texture2D(waveNormals4,(texcoord.st*0.0625)).xyz+
						texture2D(waveNormals5,(texcoord.st*0.03125)).xyz;
				
	gl_FragData[0].xyz = normalize(waves);
	gl_FragData[1].xyz = normalize(wavesNormal);
}