Background Background Background Background Background Background


How to use the _skybox entity

What is the _skybox entity?

The _skybox is one of my favourite entities, it allows for mappers to not just rely on 6-image 2d skyboxes and is a clever solution to upscaling geometry over a large area, while keeping the map size and VIS splits to a minimum.

The concept of the _skybox entity is simple - it's a compiler only object that projects whatever is inside the closed off box where it's located, onto wherever surface you have added a sky shader between the sky textures and the player world. Think of it as a full 360° camera and the point of projection is where the Radiant co-ordinates are 0, 0, 0 so if you have your map way off from that you will probably have to move it.

Constructing a _skybox

Construct your map as normal, texturing your sky brushes with what ever sky shader you fancy - in order for this to work, your map must have a sky shader for the _skybox entity to project to
The most important part is that the room or box where the _skybox is located MUST be completely sealed off from rest of the map or the compile will crash, or take an abusrd amount of time to compile.

So this is one of the few occasion where the 'hollow' function is a good tool. Make a caulk brush, full squared and hollow it. Add the _skybox in the middle of the inside - viola! you have a portal sky to play with. A good place to have it is below your player world centered around the 0 Z axis. This way it will not influence the minimap's size or depth render.

It's not suprising that too much detail can slow down compile times and framerates on older machines, the key point you need to remember is that at any point in the map where your sky is being rendered - you are guarenteed to render all of the project geometry with it.

The results above show the view from inside the small box where the projected geometry is, while below shows the results from inside the map.

Perfect Alignment

The trick to understand is the _scale value of the _skybox entity. Set it to 32 and things in the skybox will appear 32 times bigger on the skysurfaces, default 64 is 64 times, 1 is 1 time and pretty pointless, you can just skip using it then. The final projection is all relative to the origin point of the _skybox entity and the geometry inside of the hollow box containing the _skybox entity.

There are no rules with how big or small your containing box can be, as seen with Codey's bridge in Herring.

With some care you can really match objects position in the skybox with objects in the player world. This is a a very good way of keeping the illusion of a big area, but still have vis blocked between parts of the map. That's the trick of Herring, the mid building is a ceiling to floor wall but it looks like it's one place with the bridge placed in the portalsky.

Other Examples

A more simple example is the water I added into Derelict - 2 layers of the same water shader, combined with an alphablend to the colour of the skybox to give the impression of endless seas (with depth, thanks to multiple layers).

Things to Remember:

  • Stick to powers of 2 with your _scale value, this makes it easier to line up geometry of your projected skybox with your true map geometry.
  • Textures have to be scaled down accordingly to _scale value. IE if you use 32 and have a texture in player area at 0.5000 you need to scale it to 0.0156. (0.5 / 32).
  • No entities will work in a projected sky. So sadly, no moving stuff. You can use shaders with tcMod values to fake these effects.
  • I haven't tried if light entities work or not, but light emitting shaders do.
  • Shadows can be cast from the skybox to the playerworld or not, utilizing the cast/recieve shadow values in a func_group
  • As func_group entities are valid, it is also possible to increase the lightmap scale of projected sky geometry (at the cost).
  • Skyshader cloudlayers work as normal and will render behind the skybox objects.
  • No patch meshes allowed, unless you compile with -patchmeta. You'll get MAX_PATCH_PLANES every time.
  • Deformvertexes shaders can be used on _skybox geometry, but the values you use must be scaled up by the same value you assigned to _scale.
  • misc_models work fine, unless they're targeted at an entity within the map.