Yes, reducing shaders to a function makes it a lot easier to integrate with other effects. I did that quite a bit with the Cg shaders with the intention of making them all compiler agnostic via ifdefs (that is, once you have it reduced to a function, your actual shader is only 1 line long, connecting the shader backend’s uniforms to the shader function’s inputs). It’d be nice to have one unified shader file that worked on all of the drivers, but the code would be difficult to read–a maze of ifdefs–and it would be a nightmare to deal with POT/NPOT on the coords.