I have a question: how many shaders are usually active at the same time in one scene in modern games?
I mean: I know that multiple shaders are being used (switching between them in each frame). And it's common that you draw objects "by the shader":
- Draw all objects with shader1
- Change shader1 to shader2
- Draw all objects with shader2
And still, I know it's not as simple (glow effect for whole scene, render to texture etc.), but I guess we can assume it works that way most of the time, right?
That approach ("group by the shader") is good because the shader switching is expensive operation.
So, from one side you cannot have too many shaders, because you want to render the scene fast. But on the other hand you need many different shaders (or uber-shader with branches - quite similar) for skin, metal, water etc.
So - how many (and which) different shaders would the theoretical, modern, third person, 3d detective game for PC (DirectX 11 if it matters) use? It would be 5, 20 or more like 100 active shaders (I count only active, at some "frame X", shaders)?
In my sample game, I would use about 9-11 per frame (count it as different, small shaders or one uber-shader - doesn't matter now):
- Skin shader
- Eye shader (not too much? but they are different)
- Metal shader
- Ground shader
- Snow/rain shader (if required)
- Water shader (if the water exists in scene)
- Glow shader (only when some special effects are involved)
- Light emiter shader (street lamps etc.)
- Standard shader (for all other, just standard shading)
- Standard shader with normal maps
- 2D shader (for GUI etc.)
Is it "much" or "not many"? Did I forget about some important shaders that I would need?
I know it's not one number ("always use 3 shaders!"), but I wonder what is the scale (5, 100?) and which factors are important (I consider the PC game only)?