#version 330

layout( location = 0 ) in vec3 InVertex;

out vec2 vTexCoord;
out vec3 vWorldPos;

uniform mat4 uModelMatrix;
uniform float uRadius;

void main()
{
	float domeHeight = InVertex.y / uRadius;
	vec2 normalizedPos = ( InVertex.xz / uRadius ) * ( 1.0 - domeHeight + 0.5 );
	vTexCoord = ( normalizedPos * 0.5 + 0.5 );
	
	vec4 worldPos = uModelMatrix * vec4( InVertex, 1.0 );
	
	vWorldPos = worldPos.xyz;
	
	gl_Position = worldPos;
}