Big terrains and float accuracy

jpk

25-01-2006 22:09:13

I just had a look at the paging landscape scene manager and I was quite impressed with the grand canyon example... (It might be fun to do something with a _really big_ game area.)

However, I think there is an obvious problem with landscapes that large. The single precision float number accuracy really can't handle that big values.

The accuracy should be ok at the middle of the map, but what happens when you move to the near-edge of a large map - the position values grow over 100k magnitude. Given a 100k float value, you pretty much lose the ability to handle any value in accuracy smaller than 1.

So if we were using metric values, this would mean that a 100km map cannot be used in a game where positions need to be more accurate than 1m - or similarly, if it was a 10km map, values smaller than 1cm would be inaccurate. In case of a first/third person game, this might not be acceptable... (of course, someone might ask what is the point in making a first person game with a 10x10 km map, but lets not get into that now.) ;)

Now, obviosly there is a "simple" fix for this problem.. just use double precision floating points instead (or proper 32bit fixed point numbers). However, the PLSM demo app does not seem to be doing so.(?) I don't know if this is due to Ogre3d or just the demo app.

I'm sure at least some of you guys have already though about this and this may be trivial to you, but I'm still pondering about this issue. After all, it will be a problem if I should try to create a huge walkable map like that.

Just wanted to share my thoughts and maybe get some insights into this.

tuan kuranes

26-01-2006 07:57:29

If you use huge maps, you have to use double.
However, the PLSM demo app does not seem to be doing so
Well, problem is that double could slow the demo, thus making it a less impressive "showcase" ;)

Drinker Soul

07-02-2006 14:42:40

Can Antoher solution be to plit coord in pages, using float??
I mean:

My terrain

1 2
3 4

up-left corner of 1 is 0,0 , down- left 0,256 (it's just an example), and so on..

so now if i'm in page 3 my coord is coord3.x and coord3.y+256.
so for big maps we lose precision.
if we split coord to be represented by 2 int and a vector? so each pages has it's own 0-256 coord and to refer to a world coord U can use <page X,page Y> <pos x, pos y, pos z>
Sorry for my poor
english i hope i explained my ideas..

OvermindDL1

08-02-2006 04:34:34

I think a scenemanager that had sections, each with their own local space for full accuracy, and each local space existed within a larger space, with its own accuracy, mabye even higher to an arbitrary depth. Such a scenemanager would allow for arbitrary size worlds/universes with full accuracy.

tuan kuranes

09-02-2006 10:20:54

"Game programming gems 4" Book has a whole chapter on that.
it's a lot of work, I'll accept patch for that, but won't do it.
(double performance loss isn't that big.)