Jump to content
  • Advertisement
Sign in to follow this  
gorgorath

glreadpixels and gluProject always return 1

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Underneath code is gives always 1 back (well 0.99999) newPoint.setTo(p.get(i), p.get(i+1), p.get(i+2)); if(currentCamera.pointInFrustum(newPoint.getX(), newPoint.getY(), newPoint.getZ())) { get2DProjection(newPoint.getX(), newPoint.getY(), newPoint.getZ(), imageViewport, projection); which is strange, coz those points are not on the far plane? any solutions? tia Paul

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by gorgorath
Underneath code is gives always 1 back (well 0.99999)
newPoint.setTo(p.get(i), p.get(i+1), p.get(i+2));

if(currentCamera.pointInFrustum(newPoint.getX(), newPoint.getY(), newPoint.getZ()))
{

get2DProjection(newPoint.getX(), newPoint.getY(), newPoint.getZ(), imageViewport, projection);


which is strange, coz those points are not on the far plane?

any solutions?

tia

Paul
Mind posting your actual OpenGL calls? I think your problem is the very common one of losing depth precision because of having your near plane too close and/or your far plane too far away. But I can't be sure without seeing any OpenGL function calls.

Share this post


Link to post
Share on other sites
initially the nearplane was set to 1 while the far plane was 1000000.
which seems imo good, coz the points are scattered over a range 10000. so the z values should at least show some variation.



changing the near/farplane didn't lead to other results.

edit: the projected x, y values are correct

Share this post


Link to post
Share on other sites
Quote:
Original post by gorgorath
initially the nearplane was set to 1 while the far plane was 1000000.
which seems imo good, coz the points are scattered over a range 10000. so the z values should at least show some variation.

changing the near/farplane didn't lead to other results.

edit: the projected x, y values are correct
What did you try changing the near and far values to? The depth buffer is not linear; a lot of precision is used close to the camera and very little is used far away. For the most part you want to minimize the far-to-near ratio to most effectively use your depth buffer precision. 1000000:1 is VERY large. For a near value of 1 and a far value of 1000, there's about 99% of the depth precision in the nearest 9% of the view volume (something like that, I don't feel like going through the math). So if your points are scattered in a range of 10000 close the back of the view volume (say 800k - 810k) I would expect all returned depth values to be 0.9999999...

In any case, your OpenGL code would (still) be of help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!