forked from BellCrow/GettingInShapes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shaders.hlsl
49 lines (40 loc) · 861 Bytes
/
Shaders.hlsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
struct VertexInputType
{
float4 position : POSITION;
float4 color : COLOR;
};
struct PixelInputType
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
cbuffer g_modelMatrix
{
row_major matrix modelMatrix;
};
cbuffer g_viewMatrix
{
row_major matrix viewMatrix;
}
cbuffer g_projMatrix
{
row_major matrix projMatrix;
}
PixelInputType VShader(VertexInputType input)
{
PixelInputType output;
// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1;
float4 pos = input.position;
pos = mul(pos, modelMatrix);
pos = mul(pos, viewMatrix);
pos = mul(pos, projMatrix);
output.position = pos;
// Store the input color for the pixel shader to use.
output.color = input.color;
return output;
}
float4 PShader(PixelInputType input) : SV_TARGET
{
return input.color;
}