Made cross platform - Emscripten Support.

Fixed a few bugs with stenciling implementation, should work with nvidia
implementation.