What are Cubemaps?

Cubemaps are what the Source Engine uses to calculate shininess on any face or model that supports it. To render the reflectivity properly would involve the engine drawing each scene twice and slow things down considerably. The DX9 water shader uses this effect and obviously if over-used you will get slow-down.

When Cubemaps are placed in to the map and the buildcubemaps command is used it takes 6 low-res screenshots (64x64 by default) at each cubemap point (left, right, north, south, up & down) and applies these to the textures/models closest to it. This way you get a shiny effect (although a little crude) on the textures or models. These "shots" are then sorted into the .bsp when the map is restarted. Only static images are taken so you will not see any moving objects etc but it's enough to give the effect.

Models and textures will automatically use the nearest cubemap to them, and if you turn on cheats and use the impulse 81 command you will six globes that will show you what cubemap is being used at that time.

When should they be used?

Cubemaps should be used in almost all areas of your map, if you have a room with some windows at one end and a light in the centre you would want a cubemap in the room to apply the main light to all the surfaces, having a cubemap next to each window will also allow the reflection to be made accurately. You will also need them in dark areas as well, if you were to leave one cubemap in a light area and then move into a dark area with no cubemaps the cubemap in the light would still be applied, so your gun models & textures would look odd as it will be using light shiny effects in a dark area.

In a small, evenly lit room one cubemap in the middle should suffice as it will apply the effect to all surrounding walls, as the rooms get bigger and the light contrasts more you will probably need more to effectively render the cubemaps onto the world and models.

How do I apply them to my map?

Firstly, place an env_cubemap in the desired area and ensure it is 16 units away from all brushes, around head height is preferred so that the snap shots taken are relative to the player.

When opening the map it should look like either of the two screenshots:

news post image news post image

Now you will need to open the console and use the command buildcubemaps. You will it take six shots at each cubemap so allow it to finish and then when it has completed you will need to restart the map for it to be applied correctly. If you do not it will use 6 images from the default skymap and apply those to the models, and this will very odd. As you can see below:

news post image news post image

You will need to run this everytime you do a compile of the map.

Quick Example

In a corridor (shown in previous images) I placed one light source at each end. Then placed a cubemap under each light. In the centre is a dark area, which I left without a cubemap. Upon running the map and buildcubemaps I moved from the light area into the dark. My weapon looked like the below:

news post image

It is still using the nearest cubemap, and this is located in the lit area, so my gun model looks incorrect as I am in pitch-blackness but with a nice shiny bright gun.

The correct thing to do is to also place a cubemap in the dark area as well:

news post image

As you can see it is nice and black, and matching the surrounding area.

Cubemaps take a while to get used to and all I can advise is you experiment with them as much as you can. If your models or textures are lit incorrectly then think through your cubemap placement in relation to the lighting in the level.


View comments ( 53 )

Back to top