Original Post
Hello, I have just recently started working with GLSL, and would like to create multiple shaders for each of the effects in my engine. I have one for per-pixel lighting, and eventually I will have more for shadowing, skinned animation, normal mapping, and more. Of course I would like to allow the users to enable and disable certain features (shaders) so they can get the best performance. But what's the best way to manage this? I have thought of two possible solutions, and am wondering which is better, or if there's another, even better option. I haven't seen many threads on this issue. Both of my ideas would have each "effect" in it's own function and it's own file. But since a program can only have one main function, how should I determine which other functions to call? 1) Create a main() shader for every possible combination of enabled/disabled effects, and load the correct one when the user changes the settings. I'd rather not do this, as the number of main() functions could get out of hand quickly. 2) Have just one large main() shader that takes uniforms to determine which features are enabled, and use many if/else blocks to call the required effect functions (from other files). I'm leaning towards #2, but is there a better option? I know uniforms cause performance problems if they're changed often, but would there be any performance issues with my intended use (only changing when the user updates graphics settings)? Thanks!