Page 1 of 2

Problem with Z-Depth output

Posted: Wed Feb 26, 2020 10:57 am
by juangea
HI there.

We are using the Z-Depth for the support of Layama app in Blender/LuxCore.

But it seems the Z-Depth channel is acting werid, in this picture you can see an Eevee (Left) vs LuxCore (Right) output, I don't understand why is there such a big difference in the Z Depth output:
z_depth_compare.jpg
This leads a problem in the geometry calculation for the webapp, Left is LuxCore Z-Depth result, Right is Eevee Z_Depth result:
z_depth_geo.JPG
Some ideas on why may this be happening?

Some setting?

Thanks!

Re: Problem with Z-Depth output

Posted: Wed Feb 26, 2020 11:14 am
by Dade
LuxCore Depth AOV is the distance from the film image plane, may be Eevee uses something different like distance from the camera position :?:

Re: Problem with Z-Depth output

Posted: Wed Feb 26, 2020 12:45 pm
by juangea
Yes, I think Cycles/Eevee give the Z pass from the camera position, is there a way to counteract this?

Thanks!

Re: Problem with Z-Depth output

Posted: Wed Feb 26, 2020 12:53 pm
by juangea
And another qustion, trying to find an alternative option, the "Position" AOV inside the Geometry section, is World Position or Camera Position?

Re: Problem with Z-Depth output

Posted: Wed Feb 26, 2020 1:09 pm
by Dade
juangea wrote: Wed Feb 26, 2020 12:45 pm Yes, I think Cycles/Eevee give the Z pass from the camera position, is there a way to counteract this?
I can add a new AOV with this information (in v2.4). However I would further investigate the topic of Cycles/Eevee Z pass just to be sure how they work.

I don't think there is a viable work around at the moment aside form using the (first hit point) Position AOV and doing the math (<position> - <camera origin>) :idea:

Re: Problem with Z-Depth output

Posted: Wed Feb 26, 2020 1:46 pm
by B.Y.O.B.
juangea wrote: Wed Feb 26, 2020 12:53 pm And another qustion, trying to find an alternative option, the "Position" AOV inside the Geometry section, is World Position or Camera Position?
World position.

Re: Problem with Z-Depth output

Posted: Wed Feb 26, 2020 4:54 pm
by juangea
I think we will be able to use the POSITION AOV since it's World Position, instead of the Z-Depth, so we are fine :)

But could be a good idea to have a Z-Depth, in the future, that measures the things in the same way as Cycles/Eevee, just ot make easier the life of compositing people in mixed pipelines or with already defined pipelines and comps.

Re: Problem with Z-Depth output

Posted: Sat Apr 04, 2020 9:53 pm
by CodeHD
Hi,

I've been investigating the depth AOV a bit after yesterdays discussion in the radio-modelling thread.
After far too much unneccessary checking, I've noticed the following (blend-file attached for a test setup - camera at centre of a hollow sphere carved into a cube):

With LuxCore standalone, I get distance from the camera plane for ortho camera:
Console_Ortho.png
and distance from the camera point with perspective:
Console_Perspective.png
Rendering and saving from Blender, however, I get something quite different:
Blender_Ortho.png
By my observations it is some factor times Dot(RayDirection, SurfaceNormal)^3
The World position AOV gives exactly the same output btw.

I tried following it through the code myself, but in blendluxcore i stalled at engine/final.py, _add_passes(), where I can't find the definition of eninge.add_pass(), also not in LuxCore. I assume it is part of pyluxcore? Or did Visual studios search just fail me?

Am I missing some switch in Blender here or does it really parse a wrong output?

Re: Problem with Z-Depth output

Posted: Sat Apr 04, 2020 10:04 pm
by B.Y.O.B.
CodeHD wrote: Sat Apr 04, 2020 9:53 pm in blendluxcore i stalled at engine/final.py, _add_passes(), where I can't find the definition of eninge.add_pass()
It is a Blender API method: https://docs.blender.org/api/current/bp ... e.add_pass
But it's not important to your problem.
You probably want to look at the LuxCore code where the depth AOV output is computed.

Or maybe this?
https://github.com/LuxCoreRender/LuxCor ... r.cpp#L166
It is used in the addon here: https://github.com/LuxCoreRender/BlendL ... nal.py#L25

Re: Problem with Z-Depth output

Posted: Sat Apr 04, 2020 10:43 pm
by Dade
B.Y.O.B. wrote: Sat Apr 04, 2020 10:04 pm Or maybe this?
https://github.com/LuxCoreRender/LuxCor ... r.cpp#L166
Depth value will be INF if nothing is hit and, in this case, the above code will obliterate all depth values :idea:

The above code should check for INF values and ignore them in order to compute the max value.

Anyway, I find it very strange, the scale will change according the farthest hit. It doesn't make sense to me, from the above code, I guess Blender expect depth values bet 0.0 and 1.0 ... but according what metric ?