2nd iteration of shading algorithm, now with functional palette