I hope it is OK for me to put my notes here. If not please let me know mods.
So it appears there is no one stop tutorial for solving the “Continuous World Problem” so I am going to put my findings here in case others may benefit. My goal is get something working and put the scripts here for the Unity community (if time and my skills permits). My particular interest is in using GIS/DEM data to sim real world terrains.
We start with this talk from Unite 2013 where Robert Oates talks about GIS Terrain & Unity
My takeaways from this talk:
Solving the Continuous World Problem is not easy (who knew?) and the solution is a work in progress.
Problem: Memory Limits
Finite memory, lots of content
Height maps
Render meshes for terrain and other objects
Collision structures
Terrain textures
GameObjects - agents, props
Scripts on GameObjects
Problem: CPU/GPU Limits
Finite CPU, lots of systems
AI/ Behaviour - increases complexity by #objects^2
Terrain object collision every frame
Object object collision every frame
Animation
Scripts
Culling and Rendering
Problem: Numerical precision limits
Transforms use IEEE 754 float
Have gaps between the 2^32 values on a 2^129 domain
Least error near 0
Most error near +/- float.MaxValue
Numerical instability far from origin
Visible symptoms at 60 fps
@ 100,000m float errors are 0.0078m componded up the transform stack at 60 fps
at 20-40,000 it will look really bad
Solution: Streaming terrain in any direction
fundamental ideas - Stream terrain around frustum
moving tiles
terrain built at runtime not serialised in scene, dynamically constructed
database used to persist tiles and objects and stuff
queried at runtime
recycle terrain objects
keep frustum in centre/ keep tiles near origin
persist/retrieve objects
stream imagery and heightmaps
numerically stable
constant CPU/memory load
Method:
generate a n^2 terrain mosiac
store for later use
center on origin
each tile has lat/lon independent of world space
SW corner is origin with lat/lon
each tile gets imagery splat texture from disk, cache, remote server
each tile gets heightmap data
if tile moves clear imagery
Database Persistance
lat/lon coordinate
orientation?
query database by lat/lon bounds
Implementation (2013)
“good computer” 17 X 17 terrain tiles
10km X 10 km loaded at once
Optimisation techniques (2013)
reduce number of tiles loaded in memory at once
distribute tile loading across multiple frames using coroutines
recuse size of tiles
reduce fidelity of heightmaps or elevation data