0
$\begingroup$

I would like to export an image that looks like this directly from Blender:

Depth map of cube

I have three requirements:

  1. The depth is linear, and also based on distance from the camera plane (not distance from the camera).
  2. The edges of the object(s) are aliased. It would be great if the center of the objects are antialiased.
  3. The background is black, the farthest point is black, and the nearest point is white.

To solve #1 I use "Mist" instead of "Z". For #2 the only solution I've found is to export Z instead of Mist (I think I found a solution with Mist at one point where I just had to remove the alpha channel, but haven't been able to reproduce this). The really tricky one is #3. I thought using the "Normalize" and "Invert" nodes would solve it, but they don't. Here is my process:

  • Open new project.
  • Go to compositing view.
  • In Properties area, click "View Layer" icon. Under "Passes" check "Mist".
  • In Properties area, click "Render" icon. Under "Film" click "Alpha" dropdown and select "Transparent". Under "Color Management" for "Display Device" select "None". Under "Look" select "None". Under "Sequencer" select "Raw".
  • In Properties area, click "World" icon. Under "Mist Pass" set the approximate distance to the nearest point in your scene (better to underestimate) and the approximate range from the nearest point to the farthest point in your scene. Set "Falloff" to "Linear".
  • At top of Compositing area, check "Use nodes" checkbox.
  • Drag "Mist" output to "Image" input.
  • Add "Normalize" node and insert it after "Mist" output.
  • Add "Invert" node and insert it after "Normalize" node.
  • In Properties area, click "Output" icon. Under "Output" next to "Color depth" select "16". Next to the output path, click the folder and select your Desktop.
  • In the Dope Sheet area at the bottom right, click next to "End:" and type 1.
  • In the toolbar, click "Render" then "Render Animation".

The compositing graph looks like this:

enter image description here

The output (after removing the alpha channel) looks like this:

Low contrast depth map of cube

How can I get full contrast here? I imagine the problem is that normalize is using all the pixels, but I only want it to use the non-transparent pixels. I tried this approach and it helps increase the contrast partially, but not fully.

To be super clear, by "normalize" I don't mean "values somewhere between 0 and 1". I mean "values from 0 to 1, where the smallest value is 0 and the largest is 1". I'm aware that the mist pass is already normalized to the Start/Depth parameters. Essentially, I want the Start/Depth values to be computed automatically for my scene.

$\endgroup$
4
  • 3
    $\begingroup$ You don't need to normalize the mist pass, it is already in values between 0 and 1. Just set the correct ranges and set the falloff to linear. related.blender.stackexchange.com/questions/43638/… Also, when you save your image make sure that you save it with the color management set to None,to keep it linear. $\endgroup$
    – user1853
    Feb 25, 2019 at 6:32
  • $\begingroup$ thanks @cegaton, the color management and falloff notes are super helpful. it sounds like there is no way to automatically normalize the range to the nearest/farthest pixels, i can only set it manually? $\endgroup$ Feb 26, 2019 at 0:19
  • 1
    $\begingroup$ Again... there is no need to normalize. The extremes for the scale, when using mist, depend entirely on the range set by Start and Depth of the mist settings. Start would be 0, Depth will be 1. Please read the link in the comment. It's all explained there. $\endgroup$
    – user1853
    Feb 26, 2019 at 0:45
  • 1
    $\begingroup$ thanks @cegaton. i read the link again, and i understand that start is 0 and start+depth (not depth directly) is 1. i want to know how to automatically scale start/depth to my scene when "eyeballing" isn't accurate enough, and when i have to set these parameters on lots of frames. $\endgroup$ Feb 27, 2019 at 1:24

0

You must log in to answer this question.

Browse other questions tagged .