As Romoku suggested, it would appear that XNA 4 uses a newer/different shader version, in which some new keywords have been added. This includes PixelShader
and VertexShader
, so those may no longer be used as identifiers.
The solution would be to give them some other name (any will do). Also remember to update the names in the technique.
void FancyVertexShader(in VSinput IN, out VStoPS OUT)
{
// transform vertex
OUT.position = mul(IN.position, wvpMatrix);
OUT.color = IN.color;
}
// alter vs color output
void AwesomePixelShader(in VStoPS IN, out PSoutput OUT)
{
float4 color = IN.color;
OUT.color = clamp(color, 0, 1); // range between 0 and 1
}
// the shader starts here
technique BasicShader
{
pass p0
{
// declare & initialize ps & vs
vertexshader = compile vs_2_0 FancyVertexShader();
pixelshader = compile ps_2_0 AwesomePixelShader();
}
}
Edit: and as you pointed out yourself, XNA 4 uses version 2.0 for both the vertex and the pixel shader.