x3dom/x3dom — pull request #223 by simonthum (2013-10-09 19:00:56+00:00)
Title: Support gamma-correct rendering

Hi x3dom team,

I did not go the route be bespoke today as our scene sported 8 generated shaders. So instead of sifting them I simply implemented gamma-correct rendering in x3dom. I hope this resolves #222.

It was pretty straightforward to implement. Technically there are some things left, for example you will want to switch to opt-in instead of opt-out for compatibliity. See the TODOs in the commits / source code for more. Especially the application to cascaded shadows is not ideal yet - maybe you can hint me the right spot?

Visually, the result is quite staggering. This is because, as I found today, our scene causes x3dom to apply X3D lighting and 'cascaded' shadows independently. As a net result the estimated difference in intensity from non-corrected to corrected is not just the 1:2.5 one could expect from a uncorrected implementation, but 1:6.25 as both stages were introducing their bias on top of each other. Coping with such conditions using lighting trickery can get cumbersome.

I have probably missed a lot of special cases, but my test scenes worked great. I will post screenshots for comparison when I find the time.

I did not note any performance regression although there evidently is some overhead.