varying float distFromCam; //Calculate this vertex's distance from the viewer

void main() {
	vec4 pos = gl_ModelViewMatrix*gl_Vertex;
	//Calculate distance between eye and vertex
	distFromCam = distance(vec3(0.0,0.0,0.0),pos.xyz);
	
	//Calculate vertex's texture coordinate
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;	
	
	//Calculate vertex's final, transformed position.
	gl_Position = ftransform();
}