Remove duplicated code in ShaderLib