DX12VertexShader.hlsl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Matrizen für die einzelnen Knochen des Modells
  2. struct MatrixBuffer
  3. {
  4. matrix knochenMatrix[ 128 ];
  5. };
  6. // The projection and view matrix
  7. struct KameraBuffer
  8. {
  9. matrix view;
  10. matrix projection;
  11. };
  12. ConstantBuffer<KameraBuffer> Kamera : register( b0 );
  13. ConstantBuffer<MatrixBuffer> Skelett : register( b1 );
  14. struct VertexInputType
  15. {
  16. float4 position : POSITION;
  17. float2 tex : TEXCOORD0;
  18. float3 normal : NORMAL;
  19. uint knochen : KNOCHEN_ID;
  20. };
  21. struct PixelInputType
  22. {
  23. float4 worldPos : POSITION;
  24. float4 position : SV_POSITION;
  25. float2 tex : TEXCOORD0;
  26. float3 normal : TEXCOORD1;
  27. };
  28. PixelInputType main( VertexInputType input )
  29. {
  30. //return input;
  31. PixelInputType output;
  32. output.normal = normalize( mul( input.normal, ( float3x3 )Skelett.knochenMatrix[ input.knochen ] ) );
  33. // Change the position vector to be 4 units for proper matrix calculations.
  34. input.position.w = 1.0f;
  35. // Store the texture coordinates for the pixel shader.
  36. output.tex = input.tex;
  37. // Calculate the position of the vertex against the world, view, and projection matrices.
  38. output.worldPos = mul( input.position, Skelett.knochenMatrix[ input.knochen ] );
  39. output.position = mul( output.worldPos, Kamera.view );
  40. output.position = mul( output.position, Kamera.projection );
  41. return output;
  42. }