I'm getting an error stating that my shader has too many instructions, and that shader model 2.0 only supports 64. I'm pretty sure this is because my shader isn't optimized, as every other solution I've tried won't compile.
Shader:
uniform extern texture Sample;
sampler ScreenS = sampler_state
{
Texture = <Sample>;
};
float4 input[8];
float4 output[8];
float4 Swap(float2 texCoord: TEXCOORD0) : COLOR
{
float4 color = tex2D(ScreenS, texCoord.xy);
if (color.r == input[0].r && color.g == input[0].g && color.b == input[0].
color = output[0];
else if (color.r == input[1].r && color.g == input[1].g && color.b == input[1].
color = output[1];
else if (color.r == input[2].r && color.g == input[2].g && color.b == input[2].
color = output[2];
else if (color.r == input[3].r && color.g == input[3].g && color.b == input[3].
color = output[3];
else if (color.r == input[4].r && color.g == input[4].g && color.b == input[4].
color = output[4];
else if (color.r == input[5].r && color.g == input[5].g && color.b == input[5].
color = output[5];/*
else if (color.r == input[6].r && color.g == input[6].g && color.b == input[6].
color = output[6];
else if (color.r == input[7].r && color.g == input[7].g && color.b == input[7].
color = output[7];*/
return color;
}
technique
{
pass P0
{
PixelShader = compile ps_2_0 Swap();
}
}
If the comment is placed at the end of the else-if statement right above it's current position, it compiles fine, but it doesn't check the last 3 colors.
How can this code be improved so that my criteria is met and uses <= 64 instructions?