Converted singlepass shaders to multipass shaders.

This increases performance by reducing the amount of redundant computations.
Add workaround for ATI cards.
Reduce branching by merging equivalent cases.
Add legacy single-pass shaders.