env_sun is a point entity available in all Source games.
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
- 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.
- 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.
- 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)
- Color of the sun.
- Overlay Color (R G B)
- A value of 0 0 0 will act the old way. To do: Explain what the old way is.
- Size of the sun.
- Overlay Size
- A value of -1 means the overlay will act the old way.
- Material Name
- Material of the inner glow.
- Overlay Material Name
- Material of the overlay glow.
- HDR color scale.
- float value to multiply sprite color by when running in HDR mode.
- 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.
- 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 this entity and any entities parented to it are killed on the same frame, being marginally faster than
- Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
<output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
- Fire the
OnUseroutputs; see User Inputs and Outputs.
- 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.
<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.
<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 , 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.
<string>(New with Left 4 Dead 2) !FGD
- Execute a VScript function in the scope of the receiving entity.
<coordinates>(New with Alien Swarm) !FGD
- Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
<angles>(New with Alien Swarm) !FGD
- Set this entity's angles.
- These Outputs each fire in response to the firing of the like-numbered
FireUser4Input; see User Inputs and Outputs.
OnKilled(Only in the Left 4 Dead series)
- This Output fires when the entity is killed and removed from the game.
Tutorials about Env_Sun (Russian)
Lessons created by Project-S