Working on a huge shader refactor today, with the goal of being able to hot reload shaders.
Each shader used to be two large strings (one for the fragment shader and one for the vertex shader), but now they are constructed from these 5 strings.
This keeps uniform and varying names consistent too!
Each shader used to be two large strings (one for the fragment shader and one for the vertex shader), but now they are constructed from these 5 strings.
This keeps uniform and varying names consistent too!
Comments
I have it set up to generate the SPIRV, GLSL, and MSL all in one go. Works great for cross-platform builds because I can just ship the same data everywhere.
Shared code or shaders can just go into an include. Quite handy.
With some mild preprocessor magic you can even share data defs with C code to ensure consistency with the CPU side.
With hundreds of shaders and over 1000 uniforms, this duplication adds up!
Now all the uniforms for one shader are defined in one place.