Re: depth values in picking
Posted by Mathieu Blossier on
URL: https://forum.jogamp.org/depth-values-in-picking-tp4030347p4030373.html
Hi,
I know that picking is deprecated, but I've never noticed any problem with it. Furthermore, for my use, it always takes less than a frame rendering, so it's ok.
About depth, I think I've found a quite correct function to map values returned to screen z value :
f(z)=eyeToScreenDistance*(z-1-d/eyeToScreenDistance)/(z-1-eyeToScreenDistance/d);
where :
* z is the min/max value returned, 0 for near plane and 2 for far plane
* eyeToScreenDistance is the distance from eye to the screen, which for me is in the middle between near and far planes
* d is half the distance between near and far planes
I've tested it and got good results (error less than 0.001), to improve it I think the function needs something like sqrt((z-a)²+b²) corresponding to some normalization.
I've tested it only in cases where the screen is in the middle between near and far planes ; and where d is also equal to screen view width.
Cheers,
Mathieu