Day and Night?
by Daniel Bennifer · in Torque Game Engine · 08/26/2007 (9:11 am) · 9 replies
Hi,
How would you go about adding a day and night cycle? So that when its day time the sun is out, After a while, The sun goes away/down and the moon comes up. This would also mean a change of the Skybox to a night version.
Anyone have possible ideas about this?
How would you go about adding a day and night cycle? So that when its day time the sun is out, After a while, The sun goes away/down and the moon comes up. This would also mean a change of the Skybox to a night version.
Anyone have possible ideas about this?
About the author
#2
Would it take alot to port them to 1.5? As i am kind of new at the moment.
Also, There is no one else working on a 1.5 version?
08/27/2007 (1:09 pm)
Hi ,Would it take alot to port them to 1.5? As i am kind of new at the moment.
Also, There is no one else working on a 1.5 version?
#3
08/27/2007 (2:26 pm)
Easy to port if you read the code. I have essentially the same stuff going in TGEA.
#4
I'm using TGE 1.5.2 SDK, I have a pretty nice one made.
You might check out obtaining different values of objects currently in the game and learn how to tweak them to make your own night/day cycle. Try obj.dump(); on everything. Also check out sky inspectPostApply and in the Editor, $fxSunlight and other lighting/filtering effects. You can do it all through script with no engine changes. (Use your imagination and a little clever thinking) And you can make it at least morrowind quality. The only thing I had problems on was the skybox. So I use cloud layers and it comes out sweet looking.
I got a lot of my ideas for mine though "A Game Programmers Guide to Torque" and learned the scripting side of it with "3D Programming All In One"
Well worth the money.
10/08/2007 (9:35 am)
@FlameGuardI'm using TGE 1.5.2 SDK, I have a pretty nice one made.
You might check out obtaining different values of objects currently in the game and learn how to tweak them to make your own night/day cycle. Try obj.dump(); on everything. Also check out sky inspectPostApply and in the Editor, $fxSunlight and other lighting/filtering effects. You can do it all through script with no engine changes. (Use your imagination and a little clever thinking) And you can make it at least morrowind quality. The only thing I had problems on was the skybox. So I use cloud layers and it comes out sweet looking.
I got a lot of my ideas for mine though "A Game Programmers Guide to Torque" and learned the scripting side of it with "3D Programming All In One"
Well worth the money.
#5
If you have access to AFX, you can find the latest Torque MMO Kit C++ patch in this thread:
http://www.garagegames.com/mg/forums/result.thread.php?qt=66412
It includes an improved Day/Night cycle based on the original sources and has been ported to TGE 1.5
-PG
10/08/2007 (9:50 am)
@Dan: Both of those resources are hacked up versions of some source we pushed out in like 2002. They are completely missing most of the interesting functionality especially on the interior rendering side.If you have access to AFX, you can find the latest Torque MMO Kit C++ patch in this thread:
http://www.garagegames.com/mg/forums/result.thread.php?qt=66412
It includes an improved Day/Night cycle based on the original sources and has been ported to TGE 1.5
-PG
#6
Oblivion, just an example, does this by simply not using any pre-baked lighting. Everything is dynamically lit, but as a consequence, buildings and such do not cast proper shadows from the sun, they simply darken areas around them in a very general sense. While it's not especially realistic, the large, dynamic nature of the game world and the percentage of the game spent outside tends to make it pretty easy to ignore the unrealistic lighting. This system wouldn't work well in a close-quarters game like Half-Life, though this type of game is rarely open-ended enough to require it.
If you ignore all of these issues, it's all actually rather simple. Either rework an existing resource for your purposes, or simply create some script object which ticks every few seconds, minute, hour, or whatever, and change all the appropriate variables (sun elevation/color, skybox, cloud settings, etc) at certain times of day. The values for an object which you can set tend to be the same ones available when selected in the editor, but open up the appropriate source file for a reference of script-side variables and functions.
I think I say this a lot, but if you can't do it, you don't need it, end of story. Seriously, no intention of being rude, but if you're a new TGE user, I suggest messing with some of the easier stuff first, until you get grounded. It's easy to think you should just dive headfirst, but collecting a bunch of cool features like a Time of Day system with no idea of how to use them won't do you any good, and will just result in standard Torque Feature Burnout Syndrome (TFBS). ;D
10/13/2007 (2:37 pm)
It's worth jumping in here and mentioning that none of the solutions you'll find on here are likely to deal with the basic issue of a day/night cycle in Torque: Terrain and interior lighting is pre-baked, and as such it won't change with a moving or brightening/darkening light source. There are many potential solutions for this, but I haven't seen one implemented (pre-render a number of lightmaps and just load at certain time intervals, live lighting calculations spread out over time, etc).Oblivion, just an example, does this by simply not using any pre-baked lighting. Everything is dynamically lit, but as a consequence, buildings and such do not cast proper shadows from the sun, they simply darken areas around them in a very general sense. While it's not especially realistic, the large, dynamic nature of the game world and the percentage of the game spent outside tends to make it pretty easy to ignore the unrealistic lighting. This system wouldn't work well in a close-quarters game like Half-Life, though this type of game is rarely open-ended enough to require it.
If you ignore all of these issues, it's all actually rather simple. Either rework an existing resource for your purposes, or simply create some script object which ticks every few seconds, minute, hour, or whatever, and change all the appropriate variables (sun elevation/color, skybox, cloud settings, etc) at certain times of day. The values for an object which you can set tend to be the same ones available when selected in the editor, but open up the appropriate source file for a reference of script-side variables and functions.
I think I say this a lot, but if you can't do it, you don't need it, end of story. Seriously, no intention of being rude, but if you're a new TGE user, I suggest messing with some of the easier stuff first, until you get grounded. It's easy to think you should just dive headfirst, but collecting a bunch of cool features like a Time of Day system with no idea of how to use them won't do you any good, and will just result in standard Torque Feature Burnout Syndrome (TFBS). ;D
#7
So does that handle the interior problems mentioned by Henry? I have a different problem, namely that I allow the player to build interiors - all of which appear unlit. So fixing this problem would resolve the two main issues I am having.
Is there any indication Torque 2 will handle this better? I can live without day/night cycles, but being able to have the player build interiors is central to my game concept.
10/29/2007 (2:49 pm)
It includes an improved Day/Night cycle based on the original sources and has been ported to TGE 1.5
So does that handle the interior problems mentioned by Henry? I have a different problem, namely that I allow the player to build interiors - all of which appear unlit. So fixing this problem would resolve the two main issues I am having.
Is there any indication Torque 2 will handle this better? I can live without day/night cycles, but being able to have the player build interiors is central to my game concept.
#8
In 1.5 you can pre-light your buildings so that they at least don't appear black, but you won't get that lighting to match the light sources in the map vs. the placement of the object. You can probably get it "good enough," though.
There's no realistic way to calculate these lightmaps on the fly, though it seems like it might be possible to "append" to a lightmap, calculating lighting data for 1 object recently added to the scene and adding that lighting data to the existing lightmap. The process should only take a second or two for a single building (on modern hardware). It would still pause when adding a new DIF to the scene, but only for an instant. This is likely to be more complex than it sounds.
In my setup, I use DTS objects with polysoup collision for user-built structures. They don't cast proper shadows, but they look decent enough.. though the largest buildings I use this for are not especially complex.
10/30/2007 (3:07 am)
There's no existing solution for this issue that doesn't involve disabling pre-baked lighting. You can force interiors to be lit like DTS objects, which is basically what Oblivion does.In 1.5 you can pre-light your buildings so that they at least don't appear black, but you won't get that lighting to match the light sources in the map vs. the placement of the object. You can probably get it "good enough," though.
There's no realistic way to calculate these lightmaps on the fly, though it seems like it might be possible to "append" to a lightmap, calculating lighting data for 1 object recently added to the scene and adding that lighting data to the existing lightmap. The process should only take a second or two for a single building (on modern hardware). It would still pause when adding a new DIF to the scene, but only for an instant. This is likely to be more complex than it sounds.
In my setup, I use DTS objects with polysoup collision for user-built structures. They don't cast proper shadows, but they look decent enough.. though the largest buildings I use this for are not especially complex.
#9
This is probably why the game I have in my mind's eye has never been made to be honest. It is crazy that such a thing wouldn't have seen a solution in so many years of game design.
I saw one post with a link to source that claimed someone had found a way to generate ~4 lightmaps ahead of time, then swap them in and out (using some fade method). Its too bad the link was broken :/ The buildings don't look terrible when GLLighting is used, but the lack of terrain lighting makes full night or full day not possible. The terrain is always too light or too dark. So swapping in a pregenerated lightmap would work. Still looking for where that might be possible.
Better yet would be if I could swap in pregenerated lightmaps for the buildings. Still, DTS objects placed inside buildings will be lit from the sun :/ That could pose issues when folks start decorating the houses.
So let's say I do this (which is what I am doing now). How do I make it so when players enter a building, they stop getting lit from the sun? I am pretty sure Oblivion is doing that at least. Heh, as soon as I find the DVD I'll be reinstalling to check it out in more depth. Thanks for the response!
10/30/2007 (6:06 am)
Yeah part of the allure to making an RTS with real buildings, is that people will be able to go into those buildings and walk around in them, place tables and chairs for sitting, etc. I'd hate to think what using DTS models would do for framerates as the number of colissions started going up.This is probably why the game I have in my mind's eye has never been made to be honest. It is crazy that such a thing wouldn't have seen a solution in so many years of game design.
I saw one post with a link to source that claimed someone had found a way to generate ~4 lightmaps ahead of time, then swap them in and out (using some fade method). Its too bad the link was broken :/ The buildings don't look terrible when GLLighting is used, but the lack of terrain lighting makes full night or full day not possible. The terrain is always too light or too dark. So swapping in a pregenerated lightmap would work. Still looking for where that might be possible.
Better yet would be if I could swap in pregenerated lightmaps for the buildings. Still, DTS objects placed inside buildings will be lit from the sun :/ That could pose issues when folks start decorating the houses.
Quote:You can force interiors to be lit like DTS objects, which is basically what Oblivion does.
So let's say I do this (which is what I am doing now). How do I make it so when players enter a building, they stop getting lit from the sun? I am pretty sure Oblivion is doing that at least. Heh, as soon as I find the DVD I'll be reinstalling to check it out in more depth. Thanks for the response!
Torque Owner Dan -
Polished up daylight cycles - 2003
Day night cycles with seasons - 2004
Both might be rather out of date. The last one has people asking for 1.5 version, which there must not be a resource for it. Would be a starting point anyway.