Fake day night cycle.

tannermyne

L1: Registered
Nov 6, 2015
24
0
I wont go over every little detail. As I hope you dont need to be told how to turn on and off triggers.

For those who never tried to turn off the sun and bring in night in mid game. You may have not noticed you cant enable and disable the light_evn or change the map properties [ie skybox texture] in mid game. Since that being the case theres a "cheap" way to make a day night cycle.

First, you have to make two or more func_ brushes for the skybox.

Screenshot (417).png


Next, have them lay over each other.

Screenshot (418).png


Now, just a bunch of day and night lights to turn on and off.

Screenshot (419).png


I hope you all enjoy this cheap day and night demonstration.

Pros and cons of day and night cycle.

Pros
-its fun

cons
-can hurt game play by distracting players
 

Attachments

  • daynight test.bsp
    859.4 KB · Views: 187
Last edited:

LeSwordfish

semi-trained quasi-professional
aa
Aug 8, 2010
4,102
6,597
oh no, no no no, oh honey no

this isn't "cheap", this will be ludicrously expensive

Every light that can be turned on or off causes the compiler to calculate lightmaps for all surfaces it hits twice. If there are two lights, it will calculate for every surface it hits for every possibility - so in this case, that would be OnOn, OnOff, OffOn, and OffOff - so that's four lightmaps for every surface near those lights. That's four times the lighting compile time, and four times the space required to save the lightmaps.

The trouble is, doing this will require literally hundreds of lights, since it will be lighting the entire map, and then you have each one twice for Day and Night. Assuming for a moment that every surface will be lit by five lights - and that's a low estimate, since light bounces quite a way, you have 10 lights (five night, five day) that need to be calculated for, meaning that every surface will have 2^10 = 1024 lightmaps.

Thats a map filesize about a thousand times bigger, and a compile time about a thousand times longer.
 

tannermyne

L1: Registered
Nov 6, 2015
24
0
The picture was meant to exaggerate it a little bit and this was more of proof of concept. As the source engine does not do it on its own. Seeing how you cant change the skybox texture in mid game. So its a "cheap" trick. Not the real thing, but a neat trick non the less.
 

Attachments

  • daynight test.bsp
    859.4 KB · Views: 170
Last edited:

Idolon

they/them
aa
Feb 7, 2008
2,105
6,106
oh no, no no no, oh honey no

this isn't "cheap", this will be ludicrously expensive

Im not 100% sure but I think Source is smart enough to combine lights with the same name (since they'll always toggle on/off together), so this method would still only produce 4 light styles.

That said, I can't recommend that anyone use this method.
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
It is smart enough for that. Also, you will need a workaround for skyboxes, and smooth transition is impossible.
 

Izotope

Sourcerer
aa
May 13, 2013
698
764
Fake skybox model within the 3D skybox and 2 env_lights should suffice, anything else is madness
 

Tuaam

L6: Sharp Member
Jun 26, 2015
376
248
I don't know if this is even remotely possible, but how about having an animated skybox (As in, to from sunrise to sunset), and then having an env_sun that changes variables based off of a timer.

The problem with a Day / Night map is that while having a system that can do it is hard enough, the gameplay will change. So, you'd want to have lights that switch on / off. The only solution that will actually work is to have the map change times of day at the end of each round. So, one round will be day, and the other will be night.
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Even if sun is namable and can change properties, there will be HUGE TONS of lightmaps (if sun generates them?). Animated skybox howeweris quite possible. A you can't really get away without light_env.
 

Tuaam

L6: Sharp Member
Jun 26, 2015
376
248
Even if sun is namable and can change properties, there will be HUGE TONS of lightmaps (if sun generates them?). Animated skybox howeweris quite possible. A you can't really get away without light_env.
There would be lots of lightmaps, but nothing in comparison to what the previous people suggested.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
What's the limit on the number of frames an animated texture can have? Because even if we animated it at a rate of one frame per second, and had a day/night cycle as short as Minecraft's, that's 20×60=1200 frames. And I don't even want to think about what kind of filesize that would produce if indeed it were possible, even with compression.
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Could have multiple animated skins. Agreed with the second point though.
 

iiboharz

eternally tired
aa
Nov 5, 2014
857
1,291
You can name light_environment entities! The name field isn't there by default, but if you turn off smartedit and add a targetname keyvalue, you can name it, and it will function just like any other light!
 

Another Bad Pun

In the shadows, he saw four eyes lit by fire
aa
Jan 15, 2011
801
1,845
You can name light_environment entities! The name field isn't there by default, but if you turn off smartedit and add a targetname keyvalue, you can name it, and it will function just like any other light!

My guess is that Valve intended for light_environment to be a static light entity only, and didn't include a Name KeyValue in SmartEdit because it was never designed to act as a dynamic light in the first place. And it realistically couldn't be, due to the restrictions of VRAD and lightmaps.

Which goes to show... in Source engine, a day/night cycle probably isn't the best thing to have, at least according to Valve Software.

~

There are probably a couple of instances, over 12 years later, where someone could circumvent the issues that come with a lightmap day/night cycle, but from off the top of my head, none of them seem to be worth it. Unless you're content with a large map file and long compile times, some serious Hammer voodoo would be required if you wanted to create an efficient day/night cycle by changing dynamic lights entities.

Some potential alternative methods:

By abusing an insane amount of color_correction and fog settings, it could be possible to fake a day/night cycle while still using one light_environment. 2fort utilizes this method in a subtle way to give certain areas of the map a distinctive atmosphere - the most obvious example being the greenish tint of the underground sewer area.

The downside to this method is that color_correction can be disabled, ruining the effect for some players, who wouldn't see a day/night cycle at all. Also, achieving a day or night setting by smothering a heavy filter over the player's screen might look terrible! Who knows.

In newer Source games, where env_projected textures are supported (Portal 2, CSGO) you could maybe abandon a light_environment entirely, and use an animated projected texture to fake dynamic sunlight. But I'm not sure if animated projected textures are supported, or feasible - and in the case of CSGO, without a light_environment dictating the ambient color of the shadows, what would a setup like this even look like?

Source engine is so old, and the current lighting system so dependent on lightmaps, that a custom map might never be able to achieve a smooth day/night cycle in Source. Especially in TF2.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
TF2 is kind of a pointless game to put a day-night cycle into anyway because the rounds only last like 30 minutes tops. It's actually more realistic to make it look like no time has passed during that time, unless you're building a map specifically to be used on 24/7 servers.

You can name light_environment entities! The name field isn't there by default, but if you turn off smartedit and add a targetname keyvalue, you can name it, and it will function just like any other light!
This would be great, but for whatever reason they're restricted from doing anything except turning on and off.
 

Tuaam

L6: Sharp Member
Jun 26, 2015
376
248
I think a better idea would be to have the level swap env_sun and switch the skybox, so after every round it can swap the scenery for night / day based ones.

So Instead of a dynamic system, it's semi dynamic.
 
Oct 6, 2008
1,947
445
what would be need is a skybox texture starting at point x, then the exact same skybox texture in different shades of day>night (maybe 10 of them) then adjust light levels accordingly as the skybox transitions in. You can do the transition from 0-255 in the brush texture as they come in - one is 0-255 and the other is 255-0