Space Sim Backgrounds

Started by
7 comments, last by Antrim 18 years, 5 months ago
Does anyone have any insight into how backgrounds in space flight sims are produced? It seems that a textured sphere would suffice, but it doesn't seem likely that you would want a far clipping plane all the way to the sphere. So does anyone have any info as to what methods can be used to show the background while maintaining a reasonable clipping distance? TIA
Advertisement
What does the background have anything to do with clipping ? You can disable the Z-Buffer reading or writing at any time you want. Just draw your background first.

Y.
man...when you said it like that it seems...so...simple :P

Yeah, I completly forgot about being able to turn off the buffer. Been stuck in the mindset of drawing the scene as a whole and overlooked that possibility. Thanks for the input.
I'm in the middle (or near the start!) of writing my spacesim game, and I found out, fairly painfully that if you want to have really large environments (like a galaxy for instance) you need to draw different elements with at scales. For my background I am considering just drawing the galaxy in the galactic coordinate system (1 unit = 1 ly maybe?), then clearing the depth buffer, moving to the solar system coordinate system (1 unit = 1 Earth radius) and drawing local planets, clearing depth buffer, moving to LOD space (1 unit = 1000m) and drawing the LOD meshes. Maybe I will add object space where 1 unit = 1 m, for ships etc.
But if your game is going to be all based in a contained area, in space with no planet surface, then you can probably get away with one coordinate space.
If you want a textured skybox style, then you should use a cubemap, which gets around the problem of texture pinching at the poles (which you get with a sphere).
While it seemed like a good simple idea, now that I try it...I'm not sure what I need to do for it to work.

So I have my environment set up as a 2048 unit cube that has a space texture applied to it. I want to always see it (of course), but I don't want to have my clip set to 2100.

Anyway, the different methods I could find of disabling the depth buffer didn't help this situation at all. It seems like there should be a way to draw the surface with the background first, then change back to my regular mode to draw the actual scene objects, but I just can't seem to find what it is...or maybe there's simply a better way to accomplish the same thing I'm trying.

Any input is appreciated.
glDisable(GL_DEPTH_TEST); // turn off depth testing
glDepthMask(GL_FALSE); // turn off writing to depth buffer
// render background
glDepthMask(GL_TRUE); // turn back on writing to depth buffer
glEnable(GL_DEPTH_TEST); // turn back on depth test
// render everything else

That should work fire. To stop near and far clipping just scale your bg cube so it fits in. Really your cube should be one or two units in size, not 2048. The coordinates do not affect the texturing, the cube will appear exactly the same.
I know that I could have a smaller cube, and just make sure that it stays centered around the camera position. But doing that causes it to look like you aren't moving towards anything when you are simply flying straight with only your ship on the screen since the stars are at a static loc if you don't rotate.

Maybe there is another quick fix for this. I know some sims generate various particle objects to pass you by, but I'm not sure of what other method there is available until I can implement something like that. It seems like I still need to move towards whatever part of the cube I'm pointing at.

I suppose, though, that I could do a scale inside the background drawing part so that it could be kept much smaller and still seem to move.
If you move inside the starmap the illusion will be broken, as the star field will appear to distort, and a cube would be apparent. Also you couldn't always be moving towards the edge or you would have a finite space, which would only appear correct in an even smaller finite space. Even travelling at relativistic speeds, movement would not be noticeable in space unless you are passing close to an object (as in within an AU or so). Thats why people add the particles, otherwise you just seem stationary, which isn't very interesting. You could add a time speed setting, like in Elite, so that time can pass 10, 100, 1000, 10000, 1000000 times faster, which will get you places before you get bored. Or you could just scumb and add particles!
Well, I do intend to have a finite space....not a hard edge, mind you, but something along the lines of XvsTie or Freespace where you get a warning when you are close to the edge of the area, and then are destroyed/redirected/something if you go beyond the set size.

It does seem, though, that the distortion, while possibly slight, is unavoidable. I may just have to get some simple debris particles generating for now and make them look a little nicer when I get time.

Just for a performance perspective, I notice a massive difference in fps if I am using a cube as big as a small level (say 2048 units). That might have something to do with other settings I have, but more than likely, no matter the method of implementation, using a small 1 or 2 unit cube for the background is probably the best choice.

Thanks for the input

This topic is closed to new replies.

Advertisement