Say that I have a cube. I'd like for it to change into one of 5 colors: black, red, green, blue, or white depending on which direction the camera is facing towards it.
If the camera moves to face the cube's right side, for instance, it will turn green. The same concept applies with the other parts (front, back, and left), each color blending into the other. The cube then would default to white if the camera faces either the top or bottom.
See the gifs below:
The cube would be free to rotate on its own without having to worry about its color changing. It would only be the camera that would affect it.
How could that be done in Blender (specifically EEVEE) using nodes/drivers? I really don't want to use scripts if I can avoid them.
EDIT:
I should probably add that the closest I've gotten thus far is in separating the Incoming vector (from the Geometry node) into separate color channels, however it poses this issue:
It's so irritatingly close to a solution, yet the lack of solid coloring renders it useless for my purposes.