Double precision support in UE4

Does UE4 support double precision calculations? I’m currently evaluating potential graphics engines to use in a fully realistic solar system and space flight visualization/simulation program, and one of the necessary features for our project is full double precision support so that we can keep our calculations precise even at very large distances. Is this something that UE4 supports or that could be implemented without too much difficulty? Also, I’ve read about world size limits in UE3. Are there still limits on world size in UE4? Thanks!

Hi trevorr,

Currently there is an issue with some of the variables in UE4 not being set to an exact number. For instance, certain values you may enter, lets say 50, may actually be set to something like 49.9998. This isn’t happening in the background though, it will change the 50 you entered to 49.9998. Our developers are looking into this and we hope to have a solution soon.

As for the UE3 world size limitations, this isn’t an issue with UE4. The world size is only limited to what your hardware can handle.

Below is a link to a forum post that may help with your double precision question. I’m not to familiar with subject, so if I am misunderstand exactly what you are asking about please let me know and I’ll rope someone else in who may know more.

I hope it helps.

Thanks, TJ

To be more specific, are things like object coordinates in UE4 stored as single-precision floats or doubles? And do the underlying math libraries maintain double precision or are calculations reduced to single-precision floats to increase speed?

Any more specific details on this?

I’m not from the staff, but as far as I can know (correct me if i’m wrong), object coordinate are stored in a FVector, which encode coordinates in float.

Maybe there is a way to pass to double precision, like with Ogre, but if it exist, I don’t know where.

Now with your game, why doesn’t you use a relative coordinate system ? You don’t really need precise PhysX interaction for object that will only take on pixel on the screen (far away stars). Then you could just simulate the physics of far away objects with a simplified math, that could be a little more inaccurate.

And only do accurate computation for near object (thus with single precision).

Enabling double’s everywhere would be an extremely difficult task. Additionally GPUs don’t have universal support for them, so even if all your CPU work was in doubles, at some point everything would need to return to floats to head to the GPU.

Your best bet is to do the high precision simulation in your own code in doubles (or larger) representations. Then treat each loaded region of space as a zone where the float is still a passable representation of distance. In those regions you’d divide out the cell coordinate from the high precision double calculations to transform it into the space of some particular region. It’s essentially the same concept as a spatial hash.

So if my zones are lets say 100000 units across, and the actual user location is 362000.4323452343 (along one axis), I would % modulo by the cell size and be left with 62000.4323452343, and you’d do that for each axis for a players position to arrive at their local space location.

Streamable levels would most likely correspond to your zone size.

Well, that’s what I mean, but much more well explained ^^’.

Quote: “Currently there is an issue with some of the variables in UE4 not being set to an exact number. For instance, certain values you may enter, lets say 50, may actually be set to something like 49.9998. This isn’t happening in the background though, it will change the 50 you entered to 49.9998. Our developers are looking into this and we hope to have a solution soon.”

This is not resolved yet in 4.11 … Is this still being looked into ? It is really irritating to have round values messed up like that

what happens when you are halfway in one of two cells or even collisding at the border? it would make the programmer’s life miserable

I would translate your double precision vectors to place camera at 0,0,0 before casting to single precision for rendering. Anything close will have plenty of precision. Anything far away enough to loose precision (and large enough to see) will be too far away to notice the error. Anything far enough away to exceed FLOAT_MAX can be scaled in by a factor derived from it’s double precision position and clamped to a sphere of radius FLOAT_MAX.