extract common shader code