1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /////////////
- // GLOBALS //
- /////////////
- cbuffer MatrixBuffer : register( b0 )
- {
- matrix knochenMatrix[ 128 ];
- };
- // The projection and view matrix
- cbuffer Kamera : register( b1 )
- {
- matrix view;
- matrix projection;
- }
- //////////////
- // TYPEDEFS //
- //////////////
- struct VertexInputType
- {
- float4 position : POSITION;
- float2 tex : TEXCOORD0;
- float3 normal : NORMAL;
- uint knochen : KNOCHEN_ID0;
- };
- struct PixelInputType
- {
- float4 worldPos : POSITION;
- float4 position : SV_POSITION;
- float2 tex : TEXCOORD0;
- float3 normal : TEXCOORD1;
- };
- ////////////////////////////////////////////////////////////////////////////////
- // Vertex Shader
- ////////////////////////////////////////////////////////////////////////////////
- PixelInputType TextureVertexShader( VertexInputType input )
- {
- //return input;
- PixelInputType output;
- output.normal = normalize( mul( input.normal, (float3x3)knochenMatrix[ input.knochen ] ) );
- // Change the position vector to be 4 units for proper matrix calculations.
- input.position.w = 1.0f;
- // 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( input.position, knochenMatrix[ input.knochen ] );
- output.position = mul( output.worldPos, view );
- output.position = mul( output.position, projection );
- return output;
- }
|