6
\$\begingroup\$

In Kerbal Space Program, a space exploration game made with Unity, Floating origin technique is used to overcome the floating point precision issues. While in map view, the world (a scaled space with miniature celestial bodies) is recentered around the camera every frame so glitches don't occur when viewing unsafely distant planets. But when such planets are observed from an 'unsafe distance' (more than 10 000 units in scaled space), they're still rendered normally. Why don't floating point issues occur?

\$\endgroup\$
  • 4
    \$\begingroup\$ I think pictures would help explain the question, I also have a problem that this question assumes a lot of things.. \$\endgroup\$ – concept3d Nov 8 '15 at 16:25
  • \$\begingroup\$ 10km is only a "large" number if the units being used are meters or smaller. The celestial map could be rendered in a scale of km, 100m, 10m, etc. \$\endgroup\$ – Sean Middleditch Nov 8 '15 at 17:15
  • \$\begingroup\$ @SeanMiddleditch The 'map scale' is 1:6000 (1 unit represents 6000 m). By '10km in scaled space' I meant 10 000 units in the map subscene, which is enough to cause precision issues. \$\endgroup\$ – Maks Maisak Nov 8 '15 at 18:07
  • 2
    \$\begingroup\$ I don't understand your question. In Kerbal Space Program, the floating origin trick is used precisely to assure that visible bodies are within what you call the safe distance - in a way that only bodies that ceased to be visible are left in the so called unsafe distance. \$\endgroup\$ – MAnd Nov 9 '15 at 3:07
  • 1
    \$\begingroup\$ They're rendered nicely because the shader finally transforms the point in clip space, whose range extends from (-1, -1) to (1, 1). The local space vertex is first transformed into world space, then viewport space and finally screen space (or clip space). And plus the max value of a float (in C# at least) is 3.402823e38 which is quite a lot. \$\endgroup\$ – EvilTak Nov 9 '15 at 13:09
2
\$\begingroup\$

I'm fairly sure floating point rounding errors don't mean that an object will be absolutely rendered incorrectly when far away.

It just means that the probability of the sun being exactly where it is supposed to be is smaller the farther away from the origin it is.

However, you might not be able to notice if the sun is at the wrong place with an error of 10 km for instance. Since the sun jumping between 10 km is hardly noticeable from earth. It wouldn't even move a single pixel.

You also have to take into account that Kerbal uses many cameras to render a single scene. Three, if I remember correctly. One for the cockpit or ship, one for the landscape, and one for celestial objects. These cameras have individual near/far rendering planes.

I hope this answers your question.

This video goes into greater detail: https://youtu.be/mXTxQko-JH0?t=399

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.