#version 330

in vec2 vs_TexCoord0;

uniform usampler2D u_Noise;
//uniform float u_fTime;
uniform vec2 u_vTranslation;		// Translate in the same direction as the clouds

out uint fs_uiOut;

ivec2 toTex( vec2 v )
{
	ivec2 s = textureSize( u_Noise, 0 );
	v *= s;
	v = round(v);
	v = mod(mod(v, s) + v, s);
	return ivec2(v);
}

void main(void)
{
	uint uiNoise1 = texelFetch( u_Noise, toTex(vs_TexCoord0 + u_vTranslation), 0 ).r;
	uint uiNoise2 = texelFetch( u_Noise, toTex(( vs_TexCoord0 + vec2( 0.4, -0.3) + u_vTranslation ) * 0.5), 0 ).r;
	uint uiNoise3 = texelFetch( u_Noise, toTex(( vs_TexCoord0 + vec2(-0.1, +0.2) + u_vTranslation ) * 0.25), 0 ).r;
	fs_uiOut = (uiNoise1 | uiNoise3) ^ uiNoise2;
	//fs_uiOut = (0xffffffff ^ (uiNoise1 & uiNoise2)) & uiNoise3;
}