attribute vec3 vPosition;
attribute vec2 vTexCoord;
attribute vec3 vNormal;
attribute vec3 vTangent;
attribute vec3 vBinormal;
attribute vec3 vColor;

varying vec2 TexCoord;
varying vec3 Color;
varying vec3 vViewDirTangent;
varying vec3 worldPosition;
varying vec3 vWorldNormal;

uniform mat4 ProjectionModelViewMatrix;
uniform mat4 ModelViewMatrix;

uniform vec3 uViewPos;

void main() {
    vWorldNormal = vNormal;
    gl_Position = ProjectionModelViewMatrix * vec4(vPosition, 1.0);
    TexCoord = vTexCoord;

    vec3 viewDirWorld = normalize(uViewPos - vPosition);

    vViewDirTangent = vec3(
        dot(viewDirWorld, vTangent),
        dot(viewDirWorld, vBinormal),
        dot(viewDirWorld, vNormal)
    );
	vec4 viewPosition = ModelViewMatrix * vec4(vPosition.xyz, 1.0);
	
	worldPosition = vPosition;
}