mrdoob/three.js — pull request #5834 by bhouston (2014-12-30 16:04:09+00:00)
Title: Ability to set custom Gamma factors

This builds upon the [common.glsl PR here](https://github.com/mrdoob/three.js/pull/5785). This implements the idea expressed [here](https://github.com/mrdoob/three.js/pull/5785#issuecomment-68302484) and subsequently endorsed by @WestLangley.

This add the variable ```WebGLRenderer.gammaFactor``` which is correctly propagated to shaders as the define ```GAMMA_FACTOR```. I have moved the conditional application of gamma correction to two helper functions within common.glsl ```inputToLinear``` and ```linearToOutput```, instead of having it spread across a lot of shader files.

I have also changed both ```THREE.Color.copyLinearToGamma()``` and ```THREE.Color.copyGammaToLinear()``` to take the gamma exponential as an optional parameter.

I have made the code backwards compatible by defaulting the gamma correction factor to 2.0, which matches the approximation used by the square()/sqrt() methods.

Lastly, I have added a "gammaFactor" control to the webgl_shader_physical.html example, but I need to somehow force the shaders to recompile -- if someone could give me a hint on the easy way to do that, it would be greatly appreciated.