In my naïve raytracer experiment I work internally with RGB values, and after all the tracing has been done, I end up with raw RGB triplets that I need to write down to some image format with a limited gamut, typically sRGB.
Since bright spots in my image can have values far beyond (1,1,1), I need to clip them. Right now I just limit each channel individually, but that will obviously introduce a shift in hue when one channel clips before another. Here is a typical (enlarged) example from my code where the yellow-green object turns into yellow around the highlight:
I'm now looking for a way to solve this problem, but all the solutions I come up with seems to have the same drawback: eventually you have to discard information. For example, I've thought about working with another colorspace like Lab internally, but even then I would first have to transform it to sRGB for rendering the final image file.
Before I dig myself into this any further, I would like to see if there is either:
- An objectively "best" way to solve this problem, or..
- An industry standard way that is used in practice