Day / Night cyles in Torque
by Stefan Beffy Moises · in Torque Game Engine · 05/25/2002 (4:44 am) · 42 replies
Every once in a while this issue is coming up here in the forums, but nobody has been "officially" working on this topic it seems... so lets kick off the discussion here how it could be achieved... this topic is also part of the Temporary Torque TO DO list, so I guess GG itself would be interested in getting this done ;-)
Some guys have submitted a devshot showing their day-/night cylce engine here, but they didn't say anything how it's done and didn't post any resource or something yet...
We've started discussing this issue in Melv's lighting thread, here are some quotes:
"... you'd have to change the generated lightmaps at runtime to use the current lighting system, i guess... and I also guess you'd have to change/overlay the skyboxes, and do a million other things to make it really realistic... Morrowind is doing these transitions amazingly, they have beautiful nightly settings, etc. but I've got no idea how it's done..."
"As you've mentioned there are so many things that would need to change, all of which I could see methods of achieving but the one that I'm not that familiar with is the terrain.
The cheapest/quickest way I could see for the terrain is to remove the lightmaps completely! Yes, I know I'm probably treading on tender ground (sorry for the pun) with some but it would be feasible to remove the light (or more to the point the shadow) maps and bung in a normal dynamic omni light when rendering."
So if anybody has something to contribute, some wishes what should be implemented, a great idea how to achieve it, etc., post it here... ;-)
Some guys have submitted a devshot showing their day-/night cylce engine here, but they didn't say anything how it's done and didn't post any resource or something yet...
We've started discussing this issue in Melv's lighting thread, here are some quotes:
"... you'd have to change the generated lightmaps at runtime to use the current lighting system, i guess... and I also guess you'd have to change/overlay the skyboxes, and do a million other things to make it really realistic... Morrowind is doing these transitions amazingly, they have beautiful nightly settings, etc. but I've got no idea how it's done..."
"As you've mentioned there are so many things that would need to change, all of which I could see methods of achieving but the one that I'm not that familiar with is the terrain.
The cheapest/quickest way I could see for the terrain is to remove the lightmaps completely! Yes, I know I'm probably treading on tender ground (sorry for the pun) with some but it would be feasible to remove the light (or more to the point the shadow) maps and bung in a normal dynamic omni light when rendering."
So if anybody has something to contribute, some wishes what should be implemented, a great idea how to achieve it, etc., post it here... ;-)
About the author
#2
I'll certainly post it as a resource when it's done.
05/25/2002 (8:56 am)
I'm actually about 75%-80% done with the kind of dynamic lighting required for day-night transitions. ;)I'll certainly post it as a resource when it's done.
#3
05/25/2002 (9:01 am)
Sweet! Do you have any details for us what you're doing and how you do it?
#4
05/25/2002 (9:12 am)
Could this make its way into CVS?
#5
05/25/2002 (12:00 pm)
I'll detail it when it's done ... I'm still not totally sure if it's gonna work perfectly ;)
#6
The problem that arises is that OpenGL can't emulate vertex shaders AFAIK, so the only way you could use this advanced lighting and all and you don't have at least a Geforce 3+ (yes, geforce 4mx does have vertex shaders) you would have to use DirectX on windows as it contains an emulation layer.
What would be really nice is something similiar to netimmerse where you can specify per object which pipeline it goes down. (the fixed pipeline or the programmable pipeline)
-Tim aka Spock
05/25/2002 (12:55 pm)
I'd use vertex shaders to acheive the lighting of everything. Vertex Shaders still give you a gain in speed even if your card does not support them. If that's done, then rewriting the interiors would need to be done too to remove the bsp and lightmaps. Of course all of this should be optional that you can turn on so that there is still support for older cards and older CPUs as all of this will require a good deal of power, specially if the CPU has to do the vertex shaders also.The problem that arises is that OpenGL can't emulate vertex shaders AFAIK, so the only way you could use this advanced lighting and all and you don't have at least a Geforce 3+ (yes, geforce 4mx does have vertex shaders) you would have to use DirectX on windows as it contains an emulation layer.
What would be really nice is something similiar to netimmerse where you can specify per object which pipeline it goes down. (the fixed pipeline or the programmable pipeline)
-Tim aka Spock
#7
05/25/2002 (8:31 pm)
Tim: and in plain English your post translates to....? :P
#8
Making use of advanced features :)
I'm no where near really knowledgable about these advanced features but I believe you can use vertex shaders combined with normal maps (which can be generated from heightmaps) to achieve per pixel lighting.
-Tim aka Spock
05/26/2002 (3:06 am)
Basically torque would look closer to Doom 3 than Quake 3. But the "advanced path" in torque would contain the around the same requirements as Doom 3. Basically using your own lighting model instead of the preprogrammed ones that opengl and DirectX offer.Making use of advanced features :)
I'm no where near really knowledgable about these advanced features but I believe you can use vertex shaders combined with normal maps (which can be generated from heightmaps) to achieve per pixel lighting.
-Tim aka Spock
#9
Switching the renderer to vertex lighting mode and then modulating the vertex colors would be the easiest way to go... it is possible this could be made to work with lightmaps...
Otherwise, it would be possible to light the level at full daylight and then modify the lightmaps at run time... this could be a pain in the butt... also, interiors that had self illumination would need to be detected and not altered...
Advanced features like Vertex/Pixel shaders will limit who will be able to have day and night and could limit how fast it will run... for such an integral feature they aren't currently a good fit...
-J
10/09/2002 (6:28 am)
This is something I need in Torque... I am not excited about maintaining anything against the cvs, so I am in hover mode on it...Switching the renderer to vertex lighting mode and then modulating the vertex colors would be the easiest way to go... it is possible this could be made to work with lightmaps...
Otherwise, it would be possible to light the level at full daylight and then modify the lightmaps at run time... this could be a pain in the butt... also, interiors that had self illumination would need to be detected and not altered...
Advanced features like Vertex/Pixel shaders will limit who will be able to have day and night and could limit how fast it will run... for such an integral feature they aren't currently a good fit...
-J
#10
For dynamically lighting the terrain - could a normal map be created for the terrain and instead of looping through the vertices to light it becomes a fairly simple image processing operation, just loop through the normal map and derive a lightmap for it. The buildings shadows would be more complicated of course.
C.
10/09/2002 (7:21 am)
Don't a lot of cards already support vertex shaders? My old GeForce 256 has some support for them, a lot of demos of vertex shaders run really quickly on it, much quicker than plain ol' jane software rendering. I know on the mac I am using and extensions that aren't really supported by the card seem to get tossed at the Altivec units and it churns the data like water. For dynamically lighting the terrain - could a normal map be created for the terrain and instead of looping through the vertices to light it becomes a fairly simple image processing operation, just loop through the normal map and derive a lightmap for it. The buildings shadows would be more complicated of course.
C.
#11
One of the problems with Day/Night in Torque is the amount of stuff it touches... I had to modify a fair bit of engine code; so will not be submitting this as a resource... but I will post my method here... in the hopes someone may find it useful.
This isn't a "perfect" solution... the amount of potential detail is near endless... Though, I would like to stress that this solution: looks very very good, is a complete solution, and that it is also quite compatible/efficient... anyway, it works for my game...
Also, a big thanks to Melv... his stuff really helps makes the system shine...
General:
I have time of day colors being interpolated... dusk (yellowish), day (whiteish), dusk (redish), night (blueish) ... this gives that added bonus of overriding light color for say an afternoon shower/raging thunderstorm...
I would recommend against doing linear lighting on the day/night cycle... mix it up a little and thru in some extra keys... night waxing and waning gently as clouds go overhead is cooler than a solid color or slow shift!
Interiors and Terrain:
[EDIT: OLD WAY] //I used vertex colors ...
[EDIT: NEW WAY] I switched to simply using emissive material color... I changed the plan on where vertex colors will be used...
In additiion, I decoupled the interior base lighting and mission lighting(not too complicated)... this is so base lighting (lightmaps calculated in map2dif) will survive in evening/night... looks sweet... I ended up with three passes... (mission lightmap + base lightmap) * textuire
Static Shapes:
I use the client side Sun object and modulate color ... quick, easy, and effective... support could be added to the Sun class to negate this hack... but until I have need... well...
Water:
I switched to Melv's fluid code (though, the Torque stuff works the same WRT this... )... here I just modulate vertex RGB and enviornment map intensity...
Sky:
I worked pretty hard on this... I use the sky bands to make some nice shifting gradients for sunrise/sunset... also modulate sky color.. very dynamic and beautiful!
Sun:
I used Melv's fxSunlight... it is awesome.. really no tweaks other than making some client side stuff that hooked to Day/Night code.. I will also be using this to implement a moon...
Foliage:
I used Melv's fxFoliageReplicator... adding support to it for lighting... as well as support for the point lights... nothing like a projectile light flying across grass...
-J
10/28/2002 (7:44 pm)
I just wrapped up my day/night stuff... and it looks/feels awesome :)One of the problems with Day/Night in Torque is the amount of stuff it touches... I had to modify a fair bit of engine code; so will not be submitting this as a resource... but I will post my method here... in the hopes someone may find it useful.
This isn't a "perfect" solution... the amount of potential detail is near endless... Though, I would like to stress that this solution: looks very very good, is a complete solution, and that it is also quite compatible/efficient... anyway, it works for my game...
Also, a big thanks to Melv... his stuff really helps makes the system shine...
General:
I have time of day colors being interpolated... dusk (yellowish), day (whiteish), dusk (redish), night (blueish) ... this gives that added bonus of overriding light color for say an afternoon shower/raging thunderstorm...
I would recommend against doing linear lighting on the day/night cycle... mix it up a little and thru in some extra keys... night waxing and waning gently as clouds go overhead is cooler than a solid color or slow shift!
Interiors and Terrain:
[EDIT: OLD WAY] //I used vertex colors ...
[EDIT: NEW WAY] I switched to simply using emissive material color... I changed the plan on where vertex colors will be used...
In additiion, I decoupled the interior base lighting and mission lighting(not too complicated)... this is so base lighting (lightmaps calculated in map2dif) will survive in evening/night... looks sweet... I ended up with three passes... (mission lightmap + base lightmap) * textuire
Static Shapes:
I use the client side Sun object and modulate color ... quick, easy, and effective... support could be added to the Sun class to negate this hack... but until I have need... well...
Water:
I switched to Melv's fluid code (though, the Torque stuff works the same WRT this... )... here I just modulate vertex RGB and enviornment map intensity...
Sky:
I worked pretty hard on this... I use the sky bands to make some nice shifting gradients for sunrise/sunset... also modulate sky color.. very dynamic and beautiful!
Sun:
I used Melv's fxSunlight... it is awesome.. really no tweaks other than making some client side stuff that hooked to Day/Night code.. I will also be using this to implement a moon...
Foliage:
I used Melv's fxFoliageReplicator... adding support to it for lighting... as well as support for the point lights... nothing like a projectile light flying across grass...
-J
#12
10/28/2002 (8:03 pm)
Screenshots, Joshua! Screenshots please! You know we just ache for those screenshots! :P
#14
The shots don't really do justice... there is a LOT of animation going on... the sun really feels like it is burning; it pulses and distorts... it also ducks behind trees kinda like in Halo... also notice that the sky/clouds are affected by the sunset... nice huh?
The water undulates... the shoreline gets moonlight dancing off it... the grass softly blows in the breeze... and is lit up by rocket fire...
If you look really close you can see some buildings(stronghold towers)... there are two torches on the outside that remain lit... hovels and stuff can have lit doorways you see in the way off...
Also the player's shadow changes direction over the course of the day... and also get's longer at dusk (SWEET!)
And of course, if multiple players log into the game... it's the same time for all of them :)
Oh, the sunrise is quite nice too... woot!
Cheers,
-J
10/29/2002 (2:54 pm)
Below is a sunset sequence... some of the description is for those unfamiliar with some of Melv's fine work :)The shots don't really do justice... there is a LOT of animation going on... the sun really feels like it is burning; it pulses and distorts... it also ducks behind trees kinda like in Halo... also notice that the sky/clouds are affected by the sunset... nice huh?
The water undulates... the shoreline gets moonlight dancing off it... the grass softly blows in the breeze... and is lit up by rocket fire...
If you look really close you can see some buildings(stronghold towers)... there are two torches on the outside that remain lit... hovels and stuff can have lit doorways you see in the way off...
Also the player's shadow changes direction over the course of the day... and also get's longer at dusk (SWEET!)
And of course, if multiple players log into the game... it's the same time for all of them :)
Oh, the sunrise is quite nice too... woot!
Cheers,
-J
#15
10/29/2002 (3:01 pm)
I knew they'd be worth the wait. Those screenshots are incredible!
#16
10/29/2002 (3:07 pm)
O M G.
#17
It would be awesome if you could post a resource or a zip file of all the changes! But hey, in any event that is very very cool.
10/29/2002 (3:56 pm)
Holy crap.It would be awesome if you could post a resource or a zip file of all the changes! But hey, in any event that is very very cool.
#18
What kind of performance drain does it cause? And does it cause any other 'oddities' when you introduce dynamic lighting from projectiles, etc. against the terrain?
10/29/2002 (4:06 pm)
Joshua: O M F G!!!! That is INCREDIBLE!What kind of performance drain does it cause? And does it cause any other 'oddities' when you introduce dynamic lighting from projectiles, etc. against the terrain?
#19
Excellent performance... see my description of the method above...
The only "big" thing is adding a pass to interiors so that their base lighting survives night... which is nice for light coming out of buildings, etc...
Glad you folks like it! Whee!
-J
10/29/2002 (4:17 pm)
Everything works... zero oddities...Excellent performance... see my description of the method above...
The only "big" thing is adding a pass to interiors so that their base lighting survives night... which is nice for light coming out of buildings, etc...
Glad you folks like it! Whee!
-J
#20
10/29/2002 (10:57 pm)
That is just incredible. I really like the little bit of sunlight that flares when it is between the mountains during the sunset. Little details like that just make it more realistic seeming.
Associate Melv May
I've been quoted and I had only been awake for around 6 minutes (2 of which were booting by pc). 8)
This should be an interesting discussion which I'll join in later when I've finished what I'm doing.
- Melv.