Baking displacements to texture between arbitrary meshes?


Hi !
With sculpt objects, it is possible to bake a high poly object to as a scalar displacement map onto a low poly version, using a raycast algorithm to find the distance between the low- and highpoly versions.

Is there any way to do the same thing between arbitrary meshes, i.e. non-sculpt objects? So if I have a low-poly and high-poly version of the same objects, and want to bake the high-poly geo as a scalar displacement map onto the low-poly, tracing rays to determine the distance (along the normal) between the objects?

I have not been able to find a way to do this, so I am considering writing a plugin shader that traces distances between two objects, that could then be baked to a displacement map. Before I spend time on writing something like that, I wanted to check that I am not missing some simpler way of doing this.