Fake day night cycle.

Discussion in 'Tutorials & Resources' started by tannermyne, Nov 26, 2016.

  1. tannermyne

    tannermyne L1: Registered

    Messages:
    24
    Positive Ratings:
    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
     

    Attached Files:

    Last edited: Nov 26, 2016
  2. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,106
    Positive Ratings:
    6,006
    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.
     
    • Agree Agree x 8
  3. tannermyne

    tannermyne L1: Registered

    Messages:
    24
    Positive Ratings:
    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.
     

    Attached Files:

    Last edited: Nov 26, 2016
  4. Infomaniac

    Infomaniac L6: Sharp Member

    Messages:
    341
    Positive Ratings:
    168
    [​IMG]
    I have Loadsamoney for this!
     
    • Funny Funny x 7
  5. Idolon

    aa Idolon the worst admin

    Messages:
    1,519
    Positive Ratings:
    4,332
    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.
     
    • Agree Agree x 2
  6. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,429
    Positive Ratings:
    1,173
    It is smart enough for that. Also, you will need a workaround for skyboxes, and smooth transition is impossible.
     
    • Agree Agree x 1
  7. Izotope

    aa Izotope Never releases maps

    Messages:
    609
    Positive Ratings:
    571
    Fake skybox model within the 3D skybox and 2 env_lights should suffice, anything else is madness
     
  8. tannermyne

    tannermyne L1: Registered

    Messages:
    24
    Positive Ratings:
    0
    Env_lights cant be named. So cant enable and disable them.
     
    • Respectfully Disagree Respectfully Disagree x 1
  9. Tuaam

    Tuaam L6: Sharp Member

    Messages:
    326
    Positive Ratings:
    187
    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.
     
  10. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,429
    Positive Ratings:
    1,173
    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.
     
    • Agree Agree x 2
  11. Tuaam

    Tuaam L6: Sharp Member

    Messages:
    326
    Positive Ratings:
    187
    There would be lots of lightmaps, but nothing in comparison to what the previous people suggested.
     
  12. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,217
    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.
     
  13. Crowbar

    aa Crowbar perfektoberfest

    Messages:
    1,429
    Positive Ratings:
    1,173
    Could have multiple animated skins. Agreed with the second point though.
     
  14. iiboharz

    aa iiboharz Meme Queen

    Messages:
    707
    Positive Ratings:
    1,030
    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!
     
    • Agree Agree x 2
  15. Another Bad Pun

    Server Staff Another Bad Pun learning to fly

    Messages:
    578
    Positive Ratings:
    1,177
    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.
     
    • Agree Agree x 2
  16. Hosomi

    Hosomi L3: Member

    Messages:
    130
    Positive Ratings:
    40
    Can you do that with any entity?
     
  17. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,217
    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.

    This would be great, but for whatever reason they're restricted from doing anything except turning on and off.
     
  18. Tuaam

    Tuaam L6: Sharp Member

    Messages:
    326
    Positive Ratings:
    187
    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.
     
  19. Kill_the_Bug

    Kill_the_Bug L14: Epic Member

    Messages:
    1,461
    Positive Ratings:
    237
    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