- Feb 18, 2018
- 16
- 10
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.
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.