Texture2D shaderTexture : register(t0);
SamplerState SampleType : register(s0);

// Matrizen f�r die einzelnen Knochen des Modells
struct MatrixBuffer
{
	matrix knochenMatrix[128];
};

// The projection and view matrix
struct KameraBuffer
{
	matrix view;
	matrix projection;
};

// The position of the kamera
struct KameraBuffer2
{
	float4 kPosition;
};

// these values should sum up to 1
struct Material
{
	float ambientFactor;
	float diffusFactor;
	float specularFactor;
};

struct LightCount
{
	int diffuseLightCount;
	int pointLightCount;
};

ConstantBuffer<KameraBuffer> Kamera : register(b0);
ConstantBuffer<MatrixBuffer> Skelett : register(b1);
ConstantBuffer<KameraBuffer2> Kamera2 : register(b2);
ConstantBuffer<Material> Object : register(b3);
ConstantBuffer<LightCount> Light : register(b4);

struct VertexInputType
{
	float3 position : POSITION;
	float2 tex : TEXCOORD;
	float3 normal : NORMAL;
	uint knochen : KNOCHEN_ID;
	uint id : VERTEX_ID;
};

struct PixelInputType
{
	float4 worldPos : POSITION;
	float4 position : SV_POSITION;
	float2 tex : TEXCOORD;
	float3 normal : NORMAL;
};

PixelInputType main(VertexInputType input)
{
	//return input;                                                                     
	PixelInputType output;
	output.normal = normalize(mul(input.normal, (float3x3)Skelett.knochenMatrix[input.knochen]));

	// Change the position vector to be 4 units for proper matrix calculations.         
	float4 position = float4(input.position.x, input.position.y, input.position.z, 1.f);
	// Store the texture coordinates for the pixel shader.                              
	output.tex = input.tex;

	// Calculate the position of the vertex against the world, view, and projection matrices. 
	output.worldPos = mul(position, Skelett.knochenMatrix[input.knochen]);
	output.position = mul(output.worldPos, Kamera.view);
	output.position = mul(output.position, Kamera.projection);
	return output;
}