Jump to content
  • Advertisement
Sign in to follow this  
Crestfall

OpenGL OpenGL precision for large coordinates

This topic is 3684 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

I'm writing an OpenGL application that requires double precision coordinates. While the pipeline offers appropriate methods (Vertex3d etc.), it seems like the double I'm giving as argument is being cast to a float anyway by OpenGL (or anything with lower precision). I'm not really understanding why the pipeline accepts doubles when it's limited at float-precision (to make the GPU do the cast ?). Now as for the solution I could come up with 2 different ones, an easy and hard solution. Note that my problem isn't the range of the coordinates that are being seen through the viewport, but the coordinates of the position of the camera and objects are getting so high that they lose too much precision when being cast to a float (any values above 2,000,000 at least). The easy solution would be to simply leave my camera at or near the origin (not adjusting the projection matrix as I am now), and computationally translating all coordinates of everything that needs to be rendered to the camera position. This would bring the coordinates close to (0,0) and solve the loss of precision floating points are suffering at high values. The downside of this solution is that on every iteration every coordinate needs to be computationally translated (and cast to a float), as the camera is constantly moving. A second solution would be to only chose a new axis once the camera gets too far from the origin, then calculate new coordinates for everything, store them seperately in the memory, and use these new coordinates to draw objects, until the camera exceeds the point where floating point doesn't deliver sufficient precision, then recalculate coordinates again. Obviously this would increase performance compared to the first solution, but it might not be worth the trouble. Any ideas, comments, or experiences about dealing with this kind of issue in OpenGL ?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Crestfall
I'm writing an OpenGL application that requires double precision coordinates. While the pipeline offers appropriate methods (Vertex3d etc.), it seems like the double I'm giving as argument is being cast to a float anyway by OpenGL (or anything with lower precision). I'm not really understanding why the pipeline accepts doubles when it's limited at float-precision (to make the GPU do the cast ?


Wishful thinking for 64-bit GPUs?

Share this post


Link to post
Share on other sites
Quote:
Original post by jsderon
Chris Thorne has written a paper in regards to this issue.

The NASA World Wind folks have discussed this issue here and here.

X3D has this to say.

I've written about it at the Insight3D blog.

I hope this give you some ideas.


Thanks a bunch, I actually searched around quite a bit but couldn't find any easy solution. I figured I was just doing something wrong, apparently it's more of a real problem to think about than I thought it was.

What I'd still like to know if there's any difference between using Vertex3d and using Vertex3f with the same arguments but explicitly casted to a float. If not, what's the point of having a Vertex3d ...

Share this post


Link to post
Share on other sites
I am featuring infinite terrain in my current engine.
Basically all objects what 2 sets of coordiantes

1. 3x float for its relative position within the chunk it belongs to
2. 2x int that identifies sectors

this system allows for terrains of the size
+- 8.796.093.022.208,0

which corresponds to
+- 219.902.325.555,19998 kilometers
with the precision known from ego shooters

Share this post


Link to post
Share on other sites
Quote:
Original post by Crestfall

Thanks a bunch, I actually searched around quite a bit but couldn't find any easy solution. I figured I was just doing something wrong, apparently it's more of a real problem to think about than I thought it was.

What I'd still like to know if there's any difference between using Vertex3d and using Vertex3f with the same arguments but explicitly casted to a float. If not, what's the point of having a Vertex3d ...


glVertex3d will cast the values to floats. I imagine this was done for the convenience of the user whose data might be in doubles. Likewise, the other varieties of that command for integers and shorts will cast values to floats.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!