p :: properties {
	color         : float4;
	rect_position : float2;
	rect_scale    : float2;
	resolution    : float2;
	texture       : Texture2D;
	sampler       : Sampler;
}

PS_Input :: struct {
	uv : float2 @uv;
	pos : float4 @pos;
}

vertex main :: (pos : float4 @position) -> PS_Input {
	res      : float2 = p.resolution;
	scale    : float2 = p.rect_scale;
	rect_pos : float2 = p.rect_position;;

	center : float2 = rect_pos;
	half_size  : float2 = float2(scale.x / 2, scale.y / 2);
	dst_pos    : float4 = float4(pos.x * half_size.x + center.x, pos.y * half_size.y + center.y, 0.0, 1.0);

	result : PS_Input;

	src_p0 : float2 = float2(0.0, 1.0);
	src_p1 : float2 = float2(1.0, 0.0);

	src_half_size : float2 = (src_p1 - src_p0) / 2;
	src_center    : float2 = (src_p1 + src_p0) / 2;
	src_pos       : float2 = float2(pos.x, pos.y) * src_half_size + src_center;

	result.uv = float2(1, 1);
	result.pos = float4(2.0 * dst_pos.x / res.x - 1, 2.0 * dst_pos.y / res.y - 1, 0.0, 1.0);

	return result;
}

pixel main :: (input : PS_Input) -> float4 @target0 {
	color : float4 = p.color;
	return color;
}
