As most of us know, Blender lacks proper height map baking when it comes to transfer of surface data from high poly models to low-poly ones, which is just mind-boggling to say the least.
Fortunatelly, there’s a workaround for that that employs two position maps, a layer mask, as well as a single normal map from which can fairly accurately calculate the height. In addition to that, an algorithm for smoothing out abrupt height differences (in the final baked resut) has also been developed that conveniently alleviates users from having to make sure that certain elements on their objects are tapered before the baking process in order to minimize stretching artifacts.
It’s also worth mentioning that the resulting height map name contains critical information such as “d” that stands for depth which is followed by the first digit and its decimals separated by “_” and “o” for offset that contains the follows the previous structure. Depth in this case refers to what the actuall deepest depth or “height” was detected during height map calculation while offset pertains to the amount all of the height data had to be offset in order for the smallest value to be grounded (0.0). In essence these two pieces of important information were used to “accurately” map the original extracted height data to 0 to 1 range and thus when being used in your software of choice can help to more accurately reconstruct the height data.
You’ll note that there are three scripts in the file, one which only pertains to height map “baking” while the other one is for more general baking (including normal, ao, position etc.). This is so that those that are particulary interested in height map creation process would have an easier time deciphering it, as it has maps used for height map construction exposed in the UI.
Parallax occlusiong mapping node setup is by @justry while the slightly modified door was made by Mziemey from Blendswap. They are only used for height map testing purposes and nothing more.
Provided code is not considered to be a final product nor does it tend to portray itself as such. It definitely requires further attention.
P.S. Make sure that before baking all of the objects present in all three collections are also visible/enabled in the scene.
Door_POM_Compressed.blend (4.6 MB)
