I have searched the forum for my problem but did not found any solution, so here I am:
I try a texture lookup with cg in this way:
OUT.color = tex2D(UsedTex, float2(texCoord.x + 1.0f/128.0f, texCoord.y - 10.0f/128.0f));
(I have got a texture with size 128,128 applied to a rectangle with 128,128, applied with opengl like this:
This works fine.
But when I try something like this:
int OwnPos = int(texCoord.x * 128.0f);
for (int i = 0; i < 10; i++)
if (i == OwnPos)
OUT.color = tex2D(UsedTex, float2((float)i/128.0f+ 1.0f/128.0f, texCoord.y - 10.0f/128.0f));
it does not work. I get back pixels, but they are not read from the appropriate position.
I checked OwnPos, it is the right value..
By the way
tex2D(UsedTex, float2((float)OwnPos/128.0f+ 1.0f/128.0f, texCoord.y - 10.0f/128.0f));
did not work, (Compiler Error) I think because the Compiler could not determine if OwnPos is correct
Am I missing something? I think the problem for cg is that it is not possible to use variables in tex2D... hope that is not true
I tried with CG_PROFILE_FP40 and CG_PROFILE_ARBFP1.
Any help would be fine!
PS: I know that this example is a little bit stupid...