Z-Depth map Tutorial

Posts: 16
Joined: Thu Mar 03, 2016 11:37 pm

Z-Depth map Tutorial

Postby owakulukem » Mon Oct 03, 2016 3:29 pm

This is over in the General section of the forum, but I figured it would make more sense over here.

I have messed around with trying to get the z depth map out of lux before, but was never able all due to one thing. Photoshop does not natively support all the layers in a .exr file. I didn't know this so I spent many an hour trying to figure out why my z depth map was not showing up as a layer. There is a plugin for Photoshop called ProExr that will extract all the layers of a .exr in PS. This is the optimal solution as the file will remain 32bit, but I was looking for a free solution. I spend too much money as it is on my 3D hobby :mrgreen: .
So with a lot of help from others, especially jensverwiebe over at the lux forum, here is a tutorial on how to get the z depth map into a usable file:

First we will need to edit the .lxs file. So make sure the Export Only box is checked in Reality. Open up your favorite text editor - I like Notepad++.
Add the line:

"bool write_exr_ZBuf" ["true"]

I added it to the end of the Film "fleximage" section


Open the .lxs in lux and render.
Once rendering is completed Export to Image as a High Dynamic Range Image, after you name your file (I named mine "test", I know-real original ;) ), a new dialog box will appear. Make sure that the Include Z Buffer box is checked. Without adding the code above into the lxs file, you will get an error in the log. Thankfully the log tells you to add that line.


This will output "filename".exr. Now it's time to extract the z depth layer from the file.
Open Blender. In the bottom left hand corner open the Node Editor

Make sure that Use Nodes near the bottom is checked. Then add the following nodes (see the image below):
Input (Choose the exr file that was saved from lux)
Map Range
Invert (not really necessary)
*before adding the FIle Output node make sure that in the right hand corner you have designated the desired file format (jpg or other)*
File Output (this will only designate a filename and location to save)

Use the following values:

On the menu bar select Render -> Render Image
This will render your z depth map as a jpg or whatever else was designated into a folder that will be named the same. You may not get anything visible in Blender on the render screen, but the file will be output.


Now we can use this map to control bokeh and other fun stuff in Photoshop.
Here is a good tutorial on how to use the map in PS:

Here are my two images

Without the z depth map

And with the z depth map using the youtube tutorial

User avatar
Posts: 437
Joined: Sat Jan 24, 2015 3:59 pm
Location: Denmark

Re: Z-Depth map Tutorial

Postby sigstan » Mon Oct 10, 2016 3:37 pm

Thanks. Very interesting technique. Had no idea what you could use the Z depth map for.

Return to “Tips, techniques, and recipes”

Who is online

Users browsing this forum: No registered users and 1 guest