# How to render depth or surface Normal maps that properly reflect details of 3D shapes while respecting the nature of materials (transparency/glass)?

I am trying to render depth maps and surface Normal maps of different 3D shapes using Cycles. What I care about the most is how much of the details of the 3D shapes are captured in the depth maps or surface Normals. To obtain surface Normals I first do

bpy.context.scene.render.layers["RenderLayer"].use_pass_normal = True

or just click on Normal in RenderLayer settings and then render Normals.

I noticed that Blender's internal renderer is able to capture the details quite well as shown below (not for depth maps though). By details I mean the transparent materials such as glass are not affecting the Normals which is what I want.

However, a problem with the internal renderer is that the surface Normals depend on the camera angle which is not what I want. Even if there is a way to get camera view invariant surface Normal maps using Blender's internal rendering, this is still not going to be what I want due to some technical reasons. Here's the results:

Using Blender's internal renderer:

However, when I switch to Cycles I get the following rendering: here, although the surface Normals are invariant to the camera angle.

Although the Cycles materials also have properties such as transparency, the renderings do not capture any of the details that I am interested in. This is also the case when rendering depth maps as shown below.

RGB rendering using Cycles. As can be seen, the details shown here:

Rendering surface Normals using Cycles:

Depth map rendering using Cycles:

And here's the material nodes when using Cycles:

The headlamps are using a transparent material:

As you can see, all the details that I am interested in have not been captured in either the depth map or the surface Normal map when using Cycles. Does anyone know how can I create node trees (or through any other way) to enable Cycles capture detailed depth maps and surface Normals that reflect details of 3D shapes with respect to materials?

I also share the .blend file I used for getting these results:

I also upload the obj file used here with its corresponding .mtl file . Note that if you load the obj file in while Blender Render is activated, the material will only work for the Blender's internal renderer. So you may select Cycles and then import the obj file.

Download the obj file

## 1 Answer

Yes, if you make the transparent surfaces completely transparent they will not affect the normal and depth passes.

One way to accomplish this with your existing materials is by replacing the output with the "Alpha BSDF" Transparency node when the "Mix Color/Alpha" node is less than 1.

If you are doing this on many objects you may want to look into using node groups and python to automate things.

Also, you may want to add an edge split modifier to get rid of some of those artifacts near sharp edges.

• Thank you! This is great. I tried to replicate what you show here but I do not see any changes in the output after rendering. I updated my question with a new screen shot added. I may note that I do not change any of the other settings: just added nodes. What could I be doing wrong? I am using Blender 2.79. – Amir Feb 25 '18 at 23:02
• @Amir Your model has many different materials, and you'll need to do this on all of the materials which should be transparent (I just did it on the window and headlight materials). – gandalf3 Feb 26 '18 at 1:19
• Thank you. Do you think finding an answer to this would help in any way? Or should I just follow the path you recommended for finding node groups automatically? A bit irrelevant: Could you please take a look at this too? I am desperately looking for answer to this. I will delete this comment sometime tomorrow. – Amir Feb 26 '18 at 5:16