Skip to content

concepts precision

Tomáš Malý edited this page Jul 9, 2018 · 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 the 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. This is where Camera Objects may be used.

Unfortunately the 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. But it will limit the playable area only to some surrounding area.

To utilize the full potential of the VTS planetary scale data, you should employ some mechanism of continuously realigning the map with the player's position. This is, however, left to the application and is not part of this plugin.

Finally, to use Collider Probes, one needs to actually use this second approach with map moved into local space.

Clone this wiki locally