From Valve Developer Community
Revision as of 04:03, 26 August 2018 by 404 User Not Found (talk | contribs) (Removing Russian youtube advertising.)

Jump to: navigation, search

env_sun is a point entity available in all Source games.

Entity description

It places a Sun or Moon effect (glow sprite) in the skybox where it does not parallax, giving the impression that it is nearly infinitely far away. The env_sun entity does not contribute any actual lighting; it is merely a visual representation of the Sun. Use light_environment to provide actual sunlight for your map. Use shadow_control for dynamic shadows except in CSGO where Shadow Control is extraneous and may interfere with cascade lighting.

To set up the env_sun: Set the Pitch Yaw Roll. Pitch will be how far up and down the Sun will be in the sky. Yaw is how far left and right it will be. Roll is extraneous and is not necessary to set. An info_player_start can be used to visualize where the Sun will be; you can set its angles and imagine a line coming out its back pointing to the sky and that is where the Sun will be in game. Then copy and paste its pitch, yaw and roll into the env_sun (remember to delete the info_player_start after using it like this). Set Use Angles to Yes (This means it will use the Pitch Yaw Roll settings). Set Pitch as a negative number of the actual pitch (This number overrides the pitch in the Pitch Yaw Roll key value). Sun Color is the base color of the sun. Overlay Color is the color of the transition material. The overlay provides a nice transition to the full glare of the sun and smooths the popping in and out the Sun does when it comes into view. Size is the size of the sun. Set this smaller than the Overlay Size; 16 is a tiny sun and 256 is a huge sun. Set Overlay Size larger than sun.

The properties of this entity apply to the whole map. Multiple instances of this entity within a map may cause errors.

  • You can also send inputs to the env_sun entity by directing them to "env_sun" instead of using a target name.
  • The effect is additive with the sky: a pure yellow sun with a bright blue sky will appear white in-game; change the color to account for this.


Viewer entity <targetname>
Name of an entity used to determine where the sun is in the skybox. The sun should be lined up on a line from this entity to the env_sun entity.
UseAngles <boolean>
The old way to orient env_sun is to point it at a target. The new way is to specify the angles. If you use the new way, set this property to YES.
Pitch <integer>
This value sets the pitch position of the sun. It overrides the pitch value in the angles keyvalue, even if left at 0, so it needs to be specified. Contrary to the angles keyvalue, 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.)
Sun Color (R G B) <color255>
Color of the sun.
Overlay Color (R G B) <color255>
A value of 0 0 0 will act the old way. To do: Explain what the old way is.
Size <integer>
Size of the sun.
Overlay Size <integer>
A value of -1 means the overlay will act the old way.
Material Name <sprite>
Material of the inner glow.
Overlay Material Name <sprite>
Material of the overlay glow.
HDR color scale. <float>
float value to multiply sprite color by when running in HDR mode.


Name <string>
The targetname that other entities refer to this entity by.
Entity Scripts <scriptlist> (New with Left 4 Dead 2)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Script think function <string> (New with Left 4 Dead 2)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.
Note:Try to avoid expensive operations in this function, as it may cause performance problems.


Enable sun rendering.
Disable sun rendering.
SetColor  <color255>
Change the sun's color. Format: <Red 0-255> <Green 0-255> <Blue 0-255>


Removes this entity and any entities parented to it from the world.
Functions the same as Kill, although entities with a large number of children are killed marginally faster.
AddOutput  <string>
Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
Format: <key> <value>
Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything. Can also be invoked by creating an output that does not specify an input.
This input is not included in Valve's FGDs.
RunScriptFile  <script> (New with Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode  <string> (New with Left 4 Dead 2)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug:  In <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed manually with a text editor.
CallScriptFunction  <string> (New with Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
Note:This input is missing from some games FGD files.
SetLocalOrigin  <origin> (New with Alien Swarm) !FGD
Set this entity's origin in the map.
Note:This input is missing from some games FGD files.
SetLocalAngles  <angles> (New with Alien Swarm) !FGD
Set this entity's angles in the map.
Note:This input is missing from some games FGD files.



OnUser1 to OnUser4
These Outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (New with Left 4 Dead)
This Output fires when the entity is killed and removed from the game.