Game Development Community

How can I create a parallax starfield in Torque3D?

by RealDecoy Inc · in Torque 3D Professional · 02/21/2010 (3:47 pm) · 22 replies

Hey, having a bit of a wierd problem, didn't expect this to be as difficult as it turned out to be (And I'm sure I'm just missing something)

I just finished porting my code so far into 1.1 Beta.

What I'm doing is building a top down space game (basically functions on a 2d plane but with 3d graphics).

I want a parallax starfield in the background.

I decided first that using a groundplane, texturing it with an alpha transparent png with stars on it, then layering several groundplanes deep would work perfectly... Works fine, except I can't seem to find how to adjust the depth of a ground plane (they all render in the exact same spot, but the alpha transparency on the png works great, just not that useful without depth lol)

Anyway, so next I tried piece of geometry. Which works great, can stack depth and get the exact effect I want, except, it's not infinite. And there are certain situations I would want basically infinite travel in all directions (which a groundplane gives me).

Next I thought perhaps I could do it with particles, just have it fill the screen with some stars, at random positions, and move them relative to camera movement or something. Just couldn't get my head around how to do that with the particle engine.

Lastly I thought, perhaps I could render a flat texture straight to the camera (like a GUI object) but set it's Z depth to be always behind all rendered geometry, then I could have a few layers, and just scroll the texture on it relative to camera movement to create the effect...

Couldn't figure that one out either...

In addition to wanting this to exist in all missions being played, I also want the effect to render behind the "main menu" but I'm not quite sure how to do that either...

Anyway, if anyone can point me at a resource or tutorial that pre-exists, or give me some pointers or tips on how I could go about achieving what I am trying to do, I would really appreciate it.

This is meant to be a very simple casual style game, and we were hoping to do it without any real engine modification (entirely in torquescript) then we will be expanding a more robust release if this one is successful, and carry our torquescript code over, and then allow for some engine modification for the more advanced project.

But that said, if we need to modify the engine to achieve what we are trying to do, that's not a big problem. We are just trying to keep the complexity to an absolute minimum.

Thanks!
Page«First 1 2 Next»
#21
03/14/2010 (1:18 am)
Why not just a couple TSStatics layers over each other at different depths, each of which are a single quad with the same material. Material supports scrolling style texture animations.
#22
03/14/2010 (7:56 am)
Hi James, mainly because I didn't see a way to control the animations to be relative to camera movement. I don't just want a static starfield scrolling parallax in one direction at a constant speed. I want a starfield which scrolls parallax in proportion to the movement of the player (and therefore the camera) creating the illusion of a true 3d starfield.

The Shader approach looks to offer that perfectly (and is almost working. Needs some minor tweaks to get the effect just right, but overall the concept is EXACTLY what I needed lol)

Thanks!
Page«First 1 2 Next»