Different texture or shader params on same material

If I have a bunch of objects with the same material, but I want to set different params for the shader on each of them, can I do that? As far as I understand, a shader and a material are in 1-to-1 relationships, and if I change parameters in the shader, all the objects will be visually affected?

Clone the material. then you have multiple instances of the same shader but different instances of the material/uniforms.

So, the recommended way is simply to increase the number of materials to fit the objects count? Or does cloning maybe do some memory consumption optimisations?

When you said “multiple instances of shader but different instances of material” did you mean that cloning a material will keep using the same shader on the video card?

@noncom said: So, the recommended way is simply to increase the number of materials to fit the objects count? Or does cloning maybe do some memory consumption optimisations?

When you said “multiple instances of shader but different instances of material” did you mean that cloning a material will keep using the same shader on the video card?

It reuses the shader unless you set a uniform that is linked to a define… then it has to recompile the shader and you will end up with another copy. Otherwise, the shader is shared across material instances.

If you need different uniforms per object then right now you also need different materials per object.