Game Development Community

3D Parallax Starfield

by Charlie Sibbach · in Torque Game Engine · 12/29/2008 (10:11 pm) · 11 replies

I'm using the FXStarfieldReplicator resource to create the starfield in my space game. I only need it so that you can have some reference point as to how fast you are going. The problem is that I have a large play area and a long render distance (even though you can turn that down for the starfield without messing with everything else), and Torque crashes if you move too fast. What this means for me is that I can turn down the speeds and sizes of everything (scale down by 10), but it still feels like you are moving through molasses because the stars move by so slowly. The answer is to increase the density of the starfield, but I'm already generating 20000+ stars and it feels sparse.

So, I'm wondering if anybody has any good ideas about how to create some effect of rushing stars without creating 100megs worth of star billboards? Some kind of parallax starfield effect, but in 3D.

#1
12/30/2008 (8:02 am)
Game Maker has a series of tutorials on its site, one of which does such a good job explaining parallax and how to code it that I licensed Game Maker (only $20) as my token of thanks.
#2
12/30/2008 (10:09 am)
You could use a skybox for the background stars and then modify FXStarfieldReplicator to only create stars near the player.
#3
12/30/2008 (10:26 am)
Dan, I am using a skybox (skysphere, actually) for the background stars- problem is that they don't move, so it doesn't provide the visual cue that I need. I can't really modify fxStarfieldReplicator to do that, either, since the player is OK to move throughout this large play volume. fxStarfieldReplicator actually creates a few thousand single-poly billboards, so they are there in the scene and stationary, and need to be everywhere for the effect to work at all.

One idea that occurs to me is that I could move the position of the starfield replicator as the player moves, in the opposite direction, so that the stars appear to be moving faster than the player is actually going. The problem is that the stars would have to be even more vast than the entire play area, so if the stars move at a 2-to-1 ratio, I'd need a moving starfield three times as large as the play area to avoid any nasty jumps (where the player outruns the starfield and it adjusts forward to rescroll). Also, I'm not sure if I can even move the starfield in that kind of way; it generates the stars once on mission download; I'm not sure if the render positions of the stars are set absolutely at that point in time or if they remain relative to the position of the center of the starfield.

I guess some experiments are in order.

Another idea I had would be to put a big billboard underneath the player (it's an overhead view game) that has some kind of animated texture, such that I could create a rapidly moving parallax starfield. Seems like I'd really need shaders to pull that off correctly, though, and as of right now those are beyond my ken and TGE (I put the modernization kit in, and then took it out again after it DESTROYED my frame rate, so no shaders for me)
#4
01/03/2009 (6:01 am)
Well question, unless a player is logistically moving light years in this particular map... the starts arent going to move realistically.. so setting stars throughout the map even when moving though a interstellar map.. unless you have it completely setup with a entire starchart mapping system and such. The player isnt going to notice a non 3d starfield as long as your skyglobe/box is done properly. The problem comes when you add in things like nebuleas, which also really is done in shows like startrek and most scifi done really out of proportion.. since most nebuleas and astrononical bodies are in the light minutes and years range of width.. having a moving starfield i see where it would be awesome.. and it give the player a sense of motion, but its totally unrealistic, if you most hang a cloud layer of star. Or if your a programmer, and your want to create a warp effect, for fast movement.. (alot of 3d games have it) you can create a gui layer with that effect. But at standard (impulse/sublight speeds) the stars arnt going to be moving very fast..
#5
01/03/2009 (7:28 am)
Not to nit-pick along with Edward, but in order to see actual star movement, you will indeed be moving at near-light speeds, which will also create a doppler effect within the light spectrum that will bend the colors of the stars. And not to mention the compression of matter along the axis of travel as you approach light speed ;p

Check out how Homeworld did it. Space was basically a quite believeable skybox. All movement sensations are handled with local objects such as asteroids, planets, and other ships and the game captures the feeling of space quite nicely.

And don't get me started with sound (or lack there of) in space, hehe.

I wish I could help with the starfield issue regardless. I'll dig around a bit and see if I come up with anything.
#6
01/03/2009 (8:24 am)
Earth And Beyond had something like what I think you want when your ship was moving around.
There seemed to be these little particles that were only there to give you a since of motion.
The effect was much greater when traveling at "warp" or whatever it was in that game.
Here is a video of the effect (it was the only readily available source I could find)
About half way thru it shows the effect.


As far as being able to reproduce this, a particle effect centered on the camera and altered based on what your ship is doing could achieve this I think.
#7
01/04/2009 (5:22 pm)
Thanks Bill Vee! I didn't really see it in the video, the idea of a moving particle emitter might work.

And to Edward and Brian, I totally agree that the starts wouldn't move if this was a realistic setting. Unfortunately, I can't use that excuse, because it's basically an overhead view 2.5D space shooter (with velocity limits, no less!), and it gets real troublesome real quick when you don't have a visual reference as to your velocity, which a skysphere just doesn't provide. The local objects work OK for the visual cue in third person, but in top-down you just don't see enough stuff on the screen for this to be effective. It really comes down to this- the current starfield is pretty much perfect at doing what it's there to do, but if I slow the ships down to avoid Torque's speed bug I'm in trouble.

On a side note, I haven't played with moving the Starfield replicator around, because I realized a major bug with that idea- multiplayer. I can't move the starfield for both players without doing some major surgery to the system so that I can send different representations of the same object to different clients. This is kind of tough to do; I tried it with guiRadarCtrl and gave up.
#8
01/06/2009 (9:58 am)
Well, it doesn't seem to me to be a great solution to have static stars that actually exist in the level whose purpose is solely to act as a speedometer. If that's all they do, then it makes much more sense to make client-side objects that the server doesn't need to know about. You might want to have a look at the client-side TSStatic resource for some direction there.
Being client-side gives you a few things - less network traffic, less objects for the server to worry about needessly, and clients can configure the effect to their taste or requirements (if they want, they can have less or more stars to make the game run better, provide a better effect, or satisfy their nit-picklyness).
#9
01/06/2009 (10:51 am)
Thats what we had suggested, perhaps a gui layer that reacts to the motion of the player or actions of the scripts. there is a movable gui layer .. scrolling star field i think. but i think thats very 2d, and you need a 3d solution. I agre with daniel that what ever solution it is, that it is a client based on. unless every single star is a actually object thats reachable in real time (ie a really big map). If thats the case then this issue is mute as at that scale it would probably look about right..
#10
01/17/2009 (5:25 pm)
I'm working on a particle-based system that should do the trick. I'm going to place a particle emitter ahead of the ship's velocity (since you can be turned in a direction very different from that), that will extend/scale based on the magnitude of the velocity. This particle emitter will be tuned to emit invisible particles at first, with high drag, so that they will become white/"dust" as they pass over the ship. Obviously, I can do a much higher density of these particles than I can do static stars. As far as network stuff goes, I will put the emitter not in the general packUpdate function, but instead in the writePacketData function, so it only shows up for the client that's controlling, and not everybody in a network game, so it won't look strange.

I'll see how this goes, and post the code if it works.
#11
01/17/2009 (5:33 pm)
that will be cool so see, can't wait to see some screenies.