How to make one side of a mesh that's facing another mesh have a different material?

I’m working on a solar system project and I have the whole solar system in one blueprint . How do I make the planets have different materials based on whether they’re facing the sun or not?
I’m really confused … Your help would be appreciated !!