PDA

View Full Version : [CG][FragmentPr]coords and fmod not working


Spoerie
03-24-2005, 12:37 PM
Hey hey,


I'm currently working on something with CG and are new to it. I came across this site and I got one of them cg problems, so i thought I'd drop it here :)
I'm trying to convert a RAW image exported by matlab (rrrr..., gggg..., bbbb... instead of rgbrgbrgb... format) to RGB in CG.

Thing is, I can't seem to work with my 'coords'. The code below should explain.
The problem lies with the coord object. Everything else seems to work!

Strange enough: fmod doesn't work either. (CG Error)

I'm working with a FireGLX1 from ATI under Suse 9.2...
I'm hoping someone can see a problem within the code or has knowledge of what I'm doing wrong.
If anyone has any theory on how I could work with planes better, I'd love to hear that too :)

Thanks in advance.


half4 renderraw(half2 coords : TEXCOORD0, uniform sampler2D texture) : COLOR

{
static const half offset = 1.0 / 1024.0/3.0;
static const half offsetx = 1.0/1024.0 * 1024.0;
half4 color = {0,0,0,0};
int x = (coords.y*1024.0*1024.0 + coords.x*1024.0);
//Even the following doesn't work:
//int x = coords.y;
//
//The following does work though:
//half2 test;
//test.x = 7;
//x = test.x * 1024;
int index = (int)floor(x/3.0);
index = index * 3.0;
index= x-index;

//Normally you would just use fmod, but fmod doesn't work for some
//reason. Not even fmod(7,3) for example.
// index = fmod(x,3);

//the follow works, except for the 'index'
//putting in 0 or 1 or 3 instead of index works.
color.r = tex2D(texture, coords)[index];
color.g = tex2D(texture, coords + half2(offsetx , offsetx))[index];
color.b = tex2D(texture, coords + half2(2.0*offsetx , 2.0*offsetx))[index];
return color;
}

CGTalk Moderation
03-24-2005, 12:37 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.