Scaling material per object

So I found this nifty thing here Tutorial for a scaling material around a Pivot Offset but what I need is to scale the material into the objects insides the mesh, for example: Mesh with 4 cubes so the scaling should be into each one of the cubes. As I understand it can be done somehow with vertex normals but I can’t really succeed in doing so, any advice?

Sounds like it would be easier if you had separate meshes…

You could use vertex colors as mask to determine which object should scale.

I wish but what if I have a mesh with hundreds of cubes…

Not sure how what will help in this case…