gluUnProject

I am trying to use gluUnProject and seem to be having trouble with the winZ value. I did an experiment using gluProject to see what kind of winZ value it would produce and they seem to be VERY nonlinear. For example, if an object is half-way between the near and far clipping planes (which are 1 to 1000), I would expect to get a z-value of 0.5 but that isn’t the case, its more like 0.999 or something. It appears that the near clipping plane starts with a winZ of zero (which is true by definition) but quickly accelerates towards 1 in just a short distance.

Can anyone please explain what’s going on here? Thank you.

if you give gluUnProject a winZ value of 0 you get the point on the near clipping plane. if you supply 1 you get the point on the far plane.

the results are non linear because the zbuffer itself is nonlinear. you can find more information here .

Thank you, that link told me everything. I would never have figured that out in a hundred years!