Is it possible to change an object's color depending on its distance?
Animation Nodes can be used here. I shall show two methods for computing the distance between the objects and the camera.

Passing Camera Location To Cycles

The easiest and most efficient method is to use Animation Nodes to pass the camera location to cycles and compute the distance there through the Object Info Node. This is done as follows:



Notice that the distance between two points $A, B$ is equal to $\vert\vert\vec{AB}\vert\vert = \vert\vert\vec{B}-\vec{A}\vert\vert$. But for some vector $\vec{V}$, $\vec{V}\cdot \vec{V} = \vert\vert\vec{V}\vert\vert^2$ and it follows that $\vert\vert\vec{V}\vert\vert = \sqrt{\vec{V}\cdot \vec{V}}$ which is what we used to compute the distance above.

Using Vertex Colors

If more advanced computations are required, then you can compute the distance in Animation Nodes and pass it to cycles in the form of Vertex Colors. I compute the distance between the object and active camera, remap it by subtraction and division, though you can use the Remap Value Node if you are more comfortable with it, compute a color in whatever way you want, set the vertex color of the object to that color.



Why don't we use the distance a a Hue for the color?



Why don't we use the scale of the object as the saturation for the color?



I showed how to do that for a single object, however, you can do that for any number of objects using a simple loop: