How to convert this code to CG?

From a tutorial to antialias procedural textures, i dont know how to convert the BumpInt line. I’d like to understand how the code works.

AntiAliased CheckerBoard:

float checker(float2 uv)
{
float width = filterwidth(uv);
float2 p0 = uv - .5 * width, p1 = uv + .5 * width;
#define BUMPINT(x) \
(floor((x)/2) + 2.f * max(((x)/2) - floor((x)/2) - .5f, 0.f))
float2 i = (BUMPINT(p1) - BUMPINT(p0)) / width;
return i.x * i.y + (1 - i.x) * (1 - i.y);
}

sort of looks like there might be a bumpint function somewhere that is not quoted here.

That’s a macro, I don’t see why it wouldn’t work, try putting it all on one line like this

#define BUMPINT(x) (floor((x)/2) + 2.f * max(((x)/2) - floor((x)/2) - .5f, 0.f))

If that doesn’t work, you can just expand the macro manually.

Oh nice one that compiles now, i think it means the cg will run it, thanks.