I want to know the x pos of texture coord is odd or even in a CG program,such as the 0,2,4,…is even pos,1,3,5,…is odd pos.I write a code to test,in my code,I check the remainder of x divited by a number is less then a small number or not, if true it is even pos,otherwise it is odd pos.But I fail,and I can’t find out what problem is.Below is my code:
float4 main{float2 texCoord : TEXCOORD0,
uniform sampler2DoriginTex
} : COLOR
{
//the size of texture is 1024x1024,so
//every 2 pixels’ space is below:
static float xSpace = 2.0f/1024.0f;
//fmod() is the CG’s remainder calculation function
if(fmod(texCoord.x,xSpace) < 0.00001f)
return float4{1,0,0,1}; //even line is red
else
return float4{0,1,0,1}; //odd line is green
}
In my guess,the result bitmap should be red green interleaved,but what I see is all green.What’s wrong with my shader?Is it possible to determine the texcoord is odd or even?