I have a RGB color in the range of 0.0 to 1.0 for each fragment, I need an algorithm to get the inverse of the color, any ideas how can I do this?
If you are using RGB values to 255, you could do something like this:
newR = 255 - r;
newG = 255 - g;
newB = 255 - b;
To understand this concept, imagine each value as a number line going from 0 to 255. If you graph a number on that number line then the number is that distance away from the beginning of the number line. In order to negate it, the number must travel to the other end of the number line. This algorithm basically flips the number line without moving the beginning or the end. Our number line is from 0 to 255, so, if the number was 10 away from the beginning (10), now it will be 10 away from the end (245), thus negating the color.