WiseLight: Lights
This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.
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 light
, light_dynamic
, light_spot
and point_spotlight
. Additionally light is controlled with a light_environment
and you can give the appearance of a sun with the env_sun
.
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 is not included in our discussion of static or dynamic.)
light_environment
and 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
prop_static
. - Use
models/props_c17/light_domelight02_on.mdl
. - Place a
light
entity under it. - Set the brightness to: 124 207 248 400 (Four series of numbers are Red Green and Blue and Brightness).
0
to 1
and see if the light changes.Spot Light
The next example is from the Valve SDK file sdk_d1_trainstation_01
. This illustrates the use of a model with light entites light_spot
and point_spotlight
.
- Create a
prop_static
. - Use
models/props_combine/combine_light002a.mdl
. - Place a
light_spot
in front of it. - Place a
point_spotlight
in the same position. Flag it for Start On and No dynamic Light.
Hanging Lights
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_rope
entity and at least onekeyframe_rope
and constraints.
These are the entities Valve used to create that light:
prop_static
with the modelmodels/props_wasteland/prison_lamp001b.mdl
.light_spot
Brightness 254 216 146 400.point_spotlight
flagged No Dynamic Light, a Length of 256, Width of 64 and color 254 216 146.light
entity 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_relay
s. Notice the effect next time you play HL2.
One thing you should always consider to save on performance when you use any point_spotlight
s 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.