Shader performances

Hello,

Speaking of performances, I wonder if it’s better to create many shaders doing few things or a single one doing many things.
/!\ My objects aren’t batched.

For example, is it better to have 2 surfaces shaders (1 with only a color property and 1 with only a texture property) or 1 shader with both properties (and then setting white if not wanting the color and no texture if not wanting texture) ?

Because maybe it has a cost for the GPU to change the shader, but if it’s not batched I wonder if the cost will still be there anyway ?

It’s quite hard to profile and it would be great if we could have a way to measure it.

Thanks

Technically, since the objects aren’t batched, it would be better to have the two separate shaders yes. But you also don’t want tonnes of different shaders stuffing up the shader caching pipeline. Adding a color component to multiply the texture by is a very miniscule amount of processing for a GPU, not really something to worry about unless you’re doing some seriously legacy hardware stuff.

Even if the objects aren’t batched, shaders are still shared. Batching merely saves on draw calls, it doesn’t duplicate the shaders if the shader already exists in memory.