Scenes with large and small elements

Started by
4 comments, last by george7378 9 years, 5 months ago

Hi!

At the moment I'm working on a simple simulation of an Earth-orbiting spacecraft. This involves centring the camera on my spacecraft which is orbiting a few hundred kilometres above Earth and simultaneously rendering the planet itself out to a distance of around 12000km. Of course, it's unfeasible to render such a scene using metres as my base unit, as I have to specify the spacecraft's position in hundreds of thousands of metres relative to the centre of Earth, and using such massive numbers to position objects in Direct3D seems to cause problems.

So, my question is: how would you approach the problem of rendering small scenes embedded in much larger ones? Should I render the Earth first followed by the spacecraft using different units each time? If you know of any useful articles or tutorials, that would be great :)

Thanks!

Advertisement

Simply change the scale of the objects. If you move the planet 10,000 times closer, just render it with a 10,000 times smaller radius. As long as it's rendered in the same direction, you won't notice.

Alternatively, you can render all large objects with one scale, clear the depth buffer, then render smaller, nearer objects at a different scale.


Of course, it's unfeasible to render such a scene using metres as my base unit, as I have to specify the spacecraft's position in hundreds of thousands of metres relative to the centre of Earth, and using such massive numbers to position objects in Direct3D seems to cause problems.

Hundreds of thousands of meters doesn't sound like a whole lot, not if you are using 32-bit floats. If you were simulating the entire galaxy, I could see this being an issue, but you are only simulating Earth out to LEO.

Edit: Then again, now that I think about it you would only have accuracy to like 1/10th of a meter far away from the origin. If the origin is centered around the spacecraft then maybe it wouldn't be an issue. You don't need better than 1/10th of a meter accuracy for something >100,000 km away.

Also, it doesn't really matter if you are using meters, kilometers or millimeters as your base unit. This has no effect on the precision of the calculation when you are working with floating point numbers, as you are only changing the exponent.

typically, when a scene is bigger than a float can hold accurately, objects are defined in "world coordinates" which are then converted to camera-relative floating point coordinates for drawing. objects which are still too big/far to fit in a float get scaled down in both range and size until they fit in a float. drawing would probably be done in two passes, first a pass to draw all objects too big/far to fit in a float, then a pass to draw all closer objects. near and far planes can be reset as you go, to keep zbuffer resolution high.

this recent thread touches on these issues:

http://www.gamedev.net/topic/661933-max-size-for-level-using-floats/

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

probably not much help but pretty cool all the same:

http://www.andrewtop.com/Projects/Linfinity

also might be worth looking at the answer to this q:

http://stackoverflow.com/questions/1930421/seamless-transitions-of-scale-over-large-distances-3d-rendering

Ok, thanks for all the replies! I have solved it for the time being by calculating the actual positions using metres, and when I render I put the camera at (0, 0, 0) and render everything relative to that. For the Earth I'm using a sphere of radius 1 which I render 6378100 times closer than the actual calculated distance. Disabling the z-buffer for the planet rendering makes sure it's in the background.

This topic is closed to new replies.

Advertisement