
in vec3 attr_pos;
in vec2 attr_uv0;
in vec4 attr_color;

uniform mat4 modelViewProjection;

out vec3 modPos;
out vec3 texCoord0;
out vec4 vcol;

void main() {

	vcol = attr_color;
	texCoord0 = vec3(attr_uv0,1.0);
	
	float endYpos;
	float middleYpos;
	float middle = (end + start)+midTweak;
	float shift = 0.0;
	float bendBack;

	middleYpos = attr_pos.y+(bend*((end-start)*(end-start)));
	endYpos = middleYpos+(bend*((end-middle)*(end-middle)));
	//Draw straight road until start

	if(attr_pos.x >= start){
		gl_Position = modelViewProjection * vec4(attr_pos, 1.0);
	}
	//Draw bended road from start to middle
	if(start >= attr_pos.x){
		if(attr_pos.x >= middle){
			gl_Position = modelViewProjection * vec4(vec3(attr_pos.x,attr_pos.y+(bend*((attr_pos.x-start)*(attr_pos.x-start))),attr_pos.z), 1.0);
		}
		if(end >= attr_pos.x){
			if(middle >= attr_pos.x){
				gl_Position = modelViewProjection * vec4(vec3(attr_pos.x,endYpos,attr_pos.z), 1.0);
			}
			else{
			   gl_Position = modelViewProjection * vec4(vec3(attr_pos.x,(endYpos-(bend*((attr_pos.x-middle)*(attr_pos.x-middle)))),attr_pos.z), 1.0);
			}
		}
	}
	
	
}
