I haven't done the replacement trick for now, though I was doing something similar in the LibGDX build and will eventually here again to consolidate constants between shaders and game code. Your write-up did help me get to a solution with macros for hardcoding array-access and branching to stick to a single sampler call each pass. I'm happy with that for now, I just need to check that it resolves the corruption issue in korpiroot's screenshot. It doesn't happen on any of my machines but I did see it on my roommate's computer so I can check on that.