WiseLight: Lights

From Valve Developer Community
Revision as of 02:41, 22 June 2018 by Pinsplash (talk | contribs) (Created page with "{{DISPLAYTITLE:WiseLight: Lights}} {{wisemxport|~~~~}} You most likely already know there are multiple types of lights in HL2. In this tutorial I'm going to cover as many of...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This tutorial was originally created by wisemx.

Ported from SDKnuts.net to VDC by: Pinsplash (talk) 02:41, 22 June 2018 (UTC)

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</code> is not included in our discussion of static or dynamic.)

Note:If you compile your map without a 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

  1. Create a prop_static.
  2. Use models/props_c17/light_domelight02_on.mdl.
  3. Place a light entity under it.
  4. Set the brightness to: 124 207 248 400 (Four series of numbers are Red Green and Blue and Brightness).
View in Hammer vs. ingame.
Note:Some models have a skin for the appearance of On and Off. Change the Skin property from the default of 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.

  1. Create a prop_static.
  2. Use models/props_combine/combine_light002a.mdl.
  3. Place a light_spot in front of it.
  4. Place a point_spotlight in the same position. Flag it for Start On and No dynamic Light.
View in Hammer vs. ingame.

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

  1. Static models like the one below where the lamp, cord and base are all part of the same model.
  2. Lamps that are dynamic and can swing, the cable/cord is created with a move_rope entity and at least one keyframe_rope and constraints.
This is a hanging lamp you pass under when you first meet Barney. (While he's still disguised)

These are the entities Valve used to create that light:

  1. prop_static with the model models/props_wasteland/prison_lamp001b.mdl.
  2. light_spot Brightness 254 216 146 400.
  3. point_spotlight flagged No Dynamic Light, a Length of 256, Width of 64 and color 254 216 146.
  4. 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_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.

See Also