Hello,
I have been learning the GLSL language recently and all the tutorials always contain one shader program, one vertex shader and one fragment shader. Now as a somewhat experience game dev (not so much opengl) I know that in complex games there is a need for more complex systems. Systems were different objects need different shaders. For example one object may have normal mapping another one may not and have transparency mapping and so on.
I have worked with Unity and Unreal and both of them have a system were each material has a shader specific for it. In my mind things are getting more complicated because in a deferred shading situation there would be a need to have multiple shaders making each pass and then another combining all the passes. Then if post processing is required another shader needs to act upon the final renderbuffer.
Now my little brain is very confused as to how this should all work together in unison.
So my question, and I know its a bit broad, how are shaders used in large, complex games to render lots of different things lots of different ways? Are many different shaders used? Are many different programs used? I have been told that swapping shader programs at runtime is very costly so what other alternative is there?
Thank you!