Bake a texture from a geometric property of the faces in a mesh?
This script will generate a vertex color map, where each face's color is represented by a grayscale value matching the normalized distance of that face's center from the cursor, inverted (closer is brighter, farther is darker).

You can run this, then bake the vertex color to a texture file to get the image texture based on the distance. You can of course also use another object instead of the 3D cursor as your distance reference.

import bpy

o = bpy.context.object
d = o.data

if not d.vertex_colors:
    d.vertex_colors.new()

color_layer = d.vertex_colors["Col"]
curloc = bpy.context.scene.cursor_location

distances = [ ( p.center - curloc ).length for p in d.polygons ]

# Normalize distances
normalize      = lambda x, minX, maxX: round( ( x - minX ) / ( maxX - minX ), 2 )
minD, maxD     = min( distances ), max( distances )
distNormalized = [ 1 - normalize( v, minD, maxD ) for v in distances ]

for i, poly in enumerate( d.polygons ):
    for li in poly.loop_indices:
        color_layer.data[li].color = [ distNormalized[i] for c in 'rgb' ]