uniform float3x4 matArrayBones[60];
uniform float4x4 matViewProjection;

static const int  BONES_PER_VERTEX = 4;

struct VS_INPUT
{
	float4 Position : POSITION;
	float4 BlendIdx : BLENDINDICES;
	float4 BlendWgt : BLENDWEIGHT;
};

struct VS_OUTPUT
{
	float4 Position : POSITION;
};

VS_OUTPUT main_vs( VS_INPUT Input )
{
	VS_OUTPUT Output;
	
	// transform by indexed matrix
	float4 blendedPos = float4(0, 0, 0, 0);
	
	for (int i = 0; i < BONES_PER_VERTEX; ++i)
	{
		blendedPos += float4(mul(matArrayBones[Input.BlendIdx[i]], Input.Position).xyz, 1.0) * Input.BlendWgt[i];
	}
	
	// view / projection
	Output.Position = mul(matViewProjection, blendedPos);
	return Output;
}
