#version 150

uniform vec3 sunPosition;
uniform vec3 rotX;
uniform vec3 rotY;
uniform vec3 modelPosition;

out VertexData
{
	vec3 worldPos;
	vec3 normal;
	vec2 texCoord;
} outData;

in vec3 vPosition;
in vec3 vNormal;
in vec2 vTexCoord;
in vec3 vTangent;
in vec3 vBitangent;

void main()
{	
	vec3 rotZ = cross(rotX, rotY);
	
	vec3 rotatedPosition = vPosition.x * rotX + vPosition.y * rotY + vPosition.z * rotZ;	
	vec3 translatedPosition = rotatedPosition + modelPosition;
		
	outData.normal = vNormal.x * rotX + vNormal.z * rotY - vNormal.y * rotZ;
	outData.worldPos = translatedPosition;   
	outData.texCoord = vTexCoord.st;
				
	/* vec3 tangent = vTangent.x * rotX + vTangent.z * rotY - vTangent.y * rotZ;
	vec3 bitangent = cross(vNormal, vTangent);*/
			
/*	mat3 rotmat = mat3(tangent, bitangent, fNormal);
	fLightDir = normalize(sunPosition - vPosition);
	fLightDir = rotmat * fLightDir;
	fLightDir = normalize(fLightDir); */

	gl_Position = gl_ModelViewProjectionMatrix * vec4(fWorldPos, 1);
}