Color objects based on distance in Animation Nodes
You can use the Set Vertex Color Node to color the objects, I will compute the distance between an empty and some objects, then loop over the objects, create a color based on the distance and set it:



The previous tree uses the distance as the hue, which produces:



But we can use it as the value for instance:



To use the vertex color as the color in a material, we check Vertex Color Paint in the material options:



Lastly, if you are using the Object Instancer Node to make the objects, make sure to check Deep Copy making each of the meshes independent. And of course, give the source object the required material.