Is there a distance-based texture for Blender?

Kinda related, but you can also shade one object based on the angle towards another object: