P.S. we don't need to mention it, but we will have better luck with this implementation (e.g., just some tweaks and optimizations for common cases) with WebGL 2.0 assuming the updated GLSL is more flexible, which I bet it is.