Game Development Community

TGEDayNight Released!

by Prairie Games · in Technical Issues · 12/05/2002 (9:01 am) · 143 replies

Here is the Day and Night Cycle stuff as featured here.

*** Sorry, over the years we've lost this file. Please foward to Support@PrairieGames.com, thank you.
The source is available: HERE!

This is in GNU patch format... read the docs...

EDIT: I added the 2 TMU support for the interiors, get it from the link above :)

EDIT 2: Fixed a small problem with the horizon and made Sunrise/Sunset/Clouds much more dynamic/vibrant, highly recommended... the source is available from the link above or down below in the thread


Cheers,
-Joshua Ritter
Prairie Gamesm Inc.
#41
12/21/2002 (10:28 pm)
This is great.
Works fine on my geForce 2 MX400.
I have a couple of things that I would like to see improved however and was wondering if anyone is working on them, or if I should look into doing them myself (although im still pretty new to coding).

1) Linking the fxSunlight object to the time of day... atm, even if you manage to get the sun in sync with the time of day, when you restart the game it will all be messed up as the fx sunlight object starts at the start of its path, yet the time of day continues from where it was before (this shouldnt be too hard to fix)

2) I dont know if the lighting works on fxFoliageReplicator (I know the patch edits it in some way) but it doesn't on fxGrass. If it already works on fxFoliageReplicator this should be pretty easy to fix too

3) Occasionaly the top of the sky apears to mess up, as if the sides of the skybox are effected by the lighting and colouring but the top of the box isnt... has anyone else had this problem?

Sorry if I apear ungreatfull... this realy is a brilliant resource I just think these are important things to work on to get it working perfect :)
#42
12/21/2002 (10:42 pm)
1) It explicitly sets the proper location for the time of day... take a look at the screenshots on the download page... that's what it should look like, first time, or with a reload... sounds like you have something hosed...

2) fxFoliageReplicator was patched so environment AND light sources affect it... make some grass and shoot a projectile over the top... fxGrass I have not looked at, so no, I doubt it will work... though I imagine the same technique could be applied.

3) Indeed the skybox color is adjusted for simulated sunsets and sunrise... though, I know not of what you speak.. perhaps attach a screenshot...

Now, I'm going to friggin' sleep...

ZZZzzZZzzz,
-J
#43
12/22/2002 (1:41 am)
FINALLY GOT IT TO PATCH get the GNU win32 utilities from
a link at http://www.garagegames.com/docs/torque.sdk/gstarted/patches.html
put the patch.exe in c:\torque then type
patch -p0 < c:\torque\daynig~1.pat
#44
12/23/2002 (12:27 am)
This significantly improves the effect, highly recommended.

Here's a little patch that makes the Sunrise/Sunset/Clouds quite a bit more dynamic(and vibrant)... this also fixes a small problem with a strong color split at the horizon... :)

In terrain/sky.cc, change the beginning of renderBans() to look like this:

