/*
 * vertex shader for rendering the skysphere
 *
 * written by:
 * christian moellinger <ch.moellinger@gmail.com>
 * 11/2010
 */

#version 330 core

uniform mat4 Camera_ProjectionMatrix;
uniform mat4 Camera_TransformMatrix;
uniform mat4 Camera_InverseTranslationMatrix;
uniform mat4 Model_TransformMatrix;
uniform mat3 NormalMatrix;

in vec3 in_Position;
in vec3 in_Texcoord;

out vec3 my_Texcoord;
out vec3 my_EyeDir;
out vec3 my_Position;

void main(void)
{
  mat4 ProjectionMatrix = Camera_ProjectionMatrix;
  mat4 ModelViewMatrix = Camera_TransformMatrix * Camera_InverseTranslationMatrix * Model_TransformMatrix;

  vec3 vVertex = (ModelViewMatrix * vec4(in_Position, 1.0)).xyz;
  my_EyeDir = -vVertex;
  my_Position = (Model_TransformMatrix * vec4(in_Position, 1.0)).xyz;

  gl_Position = ProjectionMatrix * ModelViewMatrix * vec4(in_Position, 1.0);

  //my_Normal = NormalMatrix * in_Normal;
  my_Texcoord = in_Texcoord;
}
