How to work with custom primitive data when material has multiple slots?

Hello. I want to use custom primitive data, but when the mesh has multiple material slots I’m getting message:


I suppose it happens, because ue doesn’t know which material it should change, so if I’ll assign same material for 2 material slots I’ll change value for 2 materials. How can I bypass this problem? I want to change values separately? I think there should be something like arrays of this values…

Your materials in your meshes need to have “Use Custom Primitive Data” enabled along with setting the index to the needed custom data index

So in this material indexes 0-> 3 will be used in this material

and for Material_001 I would set 4->7

I don’t understand… I’m doing it just like you:
created material:


Added mesh to the scene:

Trying to add material indexes 0 → 1 (good, but undeclaired, for some reason):

trying to add indexes 2 → 3:

No result, I still can’t control material in another slot. What am I missing?

You are using scalar values as custom data. They only have 1 value so if you have index 0 and 1 as the parameters, then only custom data index 0 and 1 work.

You would need to either have more parameters to fill in the next indexes of the custom data fields or use something like a vector if you want colors

(note that vectors have larger offsets so the next index would be the amount of pins in the vector)

You can always use the debug float node to show if the values are working inside of the material by setting it to the base color.

I’ve tried to replace scalar values with vector:


But the first parameter still controls both material slots (and my Custom Primitive Data Defaults is still looks different compared to yours):

I don’t understand why it doesn’t create second vector parameter, it just creates another scalar one.

You want two vector parameters both in separate materials and both need to have custom primitive data turned on.
The first one can have index 0 as it’s the first material
The second one needs to have it’s index offset by the amount of inputs inside of the first materials custom data node.

So if the first material starts with an index of 0 and is a vector 4 the it takes up 0,1,2,3 => so the next available index is 4 so have your second material’s custom index data start from 4.

Then when once you hook up the data just add the indexes and values in the custom data of the primitive.

Wait, will it even work if I have the same material instance in different slots?

The slot order doesn’t matter the custom index inside of the materials is what dictates what parameter it gathers from.

If you have the same materials instance one under the next then they will both use the same index internally so they will have the same value as the index is inside of the material.

Exactly! Is there a way to use the same instance, but separate it values? Or the only way is to create additional materials?

I doubt it, the primitive data index is not exposed.

There is per instance custom data node for instanced static meshes & hism’s so that each instance can have it’s own data.

You could just make a dynamic material instance and set a parameter

1 Like

Understood, thank you very much! Is this solution works only with blueprints?

You can do the same in blueprints and c++ (dynamic material instances)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.