• Advertisement
Sign in to follow this  

Frontier: First Encounter - How to do a similar graphic?

This topic is 4716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I wondered how to do the graphics for a game like FFE. For those who don't know that game, it's a space game with simulated star systems. You fly physically correct. The parameters: Objects can have sizes from 100 m (space ship), several thousand km diameter (Earth approx. 6400 km diameter) or like the sun, 1.392.000 km radius. For those from the US: 1000 m are 1 km. The distances are up to 50 or 100 AU. 1 AU is the distance from Earth to Sun (149.600.000 km (1 AU)). From all this, i conclude the granularity of the depth-buffer is not enough to render this. My main question is: how do I create a scene with for example 10 space ships, 2 space stations in our solar system. Any ideas? My first impulse is to draw the sun, then the planets and then the space ships/stations. But what about the Z-Buffer and his lack of precision?

Share this post


Link to post
Share on other sites
Advertisement
If the depth buffer is really the problem then I guess you could easily build up a list of each object, coupled with its depth. Before drawing anything, perform a simple transformation of the centre of the model then add the object to this list with a corresponding depth (use the calculated centre). Then sort the list by depth, read off each object and draw as usual.
However, I'm sure there's a more fundamental issue here... if the scale really is the issue, then scale everything down, and if it's a problem of relative scales, then you can always use tricks like halving the total size of the sun and drawing it half the distance away.

Share this post


Link to post
Share on other sites
Is it really that easy? If I halve the size of an object, I just draw it half the distance away?

Share this post


Link to post
Share on other sites
I think so, and a quick sketch on paper with similar triangles seems to work. Calculate a vector from the camera to the object, find a point half way along it and put the object there. It should work... But it does seem too easy. I hope I'm not missing anything here. [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by benryves
I think so, and a quick sketch on paper with similar triangles seems to work. Calculate a vector from the camera to the object, find a point half way along it and put the object there. It should work... But it does seem too easy. I hope I'm not missing anything here. [grin]

yes you are: youre messing with the very thing a z-buffer tries to ensure: correct ordering.

i believe the most commonly used method to solve this is by chopping up rendering in different passes, with different near/far planes.

Share this post


Link to post
Share on other sites
First of all, if you are going to work in real dimensions, you'll need to switch all your code to use doubles instead of floats (and even there you might suffer from internal precision issues at the edge of the solar system).

For the ZBuffer issue i would advise to implement frustum culling in a first step (you'll have to do it anyway for any less-than-basic engine). Then fixing the problem should be easy. Split your original frustum in 2 or 3 smaller frustums, by changing the near/far planes each time. You might have to overlap the near/far values in each frustum in order to get a good precision everywhere. Rendering is then just a matter of intersecting the scene with each frustum, and for each set of objects, set the frustum parameters and render the objects (Note: with that method you might render some objects multiple times, so you might have to use some stencil buffer tricks).

You can also do it the "smart" way, since space is mostly empty, by determining znear/zfar so that no object (like a planet) intersects two frustums at the same time.

For planets, as they are displayed as sphere, i found that disabling the ZBuffer reads/writes, enabling backface culling, sorting the planets and rendering them from back to front works well too.

Y.

Share this post


Link to post
Share on other sites
As there aren't many objects, a general sorting by distance shouldn't pose any problems.

What is the mentioned frustrum culling?

You mention using several frustrum with different near/far-planes. Doesn't this distord the rendered picture (since the picture is rendered with the screen being the near plane?)?

Share this post


Link to post
Share on other sites
Quote:
Original post by iso8859-1
What is the mentioned frustrum culling?


Picture a frustum, which is a rectangular based pyramid with the top pointy end cut off. This can be used to represent all the viewable space on your screen, bounded by the edges of the screen and the near/far clipping planes. Frustum culling throws away any objects that are outside this frustum.

Basically - set the far plane to be very far away, and the near plane to be also very far away, but still closer than the far one. Draw. Bring both in so that the far plane is just in front of where the near plane was. Draw again. Repeat a couple of times, so that you cover the entire range. (I think that's what Ysaneya was describing?)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement