Making The Most Of Depthmaps w/ Read Pixels

toneburst's picture

Anyone any thoughts on the best way of getting a reasonable level of Z-buffer resolution with the GL Tools Read Pixels patch?

I've tried making a load of cubes around the origin of the QC coordinate system (0.0, 0.0, 0.0), but I've found there isn't enough depth-variation in the visible objects to give a usable depthmap. What's the best way around this? I've tried adding a CIFilter to scale and offset greyscale values in the depth texture, but this just serves to highlight the poor resolution and resulting rounding errors.

Would it be best to create much larger objects, but push them back along the Z-axis, to get more variation in depth values, or is it possible/desirable to somehow reduce the spacial range of the depth-buffer itself by moving the Near and Far planes?

Anyone any thought?

a|x

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

yanomano's picture
Re: Making The Most Of Depthmaps w/ Read Pixels

Generaly in 3D softwares, to output a depth map, you need to put a camera then you can define the start and the end of the scene (in pixel or other). For each shot you have to define this distance to adjust the depth needed for the gradient. Near is White and Far is Black. 1 : the readpixel patch in depth mode seems inverted (not a problem you can invert color) 2 : to work properly it will need two news parameters to define the min and max distance (to remap values because the depth component is between 0 and 1) Perhaps internaly it have to read back the depth buffer values as an unsigned int ?

As you can see in the qtz that seems to work : there are 4 (very smalls) cubes that ar distributed in an approximate Z from 0 to 1

A quick solution is probably to scale your scene with the "kineme scale" patch ;)

PreviewAttachmentSize
Depth test.qtz5.73 KB
Depth_corrected.qtz6.35 KB

gtoledo3's picture
Re: Making The Most Of Depthmaps w/ Read Pixels

You are a hero... I kept using this going "depth buffer doesn't work right", and now I see it was that I was having the invert color problem and not realizing it. This is a really trivial workaround too (eg., no big deal to do). THANK YOU!

gtoledo3's picture
Re: Making The Most Of Depthmaps w/ Read Pixels

nevermind ...had a weird glitch...

toneburst's picture
Re: Making The Most Of Depthmaps w/ Read Pixels

Thanks yanomano, I will try that!

a|x

gutsblow's picture
Re: Making The Most Of Depthmaps w/ Read Pixels

This composition no longer works. Any ideas?