OpenGL double precision

Started by frootqloop, May 12, 2020, 17:59:49

Previous topic - Next topic

frootqloop

I am making a libgdx model solar system game and the scale of it is such that I need to have double precision coordinates and OpenGl compatibility with it so that large position value objects don't skip when their positions are cast to floats to be rendered.

LibGdx uses LWJGL for its desktop graphics. I'm not worried about other platforms if they don't work but if there is a solution for all libgdx platforms that would be great.

I know there is an arb extention for 64bit vertexes but I do not know how to apply it. I'm thinking I need to open the source for LWJGL, apply the extension and recompile into jar. From here, I would need to compile libgdx from source with this jar instead of what its currently using. This is only a guess. I would appreciate any help!

Thank you

KaiHH

You don't need double-precision on the graphics card. The way to handle this is to compute camera/view-relative object positions in double-precision and upload those view-relative positions in single-precision to the GPU.
So, if you need a single global origin (i.e. in the middle of the galaxy) and have all other positions (i.e. positions on Earth) relative to that origin then use double-precision on the CPU to compute view-relative positions. This way your camera transformation is not a gigantic translation of the world from origin to the position you are currently at, but will actually only have a rotational component, because you already pre-transformed the translations on the CPU as view-relative positions when rendering the models.

frootqloop

Wow - succinct and to the point. Yes, I was thinking about this wrong. Needless to say, your solution and example was perfect and now my program is rock steady looking. And I don't have to do a bunch of extra stuff to get it working. THANK YOU