Cycles Node to tell Distance from an Empty
You can use Drivers to do this.

Add a value node, then right click on the number button and select Add Driver


In the Graph editor, switch to drivers in the header:


Select the driver on the left panel, then set it to Sum values or Averaged value to avoid your driver being blocked by the python security features. Then set the variable type to Distance and select the empty and the object to which the material is assigned. Unfortunately there doesn't seem to be a way to reference the object(s) to which the material is assigned without specifying them individually with separate drivers.