This article's documentation is for anything that uses the Source engine. Click here for more information.

light_environment

From Valve Developer Community
Jump to: navigation, search
English (en)Русский (ru)Türkçe (tr)中文 (zh)Translate (Translate)
Class hierarchy
CEnvLight
CLight
CPointEntity
CBaseEntity
lights.cpp
Light environment.png

light_environment is a point entity available in all Source Source games.

It casts parallel directional lighting from the toolsskybox texture to approximate the light cast from the Sun or Moon.

Tip.pngTip:Use with env_sun and shadow_control/env_cascade_light.
Note.pngNote:
  • The light_environment still inherits most properties from the basic light entity. This means that the light_environment can be named and/or lightstyled (by adding the targetname keyvalue with SmartEdit off) and even disabled/enabled, although it will look very crude as vanilla VRAD does not calculate bounced lighting for named lights. Furthermore, there is a bug in games other than Counter-Strike: Global Offensive Counter-Strike: Global Offensive where light from a named light_environment on static props will break when the light is changed. Additionally, only the first light_environment is used, so named light_environments can't be used to switch between environment lighting.
  • The properties of this entity apply to the whole map. Using more than 1 entity for areas with a skybox toolsskybox texture does not create errors provided If all instances of light_environment have identical info. It is pointless to have more than 1 though.
  • For more than one light coming from sky brushes, as well as for toggled or lightstyled sunlight, use light_directional instead (light will still come from all off the brushes).

Skybox lighting

Toolsskybox.png

Skyboxes are the main source of light for most maps, and as such are one of the most important parts of making a map.

Overview

Skybox lighting enters the map through every toolsskybox-textured brush, representing direct sun/moonlight and diffuse skylight. Its basic properties are controlled by three entities used in combination (four in some games):

  • light_environment defines the direction, color and intensity of the direct sunlight, and the color and intensity of the diffuse skylight.
  • shadow_control defines the color, direction, and attenuation distance of the dynamic shadows that are created by light_environment. Dynamic shadows will be buggy and unconfigurable without this entity.
  • env_sun places a glowing sprite in the skybox to represent the Sun's apparent position in the sky. It has no effect on lighting aside from this.
  • env_cascade_light casts harsh, real-time shadows onto the map, usually copying settings from the light_environment entity. (in all games since Counter-Strike: Global Offensive)(also in Black Mesa)
  • light_deferred_global casts dynamic shadows and lighting similar to env_cascade_light (only in Alien Swarm Deferred)(also in Lambda Wars)

Explanation

To make sense of it all, just make sure you have only one of each of these entities in your map, and that the Pitch and Yaw <angles> are set the same for all three of them. (Pitch is equivalent to the Sun's angle of elevation from the ground, and Yaw is its compass bearing.)

These lighting settings—direction, color, brightness, etc.—are fairly specific to the actual image used for the 2D skybox. The List of skies article suggests some settings for official game skyboxes. The worldspawn entity defines which skybox to use. Also note that fog will look wrong if env_fog_controller's settings don't correspond to the particular skybox in use.

Note.pngNote:Pitch can be overridden for light_environment and env_sun, but not shadow_control. The Pitch override also cannot be switched off and its rotation is measured counter-clockwise from the horizontal (so straight down is -90°) whereas the <angles> Pitch's rotation is clockwise (so straight down is +90°). The workaround for this is to make sure your Pitch override merely repeats the <angles> value; for example, if your shadow_control, light_environment and env_sun <angles> are "45 -60 0", set the Pitch override to "-45".

Keyvalues

Pitch Yaw Roll (Y Z X) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Pitch (pitch) <angle>
Overrides the pitch value in Angles, even if omitted, so it needs to be specified. Contrary to Angles, the rotation of this pitch is measured counter-clockwise from the horizontal, so that 90 is straight up, while -90 is straight down. (It's simply the negative of a normal pitch value.)
Brightness (_light) <color255 + int>
Color and brightness of the direct sunlight.
Ambient (_ambient) <color255 + int>
Color and brightness of the diffuse skylight.
Brightness, being represented by red, Ambient by green.
Note how the parts in direct sunlight have the red sunlight and green ambient light additively brighten the map, while the parts outside the direct sunlight are fully green.
BrightnessHDR (_lightHDR) <color255 + int>
Override for Brightness when compiling HDR lighting. Defaults to -1 -1 -1 1, which means "same as LDR".
BrightnessScaleHDR (_lightscaleHDR) <float>
Amount to scale the direct light by when compiling for HDR.
AmbientHDR (_ambientHDR) <color255 + int>
Override for Ambient when compiling HDR lighting. Defaults to -1 -1 -1 1, which means "same as LDR".
AmbientScaleHDR (_AmbientScaleHDR) <float>
Amount to scale the ambient light by when compiling for HDR.
Different SunSpreadAngle values. The quality of the soft shadows depend on compile options as well. Click if preview is not animated.
SunSpreadAngle (SunSpreadAngle) <float> (in all games since Half-Life 2: Episode Two)
The angular extent of the sun for casting soft shadows. Higher numbers are more diffuse. 3 is a good starting value. Remember: on cloudy days, the shadows will be blurred because the sunlight is being diffused by clouds.
Suggested starting values:
  • 1 - Sunny day; reduces aliasing on low-res lightmaps without increasing prominence of penumbras, and subtly softens high-res lightmaps.
  • 3 - Slightly overcast, but still sunny
  • 5 - Valve's recommended starting value
  • 90 - Hazy day
  • 135 - Cloudy, rainy, and or foggy day
  • 180 - Nighttime
You'll also have to turn down the shadow alpha in your shadow_control entity - try changing the Shadow Color variable to something such as 50 50 50.
Specular Color (specularcolor) <color255> (only in InsurgencyDay of Infamy)
Color of the light that reflects off of certain surfaces. (i.e. water).

Flags

Initially Dark : [1] !FGD

Only works when the light_environment is named, and it must be added with SmartEdit off by putting in a 'spawnflags' key with a value of 1 (Hammer doesn't allow setting non-FGD flags in the flags tab).

External links