I want to turn a 3D mesh into a height map and then use the height map to create a new 3D mesh with no undercuts
If you use the 'Mist' feature:



then enable it in the camera settings:



then adjust the start and end point that it gives you to the start and end of the model, in the world settings:



And finally, in the compositing editor, connect the mist pass to the render pass, to give you a high definition 'depth' pass:



Hope this helped!