While doing some reading on how real-time applications handle color under OpneGL, I noticed that some examples implemented Color as a collection of 4 floats, while others used 4 doubles. I have even seen some vertex-compression examples in the game development field that advocated saving colors as 4 short.
All this got me eager for learning more about this: what is the limit precision that OpenGl (or hardwares) handle for colors? More importantly, though, what are the limits in precision above which color differences become impossible to notice?
I have the impression that learning more carefully about that would help me better think and decide on how to implement a Color class for different applications and scenarios (e.g. making trade-off choices between memory, speed and color-variety).
Thanks for your ideas on this.
halfwouldn't incur in the very same problems that you mentioned before, due to the lack of precision? I though that would be particularly important at the GPU, due to the many color calculations that are frequently done in shaders – AndrewSteer Aug 28 '16 at 05:09halfis 16 bits, including 11 effective bits of mantissa precision, so while not as precise asfloat, it's still sufficient for most color operations. (Maybe not quite sufficient if you're outputting to a high-gamut HDR display; I'm not sure.) – Nathan Reed Aug 28 '16 at 05:10