varying float frag_occlusion;
varying float light_influence;
varying vec2 texcoord;
uniform mat4 inv_viewmatrix;

void main(void) 
{
        vec3 down = vec3(0.0, -1.0, 0.0);
        float ground_occlusion = dot(down, gl_Normal);
	vec4 loc_vtx = gl_ModelViewMatrix * gl_Vertex;    
	loc_vtx = inv_viewmatrix * loc_vtx;                  
	float height_occlusion = 1.0 - clamp(loc_vtx.y / 60.0, 0.0, 1.0);
	vec4 light = gl_ModelViewMatrix * vec4(-1.0, 0.0, -1.0, 0.0);
	light = normalize(light);
	light = inv_viewmatrix * light;
	light_influence = clamp(dot(gl_NormalMatrix * gl_Normal, light.xyz), 0.0, 1.0);
	vec3 d = vec3(loc_vtx.x, 0.0, loc_vtx.z);
        frag_occlusion = (1.0 - clamp(length(d) / 30.0, 0.0, 1.0)) * ground_occlusion * height_occlusion;
	gl_Position = ftransform();

	// texture
        texcoord.x = pow(sin(gl_Vertex.x), 2.0);
	texcoord.y = pow(cos(gl_Vertex.z + gl_Vertex.y), 2.0);
}