-
Notifications
You must be signed in to change notification settings - Fork 1
/
VertexShader.hlsl
32 lines (28 loc) · 1.02 KB
/
VertexShader.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
#include "ShaderIncludes.hlsli"
cbuffer ExternalData : register(b0)
{
float4 colorTint;
matrix world;
matrix view;
matrix proj;
}
// --------------------------------------------------------
// The entry point (main method) for our vertex shader
//
// - Input is exactly one vertex worth of data (defined by a struct)
// - Output is a single struct of data to pass down the pipeline
// - Named "main" because that's the default the shader compiler looks for
// --------------------------------------------------------
VertexToPixel main( VertexShaderInput input )
{
// Set up output struct
VertexToPixel output;
matrix wvp = mul(proj, mul(view, world));
output.position = mul(wvp, float4(input.position, 1.0f));
// @todo: what if the model has none-uniform scales? Make sure to apply the inverse transpose instead of just casting to 3x3
output.normal = mul((float3x3)world, input.normal);
output.color = colorTint;
output.worldPos = mul(world, float4(input.position, 1.0f)).xyz;
output.uv = input.uv;
return output;
}