Consolidated shader compilers

Refactored out the duplication of code in the shader compiler.