I got this error:
Direct3D9: VS->PS Linker: X777: (Error) The current pixel shader expects vertex declaration to provide semantic 'texcoord0' including components(s): 'xyzw',
however the current transformed vertex declaration (vertex proc. disabled) provides 'texcoord0' with component(s): 'xy'.
The vertex declaration's component set needs to be a superset of pixel shader input component set.
Vertex shader
struct A2V
{
float4 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
float4 Color : TEXCOORD1;
};
struct V2P
{
float4 Position : POSITION;
float4 TexCoord0 : TEXCOORD0;
float4 Color : TEXCOORD1;
};
void VertexProgram(in A2V IN, out V2P OUT)
{
OUT.Position.x = IN.Position.x;
OUT.Position.y = IN.Position.y;
OUT.Position.z = IN.Position.z;
OUT.Position.w = IN.Position.w;
OUT.TexCoord0.x = IN.TexCoord0.x;
OUT.TexCoord0.y = IN.TexCoord0.y;
OUT.TexCoord0.z = IN.TexCoord0.x * 0.25f;
OUT.TexCoord0.w = IN.TexCoord0.y * 0.25f;
OUT.Color = IN.Color;
}
Pixel shader
sampler fontSamp : register(s0);
struct V2P
{
float4 Position : POSITION;
float4 TexCoord0 : TEXCOORD0;
float4 Color : TEXCOORD1;
};
struct P2A
{
float4 Color : COLOR;
};
void PixelProgram(in V2P IN, out P2A OUT)
{
float2 alphaRange = float2(0.1f, 1.0f);
float4 base = float4(IN.Color.rgb, tex2D(fontSamp, IN.TexCoord0.xy).a);
float sdf = tex2D(fontSamp, IN.TexCoord0.zw).r;
float alpha = smoothstep(alphaRange.x, alphaRange.y, sdf);
OUT.Color = lerp(base, IN.Color, alpha);
}
and my vertex elements
D3DVERTEXELEMENT9 vertexElements[] =
{
{0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0},
{0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
{0, 24, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
D3DDECL_END()
};
I don't see whats wrong?