//==========================================================================================================
// EQUINOX-3D Cg FP30 default vertex-program
//
// This shader code was automatically generated by the EQUINOX-3D Cg shader framework
//
// EQUINOX-3D(TM), 3DPanel(TM) and 3DLib(TM) Copyright (C) 1992-2010 By Gabor Nagy. All rights reserved.
//===========================================================================================================
struct VertexInputs
{
 float4 Position	: POSITION;
 float3 Normal		: NORMAL;
 float2 Texcoords0	: TEXCOORD0;
 float3 TxTangent2      : TEXCOORD4;    // Texture-space tangent for normal map 2

 int4   JointIndices	: TEXCOORD1;
 float4 JointWeights	: TEXCOORD2;
};

// Vertex-Fragment interface
//
struct InterpolatedValues
{
 float4 HPosition		: POSITION;
 float4 Position		: TEXCOORD7;
 float2	TextureCoords0		: TEXCOORD0;
 float2	TextureCoords2		: TEXCOORD2;

 float3	Normal			: TEXCOORD3;
 float3	Tangent			: TEXCOORD4;

 float4	ShadowMapCoords0	: TEXCOORD5;
 float3	TxTangent0		: TEXCOORD6;
};



void main(in VertexInputs IN, out InterpolatedValues OUT,
	uniform float4x4 ModelViewProjMatrix,
	const uniform float3x3 NormalLocalToWorldMatrix,
	uniform float3x4 SkinningVertexMatrices[30]
//	uniform float3x3 SkinningNormalMatrices[15]
)
{
 if(1)
 {
  float3	LPosition = float3(0.0, 0.0, 0.0), LNormal = float3(0.0, 0.0, 0.0);
  float	LWeightSum = 0.0;
  int	LC;for(LC = 0;LC < 4;LC++)
  {
   const int	LIndex  = IN.JointIndices[LC];
   const float	LWeight = IN.JointWeights[LC];
   float3x3	SkinningNormalMatrix = SkinningVertexMatrices[LIndex];

   LPosition += mul(SkinningVertexMatrices[LIndex], IN.Position) * LWeight;
   LNormal   += mul(SkinningNormalMatrix, IN.Normal)             * LWeight;

   LWeightSum += LWeight;
  }

  LPosition /= LWeightSum;

  OUT.Position = float4(LPosition, 1.0);
  OUT.Normal   = normalize(LNormal);
 }
 else
 {
  OUT.Position = IN.Position;
  OUT.Normal = IN.Normal;
 }

 OUT.TextureCoords0 = IN.Texcoords0;
 OUT.TextureCoords2 = IN.Texcoords0;
 OUT.TxTangent0 = IN.TxTangent2;
 OUT.HPosition = mul(ModelViewProjMatrix, OUT.Position);
}
