Depth channel workflow

Trying to figure out how to work with z-depth channels. First problem is how to get the depth into a suitable range?
Using a level TOP kinda works, but I quickly get some banding (see attached file). Also, how would I automatically shift it into an appropriate range?

Thanks
Achim
depth.7.toe (3.43 KB)

Play around with the camera’s near and far planes. The depth resolution is spread over the camera’s view frustum, so minimizing this volume will maximize the depth map’s detail.
depth.8.toe (3.36 KB)

1 Like

If your going to do operations on a Depth Buffer, make sure you are working in 16-bit or 32-bit float pixel format. The Depth TOP creates a 24-bit image, but it’s not possible to do TOP operations on this format. Working in 8-bit will destroy the precision of your data. I guess a RFE would be that TOPS automatically work in 16-bit when they have a 24-bit depth buffer as input.

Graphics cards do some pretty fancy things with depth buffers so its hard to get apples-to-apples comparisons if you take two depth buffers and try to do things with them together. For example a depth buffer from an antialiased scene will be quite different than the depth buffer from the same scene without antialiasing on.

As Ben said though, the Near/Far planes are the main way you manipulate the depth buffer. Objects at the near plane will have a depth value of 0, objects at the far plane will have a depth value of 1.

Malcolm

But in the attached example, the 24-bit depth TOP is fed into a level TOP, and the level TOP works (but it converts to 8 bit)

So if I antialias the render TOP, any depth TOP referencing that render TOP will also be antialiased, correct?

Regarding the near/far planes as z-depth range, what about situations where I’m passing closely over some geo. In order to actually see the geometry, I need a very low near value. But as soon as I go <1 for near, the z channel very quickly becomes light-grey to completely white. For example, in the attached file, decrease /cam1 near plane slowly towards 0 and /depth1 will become very “light”
Wouldn’t a separate near/far depth plane value make sense?

Also, if you look how /text is represented in the z-depth channel, you see that transparent areas get the z-depth value of the geometry itself, and not from the geometry behind the transparent areas. How can I fix this?

Thanks
Akeem
dof_test.27.toe (5.95 KB)

Right, sorry let me make that clearer. You can use 24-bit depth TOP images as inputs to other TOPs, but you’ll lose precision unless you are using 32-bit pixel format.
Along with this, depending on the TOP, you may lose precision due to other reasons. The Level TOP in particular is bad for this, as it uses a lookup table internally so no matter what your doing to lose precision (even if your rendering into a 32-bit TOP). The lookup table only has 256 values per channel, far less than the number of possible values a 24-bit depth TOP will create.

I’m not sure if the concept of antialiasing really makes sense in terms of Depth Values, but yes antialiasing will affect the values in the depth value in some way (depends on the graphics card)

I wouldn’t get too hung up on the ‘color’ of the depth TOP. Its normal for it to look almost completely white unless you have your near/far really tight around your objects. Don’t be fooled by the color though, since it has 24-bit precision, your full white image is still full of very unique values.

I’m not entirely sure what you mean here, but the near/far value is only used in the depth calculation. Object disappear because as a rule OpenGL doesn’t rasterize anything that falls outside of the near/far plane.

You can turn off ‘Write Depth Values’ in the MAT for that object. Be warned that if you do that though anything that is drawn after that text will get drawn over it, regardless of if it’s behind or infront of the text. Alternatively you can use the Alpha Test to discard pixels from that geometry that have an alpha below a certain threshold. This will cause the letters to still write a depth value to the depth buffer, but not the rest of the rectangle that has a alpha < the threshold you specify.