Setting the correct scene depth distance vs Blender depth map

I am trying to compare two depth maps:

(1) From Blender, which is a mist render that has a near of 0m and far of 10m (TGA file)
(2) To a scene depth

Here is the Blender render:

UE scene depth from a post process material

Here is the post process material:

I am building a RE style prerendered game that uses static camera angles. I need to compare the two depth maps to extract the player character. I am having some trouble trying to get the exact distance calculation on the UE scene depth to compare it with the Blender mist depth map.

In the material, I divide the scene depth by 1000 to make it equal to Blender’s 10m distance.

I am not sure what I am missing here. When I look at the preview in the material, it appears to work, but it doesn’t while in game.


Scene depth in unreal is not linear. This may be your issue, and would explain why the UE image gets much brighter much faster assuming the blender depth is linear. If this is the issue, you will need to convert either to the same form as the other.

You’re right, the Blender render is using linear. I tried using quadratic falloff in Blender, but I still get a slightly brighter render in UE. I am using a TGA format for the render, should I set this to a particular compression?

You will need to determine the exact formula used for nonlinearity in UE vs Blender to be certain that a certain distance from the camera plane equals the same value in both.
File and compression types will depend on how much accuracy you need. It won’t cause the issue your having but it can cause issues when it comes to comparing values.

Also why not just use a depth map generated in Unreal without the character to compare with the real time render with it. If the geometry is the same in both the blender scene and Unreal it shouldn’t matter which you use to generate depth but by rendering depth in UE you avoid the issue entirely.