Page 1 of 1
Depth channel: Non-linear ?
Posted: Tue Jun 02, 2015 1:44 pm
by deadalvs
Hi,
When I activate the rendering of the depth channel (16 bit), I find that the distance depicted in the grey scale values seem not to be linear. Means along a very long linear geometry (oriented along camera direction), the 'depth gradient' suddenly switches from white to black short before the 'max depth value', when it should be a smooth, linear gradient.
What could be the issue ?
Any input welcome!
Matt
Re: Depth channel: Non-linear ?
Posted: Tue Jun 02, 2015 2:02 pm
by Mihai
Could you please post a simple scene and render?
Re: Depth channel: Non-linear ?
Posted: Tue Jun 02, 2015 3:56 pm
by deadalvs
Hey Mihai,
thanks for the reply!
Sure ..
https://www.dropbox.com/sh/g6dbdseuuc1y ... 8UoRa?dl=0
Notes:
- The cubes are each 100 meters wide, so the total length of all geometry is 1300 meters
- Note that the depth gradient fades off from light grey to black almost immediately at around 250 meters away from the camera, which is weird. The gradient has a kind of exponential feel to it, not linear ..
I render the image in 16bit.. can this be a conversion issue from 16bit to 8bit ? Or do I look at the picture in a wrong color space ?
The target application I need the gradient for is photoshop, do add haze.
Thanks,
Matt
Re: Depth channel: Non-linear ?
Posted: Tue Jun 02, 2015 6:24 pm
by Mihai
But you've set the far distance too short, at 250m. You're specifying that's where you want the z channel to be completely black. The idea is that you need to set the z depth near/far range to encompass your scenes objects. So that to have the biggest range in the z depth channel, the closest geometry should be 255 in the z channel, and the farthest 0, or almost 0. In your scene I've set near to 130m since that's about the distance of the nearest object to the camera, that's where you want it to be 255, and the far to about 1100m.
In the main render window when rendering, display the Zchannel and run your cursor over it and look in the lower right to see the values. This way you get an idea if you have the right range. Also compare with the main render to check that the z channel isn't clipped too soon.
Re: Depth channel: Non-linear ?
Posted: Tue Jun 02, 2015 8:19 pm
by deadalvs
Hi,
Yes, the black point is set to 250m. it was not the intention of this example to have a gradient to the last end of all the geometry at 1300m.
Please have a look at 'depth_annotated.jpg'
The actual thing I mean is that just a few pixels to the left of where the depth color actually 'hits' 0% white, there is still whopping 16% white. I'm not sure if this is an optical illusion, but the falloff from left to right visually looks like dropping to black almost immidiately. The little vertical gradient between the values above the green and red arrows.
Maybe I need glasses, hehe.
m.
Re: Depth channel: Non-linear ?
Posted: Fri Jun 05, 2015 5:49 pm
by Mihai
Oh, I didn't realize you wanted to limit that range on purpose

Well I don't think there's anything abnormal here, it can get confusing with screen space vs scene space and also that you are mapping a fixed 0-255 range into an arbitrary range of space. The zchannel is linear in the scene space sense, but not necessarily in screen space. What I mean is, if you look at your annotated render, a few rows of pixel on the far right side represent a difference of 10m in scene space, but on the left hand side, because this part of the model is closer to the camera, 10m would be represented by a lot more rows of pixels, so naturally the falloff is a lot more gradual (in the render itself). Does that make sense? For example, I can have a totally non linear zchannel - I set it to 147m near and 148m far. Depending on how far the camera is to the actual model, and how big it actually is, I can get a completely white cube in the zchannel with no falloff at all. I think it's always the best idea to try to get the most accurate mapping of the 0-255 to the total scenes scale (or better said, to the total range of stuff the camera sees in a given frame). This way you get the best distribution. Won't the plugins that use the zchannel also work in the most predictable way also?