DX11VertexShader.hlsl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /////////////
  2. // GLOBALS //
  3. /////////////
  4. cbuffer MatrixBuffer : register( b0 )
  5. {
  6. matrix knochenMatrix[ 128 ];
  7. };
  8. // The projection and view matrix
  9. cbuffer Kamera : register( b1 )
  10. {
  11. matrix view;
  12. matrix projection;
  13. }
  14. //////////////
  15. // TYPEDEFS //
  16. //////////////
  17. struct VertexInputType
  18. {
  19. float4 position : POSITION;
  20. float2 tex : TEXCOORD0;
  21. float3 normal : NORMAL;
  22. uint knochen : KNOCHEN_ID0;
  23. };
  24. struct PixelInputType
  25. {
  26. float4 worldPos : POSITION;
  27. float4 position : SV_POSITION;
  28. float2 tex : TEXCOORD0;
  29. float3 normal : TEXCOORD1;
  30. };
  31. ////////////////////////////////////////////////////////////////////////////////
  32. // Vertex Shader
  33. ////////////////////////////////////////////////////////////////////////////////
  34. PixelInputType TextureVertexShader( VertexInputType input )
  35. {
  36. //return input;
  37. PixelInputType output;
  38. output.normal = normalize( mul( input.normal, (float3x3)knochenMatrix[ input.knochen ] ) );
  39. // Change the position vector to be 4 units for proper matrix calculations.
  40. input.position.w = 1.0f;
  41. // Store the texture coordinates for the pixel shader.
  42. output.tex = input.tex;
  43. // Calculate the position of the vertex against the world, view, and projection matrices.
  44. output.worldPos = mul( input.position, knochenMatrix[ input.knochen ] );
  45. output.position = mul( output.worldPos, view );
  46. output.position = mul( output.position, projection );
  47. return output;
  48. }