Game Development Community

dev|Pro Game Development Curriculum

Star Rendering

by James Lupiani · 09/26/2002 (12:14 pm) · 31 comments

Download Code File

1. Abstract
2. Installation
3. The Star List
4. Known Issues
5. Change Log



== 1. Abstract ==

This patch will modify Torque's sky class to render a list of points on top
of the standard skybox, simulating stars. The stars are loaded from a
separate list on disk. You can specify the position, color, and intensity of
each star (via the alpha channel).

Included is a CVS patch file (star.patch), a sample star list (stars.dat),
and an awk script I use to format star catalog data into the needed form.

It's pretty simple, but I think it'll help shooters and flight sims alike.
Feel free to use it in any projects you want, just drop me an e-mail if you
make something great out of it. Oh, and don't hold me responsible if it
somehow becomes malevolent and destroys your stuff.



== 2. Installation ==

* Merge the changes between these files and your own. This can be done
manually or with a tool such as WinMerge (http://winmerge.sourceforge.net).
I annotated my changes Melv May-style by surrounding them with comments:
// JL: Stuff here
... new stuff ...
//

* Rebuild your game.

* Copy stars.dat to somewhere in your game's path. I put mine with the sky
textures and material lists.

* Open up your mission and go into the editor. Examine the Sky object. You
should notice two new fields: under media, "starList". This should be set
to point to the list you extracted in the previous step. The other, under
misc, is "renderStars". Toggle this on and click apply.

* If all goes well, you should see a bunch of little light points. If all
doesn't go well, see the Known Issues section.



== 3. The Star List ==

The star list is a simple text file containing all star information to be
drawn on the skybox. The first line indicates how many stars are being
defined. The remaining lines are tab-separated items of data. They are:
Position X, Y, Z, Color R, G, B, A. All data items are floating point.



== 4. Known Issues ==

* Unfortunately, it currently doesn't work in Direct3D mode. The wrapper
apparently doesn't support drawing points. This will have to be added
to the wrapper for this patch to work.



== 5. Change Log ==

29 Dec 2002:
* Cleaned up the code formatting, removing tabs for consistency.
* Fixed a bug where using a mission without any starList member in the
datablock would crash the game.
* Changed distribution format from a patch to .cc and .h files, as some
people were having problems with it. Code will have to be merged manually.
It's based on the current CVS HEAD tag.
Page «Previous 1 2
#1
09/27/2002 (2:55 pm)
Very cool, be nice to blend the horizon and the stars together, instead of the current sharp cut off.
#2
09/29/2002 (10:06 am)
this is very confuzing to me, (i tried to follow the directions) but when i get to this part:

Extract the patch file to your /engine/terrain directory and run
"patch star.patch".

I dont know what you meen by:
run
"patch star.patch".

Do i have to fire up cvs and run it there to change sky.cc and sky.h? (just want to be sure)
#3
09/29/2002 (10:48 am)
See step 1 of the installation. ;-)

Patch is a program you run from the command line. You give it the name of the patch file, and it goes through your source code and modifies it to match mine. It's essentially a computerized version of saying "Go to this line and change it to this." I chose to use this method because it's one GG endorses, and it's much faster than having people do it by hand. You shouldn't need CVS to do it, though it might come in handy later if GG updates sky.cc/h later on.
#4
09/29/2002 (4:15 pm)
The patch tool did not work for me, when run it just returns to a prompt waiting for more input. I even downloaded the GNU tools and tried those. I ended having to manually add the differences between the sky.cc and sky.h files.
#5
09/30/2002 (12:52 am)
One problem I've noticed is there's a program called patch in my Windows directory. It's part of a virus scanner I use periodically, so I had to get rid of it to use GNU patch.

When in doubt, specify the full path. (For example, "C:\gnu\patch.exe stars.patch")
#6
09/30/2002 (6:40 am)
Idont under stand the patch thing ,idont know what to specify in what, could sombody just post the updated sky.cc and sky.h files? it would be alot less confuzing
#7
10/05/2002 (8:59 pm)
@Ace - I suggest you carefully read the directions, and try again. All the steps are clearly specified.
#8
12/27/2002 (10:48 am)
I recently decided to take a look at this code to see how it would work with the Day/Night code. However, when I went to extract the patch it did not work. I downloaded a fresh copy of torque and filtered to only get changes up to the day that the patch was released so there would be no issues. I extracted the patch properly from the zip to engine/terrain then ran the patch.exe which I have used before, but the files did not extract. I redownloaded the zip and repeated the process to make sure that I did not get a corrupted zip but it still does not work. Would it be possible to simply get a copy of the zip files for sky.cc and sky.h?

I already have other changes in these files so I'll have to merge the changes anyway...

Thanks
#9
12/29/2002 (9:21 am)
David: I've updated the resource with bug and formatting fixes. Enjoy!
#10
12/28/2003 (9:22 pm)
Its been a year since the last post here but I must say after adding this and tweaking it with twinkles, and rendering it before the clouds this is a must have add-on for night missions/dayLightCycle.

*EDIT*
There is a problem with saving a mission that does not have a starList, it will completely whipe your mission clean and you will lose all missionData in the crash that follows. Make sure you have applied your star list prior to saving or bad things!
*END EDIT*

Thanks for the resource.
#11
03/10/2004 (2:58 pm)
Hi Sam..

Would you care to post your modifications to the star stuff?
Do you use it with fractal sky og with normal sky boxes?

kind regards
- Rasmus
#12
12/04/2004 (11:44 pm)
The header file needs a little bit of cleanup. WinMerge was unable to handle it properly because of tabs where spaces are used in HEAD etc...
Just cleaned up the formatting and all went well.

Except... when I open up the media tab in the sky object, Torque crashes...
#13
12/04/2004 (11:46 pm)
Wow, I hadn't realized this was still popular. I might make some updates to it to improve performance and add features.
#14
12/04/2004 (11:49 pm)
That'd be nice :)

I think I might actually use this if I get it to stop crashing etc.
I'll mail you and let you know if I use it. (I'll include name in credits etc)

It seems to want terrain. I don't know if this is because of this patch or not. But once I open it up the console.log fills up with terrain specific errors. (I have no terrain)
#15
12/13/2004 (4:10 pm)
Please do. This is a great resource ;)
#16
01/17/2005 (1:40 am)
I'm getting a crash on opening the Media tab as well, and I am seeing no terrain errors (have the terrain fully removed from the mission). I'm looking forward to getting a chance to play around with this once that crash is fixed, and twinkling stars? Oh, come on now... this is just getting TOO GOOD!
#17
02/03/2005 (5:44 pm)
Any chance you might make a vertex/primitive buffer version of this for TSE?
#18
02/05/2005 (11:03 pm)
It'll have to wait until I can save up for TSE, but sure.

Right now I'm running benchmarks to see if I can squeeze some more speed out of it.
#19
02/06/2005 (3:54 pm)
I already got the VBuffer version working... I'll clean it up and send it to you.
#20
06/22/2005 (4:12 pm)
Any chance you can post your changes here, Mike?
Page «Previous 1 2