When doing frac(X) it returns the fractional part of X, as we all know.
And this is a value in the range 0 to 0.99999999...., never 1.0, is this correct?
I'm trying to find a way to calculate frac(x) that can be used for texture coordinates, where the input will be any UV from 0 to a large number, which I want to to convert to 0..1 range.
Because if we have for example a quad with uvs from 0 to 1, doing frac() on them would turn all UVs into zero.
Of course, I could use a if like this
dest_u = frac(src_u);
if (dest_u <=0.0) {
dest_u = 1.0;
}
But I need this for mobile phones, including old 2.3 Android devices (openGL ES), so I'm trying to find a math solution that does not require ifs.
I know that in some situations it is possible to use min() and max() to replace some ifs, but in this case I'm not finding how to get there, anyone have an idea?