uniform vec3 light1_dir;
uniform vec3 light2_dir;
uniform vec3 observer_pos;
uniform float object_invscale;

varying vec3 gposition;
varying vec3 gnormal;

varying vec3 normal;
varying vec4 color;

attribute vec3 app_GPosition;
attribute vec3 app_GNormal;

void main()
{
//	gnormal=gl_Normal.xyz;
//	position=gl_Vertex.xyz*object_invscale;
	color=gl_Color;
	
	gposition=app_GPosition*object_invscale;
	gnormal=app_GNormal;

//	gposition=gl_Vertex.xyz*object_invscale;
//	gnormal=gl_Normal.xyz;

	gl_Position=ftransform();
	
	vec3 tpos=(gl_ModelViewMatrix*gl_Vertex).xyz;
//	vec3 nm_z=normalize(tpos-observer_pos);
	vec3 nm_z=normalize(tpos);
	vec3 nm_x=cross(nm_z, vec3(0,1,0));
	vec3 nm_y=cross(nm_x, nm_z);
	
	normal=normalize(gl_NormalMatrix*gl_Normal.xyz);
	
	normal=vec3(dot(normal, nm_x), dot(normal, nm_y), dot(normal, nm_z));
	
//	normal=gl_Position.xyz;
//	normal=(gl_ModelViewMatrix*gl_Vertex).xyz;
//	normal.z*=0.1;
//	normal=gl_Vertex.xyz*object_invscale;
}

