1
\$\begingroup\$

Wondering the scale basically. The number of shaders a large game or game engine has. I've seen some metal repos but they typically just have 1 or 2 shaders for small demos. I think I've seen a few with 5 or 10, 1 with maybe 20. But I haven't seen anything where there is like 100 or 1,000 shaders or anything like that.

Wondering what the scale is like for typical large games or game engines, if they are on the order of 1-10, or 100, or 1000, sorta thing. And if it's a large number, maybe a quick idea of what the various tasks they are used for would be interesting but not required :). Thank you!

\$\endgroup\$
4
\$\begingroup\$

It depends in part on how you count them.

Many games & engines use large shaders, called "ubershaders," that try to cover many different material effects and rendering techniques, with controllable toggles to turn features on and off depending on:

  • what's needed for each specific material
  • graphics quality/performance settings selected at build time, by the player at runtime, or by the level-of-detail system as the object recedes into the background
  • peculiarities of each target platform (eg. adaptations to differences in APIs, or optimizations specific to console hardware)

These then get compiled into individual shader programs (called "variants" or "permutations") for each unique subset of features used somewhere in the game, and each platform-specific variant.

So if we had a material with:

  • transparent & opaque versions
  • metallic & non-metallic reflection models
  • with & without a smoothness/roughness map
  • with & without an emissive texture
  • with & without parallax occlusion mapping
  • with & without a detail map / detail normal
  • baked or realtime diffuse lighting
  • with and without sampling a realtime reflection probe
  • DirectX vs OpenGL platform targets
  • high & low-quality presets
  • VR/stereoscopy support

Then we've already got over 2000 permutations just from that "one" shader!

This example is a little contrived, but not outside the realm of possibility. This article for example suggests that in Unreal 4, recompiling all shaders means around ~125 base effects multiplied to ~10 000 permutations, and Unity users report seeing ~6000 shader variants compiled under certain VR conditions.

So, as ballparks, "dozens to low hundreds" of root shader types is realistic, which may expand into hundreds or thousands of compiled shader programs in use, depending on the scope of the game and the number of different features/platforms it's trying to support.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.