3
$\begingroup$

I'm rendering blender's z-buffer to an image using render layers under compositing in cycles, but I'm noticing unexpected results.

Here is an example of a typical z-buffer render (not from blender). A flat plane will appear as a vertical gradient:

Typical Z-Buffer

Here is blender's render of its z-buffer. A similar flat plane appears as a radial gradient:

Blender Z-Buffer

I'm not quite sure what logic blender is using to represent depth. Is there a way to make blender's z-buffer behave more typically, where each pixel of the buffer represents the shortest distance from the camera viewing plane (the plane defined by the camera's normal)? If not, is there a way to get blender to render a scene like that without using the z-buffer?

EDIT: Here's a .blend file that demonstrates the z-buffer's strange behaviour. Hit render and it should show a radial gradiant on a flat plane.

$\endgroup$
2
$\begingroup$

Cycles - is a path tracing render. It's mean that the distance in z-buffer is real distance between the plane and the camera, because it calculated by measuring a light path traveling from the camera to the plane in every point of image.

If you want fake z-buffer, you can chose default "blender render", and you will see your expected result.

$\endgroup$
2
$\begingroup$

It does make sense that it's radial if you think about the distance from the camera: enter image description here

It should be more apparent with wider lenses as well. If you were to use depth pass for something like fog or smoke or volumetric effects, this would not give you any issues and in fact it is even more physically accurate. I would say it might be hard to perceive the difference in practice.

If you had some reason for staying with Cycles and needed to render the other type of depth pass, you could render it in a separate render layer with a material override using z axis of camera's texture coordinates controlled with some maths nodes to scale(multiply) and move(add) it: enter image description here

Since it's emission shader it does not need many samples to render so the added render time should still be reasonable.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.