I am trying to draw a cube in DirectX. However, I am getting the following error message;
D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled and RasterizedStream is not D3D11_SO_NO_RASTERIZED_STREAM) but position is not provided by the last shader before the Rasterization Unit. [ EXECUTION ERROR #362: DEVICE_DRAW_POSITION_NOT_PRESENT]
Here is the code for my shaders;
cbuffer WorldBuffer : register (b0)
{
matrix World;
matrix View;
matrix Projection;
}
struct VS_OUTPUT
{
float4 pos : SV_POSITION;
float4 color : COLOR0;
};
VS_OUTPUT VS(float4 pos : POSITION, float4 color : COLOR) : VS_OUTPUT_SEMANTICS
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.pos = mul(pos, World);
output.pos = mul(output.pos, View);
output.pos = mul(output.pos, Projection);
output.color = color;
return output;
}
float4 PS(VS_OUTPUT input : VS_OUTPUT_SEMANTICS) : SV_TARGET
{
return input.color;
}
Since I have given SV_POSITION
semantic to VS_OUTPUT.pos
, I think shader should be passing position, but it doesn't seem to work. How can I fix my shaders?
This is how I compile my shaders:
UINT flags = D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_DEBUG;
r = D3DCompileFromFile(L"shader.fx", NULL, NULL, "VS", "vs_5_0", flags, 0, &vertex_blob, &errMsg);