Modular/reusable 2D shader functions/effects?
I've got a few different shader effects that I'm trying to use in different combinations on different nodes. For example, one node has desaturate and blur effects, another has desaturate and reduce contrast. I'd really like to have my desaturate code defined in one place and just apply it where needed, but the only way I've found to combine effects so far are:
1) Copy/paste the relevant code into all the shaders that use it (which I don't like because I've got multiple places to update any time I want to make a change)
2) Create a god shader with all the effects and use uniforms to selectively enable them (which I don't like because it's cumbersome and sounds like a waste of GPU cycles)
Apparently spatial materials have a "Next pass" property which allows chaining them, but it doesn't work in 2D, and there was a proposal to add
#includeable shader functions, but it was closed two years ago without being implemented.
Not too bad if it's really just two or three effects, but things can get out of hand fast as more enter the picture. Anyone have a better solution to this?