This entity makes the map's sky (i.e.
sky-textured brushes) emit parallel beams of light in the specified direction, just like real world sunlight/moonlight. The only practical way of lighting outdoor maps.
The game also uses the angles and brightness of this entity to override lighting on models if they can trace a line back towards the sky from the reverse direction of this entity's
angles/angles+pitch. The
tutorial on models and lighting has more information on this.
Attributes
- Name (targetname) - Property used to identify entities.
- Pitch, Yaw, Roll (angles) - Sets the pitch (up/down), yaw (left/right) and roll (bank) respectively.
- Pitch (pitch) - A negative number will give downward pitch (which is normally what you want). Overrides the pitch in angles for both world and model lighting.
- Brightness (_light) - The first three 3-digit numbers are the colour (RGB) and the fourth is brightness/light intensity (e.g.
248 244 237 350
). The brightness of sky lighting is very potent; 2 or 3 is enough to sufficiently light a night map in moonlight.
ZHLT/VHLT-specific keyvalues:
- Ambient Color (_diffuse_light) - Diffused light colour and brightness. This simulates diffuse light usually from blue sky.
- Sun Spread (_spread) - Diffuses the shadow of the sunlight. Values range from 0 to around 10 (0 being sharp shadows).
- Only Dynamic (_fake) - Treat this
light_environment
as an info_sunlight
, causing it to be ignored by HLRAD and only affect dynamic MDL lighting.
Positioning logic
Use either
Pitch or the Pitch in
Pitch Yaw Roll (angles) to shift the Sun (or Moon) vertically (similar to daytime/hours) and Yaw to shift it horizontally (cardinal direction or obliquity.)
Pitch |
Result |
0° |
Sun at the horizon (like in sunrise/sunset) - huge shadows on floor if at least a minimal amount of -pitch were given |
-45° |
Sun between horizon and top (like 9 AM or 3 PM) |
-90° |
Sun directly overhead (like 12 Noon) - only parallel shadows on floor |
Yaw |
Result |
0° |
facing East, or RT side of the skybox |
90° |
facing North, or BK side of the skybox |
180° |
facing West, or LF side of the skybox |
270° |
facing South, or FT side of the skybox |
Notes
- Don't name
light_environment
entities if you don't have to toggle the Sun/Moon on/off.
- Sky brushes must have the "SKY" texture on all faces or they won't reliably emit light (depends on version of HLRAD used).
- The key pitch have the same function as the one in angles, although if you add a value (≠0) to pitch it will overwrite the one in angles. Roll has no effect at all.
- For modern compilers you are not advised to use multiple
light_environment
in a map as they're treated as global. However, you can still use multiple light_environment
for multiple colors. If you which to switch to the old behaviour where each light_environment
would only light up its own outdoor area (i.e. disable the global feature), use the -noskyfix
argument on the RAD compiler.
- This entity doesn't spawn a visible source of light in the sky. Therefore, the Sun or Moon must be part of the skybox as a picture for visual effects.
- The angles/angles+pitch and brightness values of this entity is used in game to override lighting on models. If an entity's origin has direct line of sight to the sky (i.e. a "SKY" face) in the reverse direction of this
light_environment
entity's angles/angles+pitch value, its lighting will be overridden with values calculated from the brightness of this light_environment
entity. Click this link for more information.
- To break line of sight and have entities take lighting from the ground as normal, use a brush textured with black_HIDDEN facing down above the affected area, and SKIP on the other faces.
- To avoid this effect altogether, use
light_spot
with "Is Sky" keyvalue set.
- Having multiple
light_environment
entities confuses the game engine for the above dynamic model lighting. It will only light models with the values of the last light_environment
entity. If you need multiple sky light sources/values, use light_spot
with "Is Sky" keyvalue for everything, and an info_sunlight
for the actual model sky lighting, using an average of all the values.
- The ZHLT/VHLT keyvalues may be missing in your copy of
halflife.fgd
. To add them, open the file in Notepad (or other suitable text editor). Find the line that starts with @PointClass
and contains the text = light_environment
, and between the brackets that follow the above line, add the following lines:
_spread(integer) : "Spread Angle" : 0 : "Spread angle for soft shadows."
_diffuse_light(color255) : "Diffuse Light" : "" : "Diffuse light color."
_fake(choices) : "Only Dynamic" : "" =
[
"" : "No"
1 : "Yes"
]
Balancing Brightness, Ambient Color, and Sun Spread
Here's a very rough guide on how to balance the three values:
- On overcast skies, the ambient light should contribute more light than sunlight.
- The sun's shadow gets more diffused the more overcast the sky is
This all depends on the choice of skybox that you use. Most of them are set on a clear sky which rules out any pressing need to set the sun spread value.
Also worth mentioning the lightmap resolution is the hard limit on how sharp shadows can be.
Related pages
Example maps
pitch
into the pitch component ofangles
. World and model lighting should just work.