#version 400

smooth in vec3 VS_Normal;

layout(location = 0) out vec4 normalOut;

vec2 spheremapEnc(vec3 n)
{
  vec2 ret = normalize(n.xy) * sqrt(-n.z * 0.5 + 0.5);
  return ret * 0.5 + 0.5;
}

void main()
{
	//normalOut = vec4( (normalize(VS_Normal) + 1.0) * 0.5, 1.0 );
	normalOut.xy = spheremapEnc(normalize(VS_Normal));
}
