This tutorial was originally created by wisemx.
You most likely already know there are multiple types of lights in HL2. In this tutorial I'm going to cover as many of those as I can and we'll go through the steps of building at least a few different types.
In HL2 "light" may refer to the model that appears to be giving off light (or not) and it refers to the light sources such as
point_spotlight. Additionally light is controlled with a
light_environment and you can give the appearance of a sun with the
Static or Dynamic?
When you design your maps the decision of using static or dynamic lights will no doubt be a question. The
light entity is the most simple to use and the least taxing on performance. (code>light_environment</code> is not included in our discussion of static or dynamic.)
light_environmentand no direct lights your map will be fullbright.
Static lights cannot move, but dynamic ones can. This is something to keep in mind when you use the
point_spotlight. It's a great light for many of your needs but it doesn't always need to provide dynamic light and you can save on resources by checking the flag No Dynamic Light.
Let's look at a few specific needs.
Typical Ceiling Light
- Create a
- Place a
lightentity under it.
- Set the brightness to: 124 207 248 400 (Four series of numbers are Red Green and Blue and Brightness).
1and see if the light changes.
The next example is from the Valve SDK file
sdk_d1_trainstation_01. This illustrates the use of a model with light entites
- Create a
- Place a
light_spotin front of it.
- Place a
point_spotlightin the same position. Flag it for Start On and No dynamic Light.
In the Valve SDK source files (
\sourcesdk_content\hl2\mapsrc) you have two huge examples that contain a wide variety of lights and light sources, which are not always direct light. See WiseVol.
The Valve files are:
sdk_d1_trainstation_01.vmf(First map in Half-Life 2, everything from the Gman intro to the area after meeting Barney.)
sdk_d1_trainstation_05.vmf(Main part of A Red Letter Day, with Kleiner's lab and the teleporter incident.)
We just created a static light with multiple direct light sources in the example above from
sdk_d1_trainstation_01.vmf, now let's create another but this will appear to be hanging.
There are two types of hanging lights in HL2
- Static models like the one below where the lamp, cord and base are all part of the same model.
- Lamps that are dynamic and can swing, the cable/cord is created with a
move_ropeentity and at least one
These are the entities Valve used to create that light:
prop_staticwith the model
light_spotBrightness 254 216 146 400.
point_spotlightflagged No Dynamic Light, a Length of 256, Width of 64 and color 254 216 146.
lightentity with a Brightness of 254 216 146 2.
Do you see how the light effect is different with those last two examples? Notice how Valve used multiple direct lights to create the effect?
It's interesting to note that Valve used 4
light_dynamic entities elsewhere in this same map for the opening scene where you are being talked to by Gman. They are pointed at his head and are turned on and off by
logic_relays. Notice the effect next time you play HL2.
One thing you should always consider to save on performance when you use any
point_spotlights is to test them with the flag No Dynamic Light checked. In this example the only effect you would notice is the direct halo from the
point_spotlight on the ground but you would improve performance.