void Sky::renderBans(F32 *alphaBan, F32 *banHeights, Point3F banPoints[][MAX_BAN_POINTS], Point3F *cornerPoints)
{
   S32 side, x, index = 0;
   F32 angle;
   U8 UalphaIn = U8(alphaBan[1]*255.0f*.95f);
   U8 UalphaOut = U8(alphaBan[0]*255.0f*.95f);

   Point3F dn=tgeDNCurrentBandColor;

   U8 c[3];
   c[0]=U8(dn.x*255.0f);
   c[1]=U8(dn.y*255.0f);
   c[2]=U8(dn.z*255.0f);

and the beginning of setVisibility() to look like this:

void Sky::setVisibility()
{
   if(mSceneManager)
   {	   
      extern bool sgForce16BitTexture;     
      extern bool sgForcePalettedTexture;     
      mRealFogColor.red = S32(mCeil(tgeDNCurrentBandColor.x * 255.0f));
      mRealFogColor.green = S32(mCeil(tgeDNCurrentBandColor.y * 255.0f));
      mRealFogColor.blue = S32(mCeil(tgeDNCurrentBandColor.z * 255.0f));
      mRealFogColor.alpha = 255;
      if(sgForce16BitTexture)
      {
         U8 temp = (mRealFogColor.red >> 4) & 0xF;
         mRealFogColor.red = (temp << 4) | temp;
     
         temp = (mRealFogColor.green >> 4) & 0xF;
         mRealFogColor.green = (temp << 4) | temp;
 
         temp = (mRealFogColor.blue >> 4) & 0xF;
         mRealFogColor.blue = (temp << 4) | temp;

         mSceneManager->setFogColor((ColorF)mRealFogColor);
      } 
      else
      {
         mSceneManager->setFogColor(ColorF(tgeDNCurrentBandColor.x,tgeDNCurrentBandColor.y,tgeDNCurrentBandColor.z));
      }

and finally in renderSkyBox()

void Sky::renderSkyBox(F32 lowerBanHeight, F32 alphaBanUpper)
{
   S32 side, index=0, val;
   U32 numPoints;
   Point3F renderPoints[4]; 
   Point2F texCoords[4];

   Point3F dn=tgeDNCurrentBandColor;
   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   glColor3f(dn.x,dn.y,dn.z);

Vibes,
-J
#45
12/23/2002 (1:37 am)
Thanks alot josh, your work adds new dimensions to the realism in torque.
//BTW i know you hate windows and msvc but im getting really wierd errors on compile. It says it cant find the files atgedaynight.h!!!!!!!!! I have about 4 copies in different directories wtf there all right there...
//
OMFG i feel REAL dumb maybe i should just put them in the right directory...

I will be producing a wealth of media material for your Cthulu like game. H.P lovecraft is the king of horror
#46
12/23/2002 (4:43 am)
I just saw it in action josh. Its the most beautiful realistic in-game rendering effect ive ever seen. Its perfect absolutely perfect.
#47
12/23/2002 (6:37 am)
Yeah, looks absolutely lovely!! :)
Thanks a lot, Josh!!
Check it out in our gallery... ;)
tork.zenkel.com/modules.php?op=modload&name=ToRKGallery&file=index
#48
12/23/2002 (3:33 pm)
Thanks for this Josh - I finally got it sorted out - a single line wrong in the interiorRender.cc - the patcher barfed on a change I had made & then later undone.

Only issue right now is that the sun is rising in the NorthEast and setting in the SouthWest :-)
#49
12/23/2002 (4:15 pm)
Fucking great work Josh!!! Aside from the obvious neat graphical effects of this, it has added a whole new dimension to gameplay. There can be quite a bit of strategy involved when it becomes dark and turns light again. Imagine sneaking into an enemies base when it's dark and hard to see you, setting up remote charges everywhere, leaving before day break, and then detonating safely from your base when day comes around.
#50
12/23/2002 (6:13 pm)
Thanks all...

I'm working very hard to add persistent world support to Torque... (massively) good stuff is in store for 2003!!!

Vibes,
Joshua Ritter
ActionRPG Revolutionary
#51
12/23/2002 (6:20 pm)
Josh - it looks like the azimuth control is hard coded in the Day/Night code, right ? I can't get the flare to respond to editor changes in the azimuth. it does so for things linke brightness and colour animation, not the azimuth.
#52
12/23/2002 (6:55 pm)
Looks real nice on a my GF1, with your latest patches.
Wow !!! Thank you, yet again ;)
#53
12/25/2002 (7:15 am)
I think jopshua understands helping others to help him is one of the best ways to succeed. With his framework for enviromental realism and Massively multi-player capacities, your free to create virtual realities. For us Indies its better than sliced bread!
WWW.ACTIONRPG.COM
#54
12/26/2002 (3:35 am)
This new code realy fixes my horisons up nicely!
The clouds become rather weird now however... (the shades are banded)
I am also having the same problem as Ken, the azimuth isnt effected although the colour is....
The banding of the clouds might be because of my graphics card... its a GF2 mx 400.
If you need some screenshots then i'll try get some done for you, but maybe you already know of this issue.

I was also wondering if it is possible to have fog only render at a certain distance from the player (like grass creation with an inner and outer radius), because atm my fog severely blocks your lovely sky yet if i lower it then my moutains fade in rather horibly :/

Perhapse someone has already come up with a fix for this... i'll have a search around for it.
#55
12/26/2002 (6:40 am)
itd be cool to have the colors fallof from wherever the sun sets. So the colorartion would be more vibrant and saturated where the sun actually rise and set. I have to scan until i see the corona come up as it is now. I dont think the sunrise/set needs more color so much as the rest of the fog needs less.
#56
12/26/2002 (9:17 am)
Thorgrim, make sure you're running in 32 bit color, as I was thinking exactly the same, and when I looked at the video options, I was in 16 bit mode.
#57
12/28/2002 (6:31 pm)
Ahh
Thanks Nicolas I had just upgraded my graphics drivers (+ got directX9) which must have put it back to 16 and I forgot to put it on 32 again :P
Silly me...
Looks great now :D

Still trying to get the sun moving at the right speed though. :/
Are there special settings i need for the fxSunlight object or something? like a specific name?
I thought it was all one in the code... I would have checked the sample mission but it comes up with an error about lighting when i start it up. I'll re do the patch on a new head version sometime and see if it works then.
#58
12/28/2002 (7:11 pm)
Read the text file included in the zip.

-J
#59
01/03/2003 (5:19 am)
This looks pretty sweet. Just a question or two..

Is day the same amount of time as night? If so is there a (fairly) simple way to make it so.. say night is 30 minutes (real life time) and day is 60 minutes? The only thing I can think of is maybe have sfactor tweaked to a different value at say 1800 hours game time to speed up night, then at 0600 slow it down some.

Are all players going to be playing in the same time of day? Like if I join a game thats at 4pm or so.. will I see 4pm, or will I be starting at midnight?

Thanks for sharing this code :)
#60
01/20/2003 (7:55 pm)
Small bug, crash when recorded demo is played in sceneLighting.cc:

void SceneLighting::processEvent(U32 light, S32 object)
{
//TGEDN
//XXX check for NULL pointer
//use the server sun for lighting
tgeDNSun->mLight.mDirection=tgeDNServerSun->mLight.mDirection;
tgeDNSun->mLight.mColor=tgeDNServerSun->mLight.mColor;
tgeDNSun->mLight.mAmbient=tgeDNServerSun->mLight.mAmbient;
...

depends on tgeDNServerSun which is NULL;

Changed sun.cc (did not check to see if this causes any other problems):

bool Sun::onAdd()
{
if(!Parent::onAdd())
return(false);

if(isClientObject())
{
Sim::getLightSet()->addObject(this);
//TGEDN
tgeDNSun = this;
tgeDNServerSun = this; // <<<
}
else
...

Demo recording does not include time / day-night lighting changes.