1
$\begingroup$

I need to get a height map of many objects covering each other. It's exactly like the Z-buffer. I need this to simulate a laser scanner output.

My scene looks like this: Scene image

I have seen some tutorials and understood I need to set texture to blend based on Z coordinate. But I have not found a way, how to set the texture to all objects at once. I tried to use a group, but then I did not find any mapping by Z coordinate settings.

Could you please advice me? Is it even possible to get height map of bunch of objects? Is it possible to set texture to objects by python script? Some other ideas?

$\endgroup$
  • $\begingroup$ Once you set up the material it will work for however many objects you have. You can copy material by selecting all the objects and the one you want to copy from last so it's active (yellow color) and hitting CTRL-L. To create height-blended material check this post blender.stackexchange.com/questions/67142/… $\endgroup$ – kheetor May 8 '18 at 11:50
  • $\begingroup$ Why not just use the Z pass and the resulting depth map? $\endgroup$ – David May 8 '18 at 12:22
  • $\begingroup$ @David Sorry, I have nearly no experience. Could you please describe me a bit more, what you mean? $\endgroup$ – google2 May 11 '18 at 18:54
  • $\begingroup$ Do you want an image of all the objects (a depth map, height map,)? Or do you want to texture all the objects biased on their position? I was assuming the former, but not am not sure. $\endgroup$ – David May 11 '18 at 19:21
  • $\begingroup$ @David I want a height map of all objects. But the only way I found to do this was texturing objects based on their Z position. Is there another way how to get haight map? $\endgroup$ – google2 May 12 '18 at 11:17
0
$\begingroup$

Set your camera above the objects looking straight down. In the Render Layers tab of the properties window make sure the Z pass is enabled.
The rest of the settings are just to speed up the rendering. I used a plain emission shader as the override material. I set the samples to 1, turned off the denoising and the "Use" options: "Use Environment," "Use AO," and "Use Hair."

render layer settings

Now If you look at the rendered depth pass it will look all white. However all the data is there. (A 32bit exr would show you it in other programs.)

In the compositer drop a Normalize node between the Render Layers Depth output and a viewer node to see what is really there.

animated gif showing the rendered passed and the normalize node

Little side note. Notice the banding on the cube in this gif. That is why you should save the depth map using a high bit depth. If you use a normal 8 bit image it will not be able to store all the information and you will end up with stepped ridges instead of a smooth gradient along the different heights.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.