Skip to content

concepts precision

Tomáš Malý edited this page Aug 6, 2020 · 5 revisions

Precision

Floating point type

See Floating Point Standard on Wikipedia.

Single precision has 7 decimal places of mantissa. The meshes VTS works with have triangles as small as few centimeters. But these triangles are as far as the Earth radius from the world origin.

Putting this into numbers, two vertices are separated by 0.01 metres. But their position is eg. 6378000 metres. Therefore their position differs at 9th decimal place. We are missing at least two decimal places of precision and therefore need to use double precision.

ModelView Matrix

Current (gaming) graphics cards do not support double precision, which means that we have to find some workarounds.

The simplest trick here is that we do not need the same amount of precision everywhere. When you are looking at a 2 story house from a distance of 100 kilometers, you probably wont even distinguish the two floors. When you look at the same house from distance of 10 meters, you will see even some flowers behind windows. The outcome is that we need full precision at the position of the camera only.

All VTS applications solve this by doing all necessary computations in double precision, and after the ModelView matrix is composed, it may be safely cast into single precision. Because MV matrix contains positions relative to the camera, the numbers are fairly small and no precision is lost.

This approach is leveraged in Camera Cmd Bufs, but it requires that we can directly set the MV matrix, thus using the Command Buffers.

Unity Transform

Sometimes using the Command Buffers is infeasible and actual game objects for the meshes are needed, eg. to cast shadows. This is where Camera Objects may be used.

All game objects instantiated by the camera have their transformation stored in single precision. Therefore these objects must already be positioned in a local space close to the camera, otherwise some precision issues will appear. This can be easily done with Map Make Local script.

Unfortunately this will limit the playable area only to some surrounding area. To utilize the full potential of the VTS planetary scale data, you may use Shifting Origin.

Also note that to use physics engine (eg. for collisions) same limitations apply and the Map Make Local must be used too.