Multiple 3d skyboxes

Discussion in 'Tutorials & Resources' started by monster860, Mar 11, 2018.

  1. monster860

    monster860 L1: Registered

    Messages:
    9
    Positive Ratings:
    3
    So, you want to create multiple 3d skyboxes? Well with some slight workarounds, you can! When valve was developing their source engine, they considered the idea of having multiple skyboxes. Some code is still left around for this functionality that we can take advantage of, with a bit of hammer trickery.

    1. The point_template entity

    The first thing you'll need to do is create a point_template somewhere in your map. Preferably, this should be somewhere in the "skybox" area of your map. Then, place a sky_camera in the exact same spot.

    ! Wherever you place a sky_camera entity, vvis will not optimize. Do not place it in the main playable area of your map.

    Open the entity properties of the sky_camera, turn off SmartEdit, click Add, and put in "targetname" for key and "current_camera" for targetname. Then, open the point_template entity you created, turn SmartEdit back on, and change it's name to "camera_template", set Template 1 to "current_camera" and make sure that under Flags, "Preserve entity names (Don't do name fixup) is checked.

    Now, this is the part where we get into major hack territory. Unfortunately, you can't actually use a point_template with a sky_camera normally, because sky_camera entities are preserved across map loads. point_template builds it's template on map load, and since the sky_camera isn't there on consequent map loads, it won't be able to use it. This means that in order to actually use a point_template with a sky_camera, it needs to be preserved across map loads as well.

    To do this, simply create (or use an existing one) logic_auto, and add an output with the output "OnNewGame", targeting the camera_template entity, and the input of "AddOutput" with a paremeter override of "classname sky_camera"

    Normally, once an entity is spawned, Source doesn't care about what the classname of an entity is. It will still work fine. However, it is used, when deciding upon map reload, whether to keep the entity or whether to discard it. Thus, changing the classname will cause it to be preserved across map loads as well. (You can use this trick to make other entities preserved across map loads as well if you want to.)

    2. The env_entity_maker

    Place an env_entity_maker wherever you want the origin of a skybox to be. Give it whatever name, set the template to be "camera_template" and leave all the flags unchecked.

    Add the following outputs:

    OnUser1 -> !self -> ForceSpawn
    OnUser1 -> current_camera -> Kill

    (both of them can have no delay)

    3. Wrapping it all up

    Now, whenever you do FireUser1 on any of the env_entity_maker entities, it will place the sky_camera at it's location, and it will instantly update to clients.

    For fun times, you can parent the env_entity_maker to a func_tracktrain, have it move around, and do FireUser1 with a logic_timer ever 0.02 seconds to have a skybox that moves around. This is the result of that.
     
    • Like Like x 2
    • Thanks Thanks x 1
  2. Rare Endangered Spycrab

    Rare Endangered Spycrab L2: Junior Member

    Messages:
    97
    Positive Ratings:
    30
    I tried this and the skybox was inconsistent in updating, sometimes it updated instantly and other times it lagged for a few seconds. Nevertheless, pretty cool trick.
     
  3. Kill_the_Bug

    Kill_the_Bug L14: Epic Member

    Messages:
    1,463
    Positive Ratings:
    237
    Can you put in some pics to show it in action?
     
  4. Izotope

    aa Izotope Never releases maps

    Messages:
    613
    Positive Ratings:
    572
    I just tried this and the skybox change works fine, however it doesn't seem to load the first one at the map start, so I start with no 3d skybox.
     
  5. monster860

    monster860 L1: Registered

    Messages:
    9
    Positive Ratings:
    3
    I mean you really ought to be doing the skybox change *on* map start. Otherwise it might remember the wrong skybox across a load.
     
  6. Izotope

    aa Izotope Never releases maps

    Messages:
    613
    Positive Ratings:
    572
    Wasn't mentioned in the above tutorial, though :3
    I'll try more of this later

    EDIT:
    Made it so it picks the default sky at the mapstart and now I can flawlessly alternate between skies.
    [​IMG]
     
    • Like Like x 1
    Last edited: Mar 11, 2018