So my vertex structure has an XMCOLOR member in it and I want to use it in HLSL but I'm getting errors while compiling the shaders.
error X4577: Not all elements of SV_Position were written.
error X4576: Output signature parameter (1-based Entry 0) type must be float32 and mask must be xyzw.
I'm new to HLSL and DirectX so I can't understand what's the problem...
My vertex (VS) and pixel (PS) shaders:
cbuffer cbPerObj : register(b0)
{
float4x4 vWorldViewProj;
};
struct VertexIn
{
float3 pos : POSITION;
float3 tan : TANGENT;
float3 norm : NORMAL;
float3 tex0 : TEX0;
float3 tex1 : TEX1;
float color : COLOR;
};
struct VertexOut
{
float3 pos : SV_POSITION;
float3 tan : TANGENT;
float3 norm : NORMAL;
float3 tex0 : TEX0;
float3 tex1 : TEX1;
float color : COLOR;
};
VertexOut VS(VertexIn vin)
{
VertexOut vout;
vout.pos = mul(float4(vin.pos, 1.0f), vWorldViewProj);
vout.color = vin.color;
vout.tan = vin.tan;
vout.norm = vin.norm;
vout.tex0 = vin.tex0;
vout.tex1 = vin.tex1;
return vout;
}
float PS(VertexOut pin) : SV_Target
{
return pin.color;
}
And my Vertex struct in C++:
struct SVertex
{
DirectX::XMFLOAT3 vPos;
DirectX::XMFLOAT3 vTangent;
DirectX::XMFLOAT3 vNormal;
DirectX::XMFLOAT3 vTex0;
DirectX::XMFLOAT3 vTex1;
DirectX::PackedVector::XMCOLOR color;
};