Using a custom property in a material

I’m wondering if there’s a way I can take an object’s custom property and use it in a material.

I have three objects all with the custom property MatVal and in this experiment I’m wanting to plug it in to the mix node so that the object’s property will affect the mix value. I’m not entirely sure how to do this though, so I’m hoping someone can point me in the right direction or give me some assistance.


CustomProperyMaterialTest.blend (454 KB)

As you may have noticed, there is not object input node. So there is no way to fetch the custom property in the node editor.
The only thing that comes to mind is that you could add a Value node to control the mix. Then write a script that fires in the scene_update or frame_change handler that examines the object for the custom property and then relays that value to the already existing Value node in your setup.

There may be other ways to achieve your goal, however. Why not just use multiple materials?

Mostly this is for me learning what I can and can’t do with materials. I’m trying to figure out the bounds of Blender’s material system, so I’m trying any sort of experiment I can to create whatever effect or utility I can come up with.