This is rather easy to do with an object that has a MultiResolution modifier as you mentioned. Such a mesh offers the possibility to bake the displacement from the base mesh to the subdivided one into a 32bit displacement map, and re-use that input for color ramps to drive the material color. Such a workflow also allows you to clearly distinguish between indentations and elevations as a bonus.
First, create your mesh as usual, and make sure there is a proper UV map to it. This UV map is critical for baking, so the better the layout, the better the displacement quality. Sculpt your detail into the MultiResolution modifier.
Next, create a texture of a reasonable size (I chose a 2K image in this example), and make sure it uses
32bit Float. This will make sure that there is enough image depth available to avoid banding artefacts in the texture, making it perfectly smooth:
Now create a material on the object, and use the image in the node tree, connecting it with the UV map. It doesn't matter yet where you connect the texture to, but you can already pipe it into a color ramp and the result of that into the Shader:
Now make sure that the image texture node in the Shader Node Tree is the active node (white highlight frame around it):
You are now ready to bake the displacement. The mode we will use records the difference between the
Preview level of the modifier and the highest sculpt level, so in general you will set the preview level to
0 before baking:
Go to the
Render Properties tab in the Properties Editor, and open the
Bake Panel. Set the options as follows to bake the Multires Displacement data into a map:
By now, your object should look like this:
And after re-enabling the
Preview subdivision levels to the max, like this: