Difference between revisions of "Env sun"

From Valve Developer Community
Jump to: navigation, search
Line 1: Line 1:
{{base point|env_sun}}  
{{base point|env_sun}}  

Revision as of 17:09, 2 December 2017

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 (targetname) <string>
The targetname that other entities refer to this entity by.
Entity Scripts (vscripts) <scriptlist> (in all games since <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 (thinkfunction) <string> (in all games since <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 from the world.
Removes this entity and its children from the world.
Note:Entities already remove orphaned children upon being removed, but this input removes all children on the same frame, being marginally faster than Kill.
AddOutput <string>
Adds a keyvalue/output to this entity. It can be potentially very dangerous, use with care.
KV Format: <key> <value>
I/O 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 depending on the entity. Can also be invoked by firing an output that does not specify an input.
RunScriptFile <script> (in all games since <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> (in all games since <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> (in all games since <Left 4 Dead 2>) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin <coordinates> (in all games since <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.
SetLocalAngles <angles> (in all games since <Alien Swarm>) !FGD
Set this entity's angles.



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  (only in <Left 4 Dead><Left 4 Dead 2>)
This output fires when the entity is killed and removed from the game.

Tutorials about Env_Sun (Russian)

Lessons created by Project-S

description of env_sun (Видимое солнце)


Env_Sun + Light_Environment (ещё одно видео о солнце)