- In Visual Studio, right-click on the project in the
Solution Explorer
, and selectAdd -> New Item
. - In the window opened, select
HLSL
in the left menu then selectVertex Shader File (.hlsl)
. If you don't have this option, simply choose any other options and name it with.hlsl
as the format. - Right-click on the new .hlsl file you've just created, and select
Properties
at the bottom of the menu. - In the properties window, select
General
on the left, make sure theItem Type
is set toHLSL Compiler
. - Head to the
HLSL Compiler -> General
menu on the left, set theShader Type
toVertex Shader (/vs)
, andShader Model
toShader Model 3(/3_0)
.
- We will explain the code later, just make sure it is compilable for now.
- Paste the code below and simply hit Build (Ctrl+B).
- It should build a file named *.cso in your out directory.
cbuffer cbPerFrame : register(c0) { matrix WorldViewProj : register(c0); }; float4 main(float3 pos : POSITION) : SV_Position { return mul(float4(pos, 1.f), WorldViewProj); }
- Simply do the steps above for Vertex Shader, but in the properties window, set the
Shader Type
toPixel Shader (/ps)
. - Paste the code below and simply hit Build (Ctrl+B).
cbuffer cbPerFrame : register(c0) { float4 color : register(c0); }; float4 main() : SV_TARGET { return color; }