#include "inc/uniforms.glsl"
#include "inc/utils.glsl"

#ifdef VERTEX

layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
// normal
layout(location=3) in vec2 in_UV;
out vec4 ex_Color;
out vec2 ex_UV;

uniform mat4x4 overlayTransform;

void main()
{
	ex_Color = in_Color;
	ex_UV = in_UV;
	gl_Position = overlayTransform*in_Position; 
}

#endif

#ifdef FRAGMENT

in vec4 ex_Color;
in vec2 ex_UV;

layout(location=0) out vec4 out_Color;

uniform float overlayAlpha;
uniform sampler2D tex;
uniform float p_ovr_y_cut; // cut begin point
uniform float p_ovr_y_cut_size; // cut size

void main()
{
	vec4 col;
	if ((p_ovr_y_cut_size == 0.0) ||
		(ex_UV.y > p_ovr_y_cut && ex_UV.y < p_ovr_y_cut + p_ovr_y_cut_size)) {
		col = texture(tex, ex_UV);
		col.rgb *= 1.5; // värikorjaus tekee vähän liian tummaa kamaa
		//col.rgb = pow(col.rgb, vec3(1.0/2.0));
		//col.a *= p_overlay_alpha;
		col.a *= overlayAlpha;
		out_Color = col;
	} else {
		col = vec4(0.0);
	}
	
	out_Color = col;
} 

#endif