1
\$\begingroup\$

I'm trying to generate a real-sized planet with WebGL. After researching, I came to the conclusion that the best way to get around 32-bit float precision issues (since GPUs don't support double precision) is to use 64-bit integer coordinates. I would generate these coordinates on the CPU, then send them as integers to the GPU. After that, I would get the position of the vertices relative to the camera by doing:

vertexPosition-cameraPosition

Since the result is small, I can now safely convert to 32-bit floating point and render it. All was good until I realised that since the coordinates are large integers, I can't multiply them by a model matrix if I want to rotate the planet around it's center since the floating point coordinates are no longer relative to the planet's center.

Is it possible to scale the model matrix by a large value, then convert it to integer, multiply by the position, and then divise by that same large value? I know there is a solution but I can't find it.

Thanks

\$\endgroup\$
4
  • \$\begingroup\$ I believe Tom Forsyth (ex-game dev, ex-Larrabee engineer, etc) wrote a blog on using 64-bit ints for geometry, but my searching has failed me. You may have better luck. \$\endgroup\$ Commented Apr 12, 2018 at 15:33
  • 1
    \$\begingroup\$ Thanks! I found his blog: tomforsyth1000.github.io/blog.wiki.html. It may be the article titled "A matter of precision" but I don't see anything about geometry. \$\endgroup\$ Commented Apr 12, 2018 at 15:56
  • \$\begingroup\$ First of all, GPUs do have double precision, WebGL just can't use that yet (OpenGL 4.0 can). Secondly, may I ask you why you think precision is an issue? Earth for instance is just 10,000 kms wide in every direction and Jupiter is just 140,000, that shouldn't be enough to cause precision issues in my opinion and even if it would, you already have to cut it into pieces, because you won't be able to fit that much data into a single VRAM and then you might as well just position the chunks around the origin. \$\endgroup\$ Commented Apr 12, 2018 at 16:50
  • \$\begingroup\$ I actually want detail when really close to the ground, so I need centimeter precision. The earth radius is around 10000*100000 cm wide so 32-bit float isn't precise enough. And isn't double precision slow on the GPU (relative to single precision)? \$\endgroup\$ Commented Apr 12, 2018 at 16:58

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.