12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /////////////
- // GLOBALS //
- /////////////
- cbuffer MatrixBuffer : register(b0)
- {
- matrix knochenMatrix[128];
- };
- // The projection and view matrix
- cbuffer Kamera : register(b1)
- {
- matrix view;
- matrix projection;
- }
- cbuffer LightController : register(b2)
- {
- uint lightLength;
- }
- cbuffer Light : register(b3)
- {
- uint4 light[6];
- }
- //////////////
- // TYPEDEFS //
- //////////////
- struct VertexInputType
- {
- float4 position : POSITION;
- float2 tex : TEXCOORD0;
- float3 normal : NORMAL;
- uint knochen : KNOCHEN_ID0;
- uint id : VERTEX_ID0;
- };
- struct PixelInputType
- {
- float4 worldPos : POSITION;
- float4 position : SV_POSITION;
- float2 tex : TEXCOORD0;
- float3 normal : TEXCOORD1;
- float4 light : TEXCOORD2;
- };
- ////////////////////////////////////////////////////////////////////////////////
- // 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);
- output.light = float4(1.0f, 1.0f, 1.0f, 0.f);
- if (input.id < lightLength)
- {
- output.light.x = ((((uint[4])light[input.id / 4])[input.id % 4] >> 24) & 0xFF) / 255.f;
- output.light.y = ((((uint[4])light[input.id / 4])[input.id % 4] >> 16) & 0xFF) / 255.f;
- output.light.z = ((((uint[4])light[input.id / 4])[input.id % 4] >> 8) & 0xFF) / 255.f;
- output.light.w = 1.f;
- }
- return output;
- }
|