#version 150

out vec3 src_normal, normal, binormal;//, et;
out vec4 pos, ppos;
out float fogCoord, FC, C;
out mat3 TBN;

uniform bool acc_fog;
uniform vec2 dt;
uniform vec3 eye;
uniform mat4 prev_ModelViewProjectioMatrix;
uniform float z_near, z_far;

void main(void) {
	normal = qgl_Normal;//(qgl_NormalMatrix * qgl_Normal);
	binormal = qgl_Bitangent;//(qgl_NormalMatrix * qgl_Normal);
	pos = qgl_ftransform();
	TBN = mat3(qgl_Tangent, qgl_Bitangent, qgl_Normal);
	/*if (acc_fog) {
		fogCoord = (gl_Fog.end - length(pos.xyz) * 0.85) / (gl_Fog.end - gl_Fog.start);
		fogCoord = 1. - clamp(fogCoord, 0., 1.);
	}*/
	//gl_TexCoord[0] = gl_MultiTexCoord0;
	//gl_TexCoord[1] = gl_MultiTexCoord1;

	src_normal = normalize(vec3(pos.xy * dt * 2., 0));

	qgl_FragTexture = qgl_Texture;
	qgl_FragColor = qgl_Color;
	//tp /= tp.w;
	ppos = prev_ModelViewProjectioMatrix * vec4(qgl_Vertex.xyz, 1);
	//pos.w = pos.w;
	//speed = tp - ppos;
	//speed /= (abs(speed) + 1.);
	//speed.xyz *= speed.w;
	//pos *= pos.w;

	//logz = gl_Position.w*C + 1;  //version with fragment code
	C = 0.01;
	FC = 1. / log(z_far * C + 1.);
	
	//pos.z = (logz + logz - 1) * pos.w;

	gl_Position = pos;

}
