Thursday, June 09, 2011

Coloring Fun...

If you read my blog posts about tinting you will know that I spent an inordinate amount of time ensuring that the color tinting of graphics looked about right as compared to the iOS OpenGL version.

For some reason or other (i.e. the information just isn’t out there or – more likely – I couldn’t find it) it’s very hard to find details of the exact color blending/tinting algorithm used by OpenGL. Any information that is out there doesn’t produce results anywhere near what I expected to see as compared to my existing iOS app.

This began a fairly protracted period of trial and error to see if I could at least approximate what I was seeing with the OpenGL blending.  I searched for information online and tested out several different algorithms and their variants, but nothing seemed to look right. In the end I sat down and worked some things out from first principles and – after a bit of tweaking and discussion with techie friends – I ended up with something that closely approximated the OpenGL effect.

As development of the HTML5 version continued, and managed to port across more of the levels and thus got a much better idea of how close the tinting approximation was. As such, here is a comparison of the iOS OpenGL-based tinting (left) versus the HTML5 Canvas-based tinting (right). I don’t think I did too badly at all:

No comments: