Original Post
I'm looking at dot3 bumpmapping and at one point during the info I'm looking at it says that an integer between [0,255] must be clamped to [-1.0,1.0].
float clamp(unsigned char i)
{
float temp;
temp = (i / 255.0f); // first, clamp the value to [0,1]
temp *= 2; // multiply by 2
temp -= 1.0f; // subtract 1
return temp;
}
This is what I did, and it initially looks to be fine (works with values 0,65,127,191,255). I was wondering if there was a generalised forumla for clamping a value between [a,b] to [c,d]. I took a look on mathworld, but I'm not really sure what to search for.