18
$\begingroup$

This setup seems like it should work, but it doesn't.

$\endgroup$
18
$\begingroup$

enter image description here
and another, more tunable. enter image description here

the Z-buffer isn't really an image but a grid of distance values mapped from camera clipping start, and end (these settings are found in the Camera Object properties tab).

Use the limits tickbox to visualize the clipping start and clipping end range, (also called near and far clipping planes). Generally keep all your geometry in that range and you will be using the Z-Buffer like a boss.

PS: instead of the Map Range node, you can use the Normalize node and you won't have to set the range values, it will find the lowest/highest values in the Z-buffer and map them to 0...1 range

enter image description here

$\endgroup$
15
$\begingroup$

The value outputted by the z pass is in absolute units, going from zero to however far the objects in the scene are. Thus it goes over the color ramp's range of values, and gives out the value that maps to full 1 in the ramp.

You can fix this by adding a normalize node before the color ramp, or by multiplying it by some small value with a math node. The normalize scales the range from the smallest value to the largest to map into the 0-1 range, so the results of all objects change if you animate the furthest or closest object. A math node does not have that limitation and thus works better with animated scenes.

$\endgroup$
1
  • $\begingroup$ Oh, I forgot the map range node, it would be the best solution for this situation. Basically it's the same as normalize but it has settings to work around that problem I mentioned $\endgroup$ – hjaarnio May 31 '13 at 11:10

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.