precision mediump float;

attribute vec2 aVertexPosition;

uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uProjectionMatrix;
uniform vec3 uCameraPosition;
uniform vec3 uLightPosition;

varying vec4 clipSpace;
varying vec2 uv;
varying vec3 toCameraVector;
varying vec3 fromLightVector;

const float tiling = 8.0;

void main() {
  vec4 worldPosition = uModelMatrix * vec4(aVertexPosition.x, 0.0, aVertexPosition.y, 1.0);
  clipSpace = uProjectionMatrix * uViewMatrix * worldPosition;
  gl_Position = clipSpace;
  uv = (aVertexPosition / 2.0 + 0.5) * tiling;
  toCameraVector = uCameraPosition - worldPosition.xyz;
  fromLightVector = worldPosition.xyz - uLightPosition;
}
