uniform sampler2D baseMap;
uniform sampler2D tbg1;
uniform sampler2D tbg2;
uniform sampler2D tbg3;
uniform sampler2D tbg4;
uniform vec2 camPos;
uniform float zoom;

varying vec2 Texcoord;

void main(void)
{
   vec2 offset = camPos * 0.0007;
   offset.y = -offset.y;
   vec2 uv;
   uv = Texcoord + offset * 0.8;
   vec4 bg1 = texture2D(tbg1, uv * zoom);
   
   uv = Texcoord + offset * 0.6;
   vec4 bg2 = texture2D(tbg2, uv * zoom);
   
   uv = Texcoord + offset * 0.74;
   vec4 bg3 = texture2D(tbg3, uv * zoom);
   
   uv = Texcoord + offset * 0.68;
   vec4 bg4 = texture2D(tbg4, uv * zoom);
   
   vec4 baseColor = texture2D(baseMap, Texcoord);

   vec2 edge = vec2((Texcoord.x - 0.5), (Texcoord.y - 0.5));
   float edgeGlow = 1-length(edge) - 1.0;
   //edgeGlow = pow(edgeGlow, 3.0);
   vec4 purple = vec4(0.2, 0.45, 0.7, 1.0);
   vec4 blue = vec4(0.251, 0.541, 0.639 , 1.0);//vec4(0.2, 0.2, 0.63, 1.0);
   
   vec4 layers = (bg1 + bg2 + bg3 + bg4) * 0.25;
   vec4 color = mix(blue, purple, layers.x) * layers.x;
   vec4 finalColor = baseColor + color * 0.05;
   finalColor.w = 1.0;
   gl_FragColor = finalColor;
}