Should WebGL shader output be adjusted for gamma?

This is a tough one, but from what I've been able to dig up (primarily from this email thread) it seems that the current behavior is to gamma correct linear color space images(such as PNGs) as they are loaded. Things like JPEG get loaded without transformation of any sort because they are already gamma corrected. (Source: https://www.khronos.org/webgl/public-mailing-list/archives/1009/msg00013.html) This would indicate that textures may possibly be passed to WebGL in a non-linear space, which would be problematic. I'm not sure if that has changed since late 2010.

Elsewhere in that thread it's made very clear that the desired behavior should be that everything input and output from WebGL should be in a linear color space. What happens beyond that is outside the scope of the WebGL spec (which is why it's silent on the issue).

Sorry if that doesn't authoritatively answer your question, I'm just digging up what I can on the matter. As for the matter of wether or not you should be doing correction in a shader, I would say that the answer appears to be "no", since the WebGL output is going to be assumed to be linear, and attempting to self correct may lead to a double transformation of the color space.


When I mentioned this question on Freenode #webgl (June 29, 2012), Florian Boesch vigorously expressed the opinion that nearly all users' systems are hopelessly misconfigured with regard to gamma, and therefore the only way to get good results is to provide a gamma option within a WebGL application, as even if WebGL specified a color space (whether linear or non-linear) for framebuffer data, it would not be correctly converted for the monitor.