Choose map by material ID in material node

Hi! Fresh newbie question here.

Here is my situation. I have material in which i generate, say, four procedural masks (modified gradient and stuff).
By one of these masks i blend two materials (map by map).
I want my material, when assigned to an object, to pick a specific mask according to material ID of the object parts.
Is it possible without setting separate materials for each mask?
Is there a node in material node editor/blueprints that will return material ID to use as a switch or something?

Grateful for any input on the matter and ready to clarify anything if some part of my question were clumsily worded.

Thanks for your answer. sad face
OK, so, please correct me if i’m wrong (again, total newbie here) - if it’s doable in Blueprints it might be packaged to material function or something like that to use in material editor? Or is there Blueprint functionality that couldn’t be translated to material editor that easily?

I think there was some function in Blueprints/C++, that can return number of material IDs, but not in material editor.

Basically, material knows almost nothing about mesh it applied. It’s only material that handles pixels.

No, you cant use it as material function, but you can

  • create blueprint from actor class
  • add static mesh component to it
  • get mesh material ids
  • create dynamic material instance and apply to all material ids in this mesh
  • pass material ids as parameters to dynamic material instance.

this is how it may be technically, but I’m not understand what exactly you want to achieve, so maybe I’m wrong.

From what you’ve described it seems exactly like the thing i want to achieve! To pass matID as a parameter to a material at some point that is. Thanks again. 8)
Back to googling/coding study for me then, i guess.