#version 330

in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec2 vertexTexCoord2;  
in vec4 vertexColor;
in vec4 vertexTangent; // metadata1

out vec2 fragTexCoord;
out vec2 fragTexCoord2;
out vec4 fragColor;

flat out int ambientOcclusionSide1;
flat out int ambientOcclusionSide2;
flat out int ambientOcclusionCorner1;
flat out int ambientOcclusionCorner2;
flat out int ambientOcclusionCorner3;
flat out int quadHeight;
flat out int quadWidth;

uniform mat4 mvp;

void main() {
	fragTexCoord = vertexTexCoord;
	fragColor = vertexColor;
  fragTexCoord2 = vertexTexCoord2;
  gl_Position = mvp*vec4(vertexPosition, 1.0);

  // metadata 1 processing
  ambientOcclusionSide1 = floatBitsToInt(vertexTangent.x);
  ambientOcclusionSide2 = floatBitsToInt(vertexTangent.y);
  int metadata1Z = floatBitsToInt(vertexTangent.z);
  int metadata1W = floatBitsToInt(vertexTangent.w);
  ambientOcclusionCorner1 = (metadata1Z & 0x1) >> 0;
  ambientOcclusionCorner2 = (metadata1Z & 0x2) >> 1;
  ambientOcclusionCorner3 = (metadata1Z & 0x4) >> 2;
  quadHeight = (metadata1Z & 0x1f8) >> 3;
  quadWidth  = (metadata1Z & 0x7e00) >> 9;
}
