// in which two textures get rendered on top of each other
uniform sampler2D baseMap;
uniform vec2 invImageSize;

varying vec2 Texcoord;

void main(void)
{
	vec4 base = texture2D(baseMap, Texcoord);
	float left  = texture2D(baseMap, Texcoord - vec2(invImageSize.x, 0.0)).x;
	float right = texture2D(baseMap, Texcoord + vec2(invImageSize.x, 0.0)).x;
	float up    = texture2D(baseMap, Texcoord - vec2(0.0, invImageSize.y)).x;
	float down  = texture2D(baseMap, Texcoord + vec2(0.0, invImageSize.y)).x;
	
	float vert = abs(left - right);
	float horiz = abs(up - down);
	float lines = vert + horiz;
	
	vec4 wallColor = vec4(0.251, 0.56, 0.589 , 1.0);
	vec4 lineColor = vec4(0.463, 0.663, 0.97, 1.0) * 1.5;
	
	float alpha = clamp(pow(base.x + 0.7, 15.0), 0.0, 1.0);
	vec4 finalColor = base.x * wallColor + lines * lineColor;
	finalColor.a = alpha;
	gl_FragColor = base * (1.0 - alpha) + alpha * finalColor;
}