Hello all,
I have been tinkering with shaders lately in Godot 3.3.2 and while I am very happy with the vertex/fragment/lighting split, render_mode system & overall ease of writing shaders, I feel the workflow quickly gets out of hand when it comes to generating & maintaining multiple permutations of a shader (e.g. back-facing vs front-facing) or even when developing a 'library' of common shader functionality.
As far as I am aware, unlike the SpatialMaterial, a ShaderMaterial/shader cannot have its render_mode exposed as a parameter, so I am curious to know what your workflow is for dealing with multiple shader permutations, provided it isn't just copying and pasting any modification/fix from one shader to another.
Similarly, how do you deal with common shader functionality/math that may be used inside multiple shaders? Again the only solution that seems to work at the minute is to maintain a 'master' shader & copy & paste the 'common' functionality into each and every shader file that will need it.
I know 'Shader' has fields for 'code' & 'custom_defines', I wonder if anyone has figured out a mechanism to possibly automate the deployment & maintenance of common shader code.
One potential solution which I may attempt when I get some time to spare is to write and editor plugin to supply some common shader code with a special section surrounded by some markers (probably just a formatted comment), and have the plugin copy any functionality over into any other target shader.
Has any of you attempted something similar or know of a similar (or hopefully more elegant) idea floating around on the web?
Thanks in advance