Change material if in shadow, like in the gif animation

There are ways you can fake it, sure. Distance probably isn’t ideal. Material Parameter Collections can pass values from a blueprint into the material, such as a point is space to measure distance against. But the number of vectors needs to be pre-defined, you can’t just keep adding more points, and every point you add makes the material more expensive for all of the objects using it, even if they are nowhere near those points. And since distance is measured against a point, it would be a spherical mask, not a box.

You could also just stick a decal on them to color them. You could just manually select them and change their material.

If it is totally static and will never change, then you just pre-compute it once when the object is added to the scene.

Someone might be able to offer a better solution if they knew what exactly you’re trying to achieve and under what conditions. Is it visual only, does it need to impact gameplay somehow? Is it 100% static, or will the object or light move at any point during runtime?

There’s endless ways you could achieve something, but there’s probably only one best way and it’ll depend on your use case. But without that information people are just shooting in the dark.

Also, all of this only works if you’re only concerned about the sun. Once you try to factor in a second light, all of the costs and challenges double.