/*
uniform vec3 light1_dir;
uniform vec3 light2_dir;
uniform vec3 observer_pos;
uniform float object_invscale;
*/
uniform float texturesize;

varying vec3 normal;
varying vec3 cull_normal;
varying vec4 color;

varying vec3 tangent;
varying vec3 binormal;

attribute vec3 app_Tangent;

void main()
{
//	normal=gl_Normal.xyz;
//	position=gl_Vertex.xyz*object_invscale;
	color=gl_Color;
//	gl_TexCoord[0]=gl_MultiTexCoord0;
//	gl_TexCoord[0]=gl_MultiTexCoord0-vec4(0.5/256, 0.5/256, 0, 0); // compensate for bumpmap emboss offset - TODO: uniform for texture size
//	gl_TexCoord[0]=gl_MultiTexCoord0-vec4(0.5/512, 0.5/512, 0, 0); // compensate for bumpmap emboss offset - TODO: uniform for texture size
//	gl_TexCoord[0]=gl_MultiTexCoord0-vec4(0.5/1024, 0.5/1024, 0, 0); // compensate for bumpmap emboss offset - TODO: uniform for texture size

	gl_TexCoord[0]=gl_MultiTexCoord0-vec4(0.5/texturesize, 0.5/texturesize, 0, 0); // compensate for bumpmap emboss offset
	gl_TexCoord[1]=gl_MultiTexCoord0; // no uv compensation for colortexture

	gl_Position=ftransform();
	
	normal=normalize(gl_NormalMatrix*gl_Normal.xyz);


	vec3 tpos=(gl_ModelViewMatrix*gl_Vertex).xyz;
	vec3 nm_z=normalize(tpos);
	vec3 nm_x=cross(nm_z, vec3(0,1,0));
	vec3 nm_y=cross(nm_x, nm_z);
	cull_normal=vec3(dot(normal, nm_x), dot(normal, nm_y), dot(normal, nm_z));


	tangent=normalize(gl_NormalMatrix*app_Tangent);
	binormal=cross(tangent, normal);
}

