varying vec2 DepthTextureCoord;
varying float FragLightDepth, ViewDist;

uniform mat4 Eng_ObjectLightViewProjMatrix;
uniform mat4 Eng_Bones[16];

attribute float Bone1, Bone2, Bone1Weight;

void main()
{

 	vec4 v1 = gl_Vertex;
	vec4 v2 = gl_Vertex;

/*	if (Bone1 > -0.1)
	{*/
		int b1 = int(Bone1);
        v1 = Eng_Bones[b1] * gl_Vertex;
 /*	}

	if (Bone2 > -0.1)
	{*/
		int b2 = int(Bone2);
        v2 = Eng_Bones[b2] * gl_Vertex;
 /*	}

	if (Bone1Weight >= 0.0)*/
		v1 = mix(v2, v1, Bone1Weight);

	vec4 d = Eng_ObjectLightViewProjMatrix * v1;
	DepthTextureCoord = ((d.xy / d.w) + 1.0) * 0.5;
	
	FragLightDepth = (((d.z / d.w)+1.0)*0.5);
	
	gl_Position = gl_ModelViewProjectionMatrix * v1;
	
 	ViewDist = -(gl_ModelViewMatrix * v1).z;
}
