Precision issues with M(ogre)

mzanin

17-11-2009 09:40:28

I've just started playing around with Mogre in the hopes that we could use it as a replacement for our existing in-house graphics engine.

One of the main requirements that Mogre has to meet for us to make use of it is that it needs to be able to cope with our large ECEF coordinates. I wrote a simple test application rendering a set of spheres at meter resolution at an arbitrary ECEF Cartesian location and (as expected) saw significant rounding errors; seen by the jittering of objects while the camera was moving around the scene close by.

Our existing graphics system works purely in doubles and only when the transforms have to be passed to DirectX will the system convert the Matrices to floating point values.
At that stage the values are small enough to not cause any significant rounding issues...

Now as I'm unfamiliar with Ogre/Mogre I'm not sure the best way to tackle this problem. I read that it is possible to build Ogre in double precision mode, will this work with Mogre also?

Anyway I'm interested to hear your suggestions.

smiley80

17-11-2009 09:48:33

In your config change 'Floating-point mode=Fastest' to 'Floating-point mode=Consistent'.

mzanin

17-11-2009 09:54:44

Thanks for the suggestion. I just tried setting it to Consistent but didn't seem to improve the jitter at all. What does this setting do?

smiley80

17-11-2009 09:59:28

By default, DirectX sets the FPU to single precision for performance reasons.'Floating-point mode=Consistent' only changes precision for DirectX calls.

mzanin

17-11-2009 10:28:03

Ah that wouldn't work for me then. I'm explicitly casting to float (from double) when I make the call to .Translate(...) on the SceneNodes.
It would be nice if I could pass it the world matrix transform, that would probably fix the jitter I think.

GantZ

17-11-2009 11:57:53

you will need to recompile Mogre using OGRE_DOUBLE_PRECISION set to 1 (in OgreConfig.h). all the internal function and custom class (like vector3) of Mogre use Mogre::Real which directly relate to Ogre:Real which is set to float or double given the value of OGRE_DOUBLE_PRECISION. if you are not familiar with the process, see : http://www.ogre3d.org/wiki/index.php/Bu ... rom_source, the batch build part, or you can use the manual way here : viewtopic.php?f=8&t=10937#p63491

mzanin

24-11-2009 08:08:59

Thanks for the help. I finally managed to build Mogre with OGRE_DOUBLE_PRECISION set to 1 (definitely not a trivial task)...

Now, after re-running the sample application the entities are no longer jittering relative to each other but it seems that the camera translation is still subjected to rounding errors.
I think that because every object in the scene is shifted slightly by the same amount every time the camera updates.

Does anyone have any idea why that could be happening?

mzanin

24-11-2009 08:37:21

After setting CameraRelativeRendering = true the jitter has disappeared... Now I'm happy :-)