Can someone tell me why the following pixel shader code works and the second bit of code doesn't? This is excerpted from a .fx file that otherwise works fine. The only thing that is changing is the litcolor.r value in the if-then code. It seems that if I don't change the litcolor.r value, all works fine. Why would changing this value cause the shader to not compile correctly? I know it's not a real useful bit of code, but just trying to see what the limitations of pixel shaders are. Thanks!
struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float4 Diffuse : COLOR0; // vertex diffuse color
};
float4 ColorPS(float4 vPosition : POSITION, float4 c : COLOR0) : COLOR
{
VS_OUTPUT Output;
float4 litcolor = float4(0.0f, 0.0f, 0.0f, 0.0f);
if (vPosition.x>1000)
{
litcolor.r=0.0f;
}
//else
//{
// litcolor.g=1.0f;
//}
return litcolor;
}
and the following gives me a shader compiler error?
ColorPS(float4 vPosition : POSITION, float4 c : COLOR0) : COLOR
{
VS_OUTPUT Output;
float4 litcolor = float4(0.0f, 0.0f, 0.0f, 0.0f);
if (vPosition.x>1000)
{
litcolor.r=1.0f;
}
//else
//{
// litcolor.g=1.0f;
//}
return litcolor;
}