I would like to export an image that looks like this directly from Blender:
I have three requirements:
- The depth is linear, and also based on distance from the camera plane (not distance from the camera).
- The edges of the object(s) are aliased. It would be great if the center of the objects are antialiased.
- 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:
The output (after removing the alpha channel) looks like this:
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.