Env sun: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(-added class hierarchy, cleanup)
Line 3: Line 3:
[[File:Sun_ldrhdr.jpg|thumbnail|Example of env_sun working with sky_day01_04_hdr skybox. (LDR (left) HDR (right))]]
[[File:Sun_ldrhdr.jpg|thumbnail|Example of env_sun working with sky_day01_04_hdr skybox. (LDR (left) HDR (right))]]
[[File:Env_sun(gmod).png|left]]
[[File:Env_sun(gmod).png|left]]
 
{{CD|CSun|file1=sun.cpp}}
{{entity|env_sun|type=e0}} It places a glowing sun effect [[skybox]] where it does not parallax, giving the impression that it is nearly infinitely far away. The entity does not contribute any actual lighting; it is merely a visual representation of the Sun. Use {{ent|light_environment}} to provide actual sunlight for your map.
{{entity|env_sun|type=e0}} It places a glowing sun effect [[skybox]] where it does not parallax, giving the impression that it is nearly infinitely far away. The entity does not contribute any actual lighting; it is merely a visual representation of the Sun. Use {{ent|light_environment}} to provide actual sunlight for your map.


Line 11: Line 11:
{{bug|Centering the player's view perfectly on the sun will render it invisible, even if there is no crosshair. This has been fixed since {{l4d}}.}}
{{bug|Centering the player's view perfectly on the sun will render it invisible, even if there is no crosshair. This has been fixed since {{l4d}}.}}
: {{fix|A fix for this bug can be found here: [[General_SDK_Snippets_%26_Fixes#Fix_env_sun_sprite_disappearing_in_sky_when_you_look_at_it]]}}
: {{fix|A fix for this bug can be found here: [[General_SDK_Snippets_%26_Fixes#Fix_env_sun_sprite_disappearing_in_sky_when_you_look_at_it]]}}
{{code class|CSun|sun.cpp}}


==Keyvalues==
==Keyvalues==
{{KV|UseAngles (use_angles)|boolean|The old way to orient <code>env_sun</code> is to use ''Viewer entity''. The new way is by '''Pitch Yaw Roll'''. If you want to use the new way, set this property to YES.}}
{{KV Targetname}}
{{KV|Viewer entity (target)|target_destination|Name of an entity (probably {{ent|sky_camera}}) used to determine where the sun is in the skybox. The resulting sun sprite will be positioned based on a line starting from the '''Viewer entity''' towards the <code>env_sun</code>.}}
{{KV|UseAngles|intn=use_angles|boolean|The old way to orient <code>env_sun</code> is to use ''Viewer entity''. The new way is by '''Pitch Yaw Roll'''. If you want to use the new way, set this property to YES.}}
{{KV|Pitch (pitch)|float|This value sets the pitch position of the sun. It overrides the '''Pitch''' in '''Pitch Yaw Roll''', even if left at 0, so it needs to be specified. This '''Pitch''' is reverse of the normal, so 90 is straight up, while -90 is straight down.}}
{{KV|Viewer entity|intn=target|target_destination|Name of an entity (probably {{ent|sky_camera}}) used to determine where the sun is in the skybox. The resulting sun sprite will be positioned based on a line starting from the '''Viewer entity''' towards the <code>env_sun</code>.}}
{{KV|Yaw (angle)|nofgd=1|float|Override for '''Yaw''' in '''Pitch Yaw Roll''', similar to '''Pitch'''.}}
{{KV|Pitch|intn=pitch|float|This value sets the pitch position of the sun. It overrides the '''Pitch''' in '''Pitch Yaw Roll''', even if left at 0, so it needs to be specified. This '''Pitch''' is reverse of the normal, so 90 is straight up, while -90 is straight down.}}
{{KV|Sun Color (R G B) (rendercolor)|color255|Color of the sun. 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.}}
{{KV|Yaw|intn=angle|nofgd=1|float|Override for '''Yaw''' in '''Pitch Yaw Roll''', similar to '''Pitch'''.}}
{{KV|Overlay Color (R G B) (overlaycolor)|color255|Color of the sun overlay.}}
{{KV|Sun Color (R G B)|intn=rendercolor|color255|Color of the sun. 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.}}
{{KV|Size (size)|integer|Size of the sun.}}
{{KV|Overlay Color (R G B)|intn=overlaycolor|color255|Color of the sun overlay.}}
{{KV|Overlay Size (overlaysize)|integer|A value of -1 means the overlay will act the old way{{clarify}}.}}
{{KV|Size|intn=size|integer|Size of the sun.}}
{{KV|Material Name (material)|sprite|Material of the inner glow.}}
{{KV|Overlay Size|intn=overlaysize|integer|A value of -1 means the overlay will act the old way{{clarify}}.}}
{{KV|Overlay Material Name (overlaymaterial)|sprite|Material of the overlay glow.}}
{{KV|Material Name|intn=material|sprite|Material of the inner glow.}}
{{KV|HDR color scale (HDRColorScale)|float|Color multiplier when in [[HDR]] mode.}}
{{KV|Overlay Material Name|intn=overlaymaterial|sprite|Material of the overlay glow.}}
{{KV|Glow Distance Scale (glowDistanceScale)|since=CSGO|float|Scales the distance used to test for sun glow occlusion. If the player can see any part of the skybox within this range, the overlay will render.}}
{{KV|HDR color scale|intn=HDRColorScale|float|Color multiplier when in [[HDR]] mode.}}
{{KV BaseEntity}}
{{KV|Glow Distance Scale|intn=glowDistanceScale|since=CSGO|float|Scales the distance used to test for sun glow occlusion. If the player can see any part of the skybox within this range, the overlay will render.}}


==Inputs==
==Inputs==
Line 32: Line 31:
{{IO|TurnOff|Disable sun rendering.}}
{{IO|TurnOff|Disable sun rendering.}}
{{IO|SetColor|param=color255|Sets '''Sun Color'''.}}
{{IO|SetColor|param=color255|Sets '''Sun Color'''.}}
{{I BaseEntity}}
==Outputs==
{{O BaseEntity|l4d=1}}

Revision as of 06:07, 11 August 2023

English (en)Русский (ru)中文 (zh)Translate (Translate)
Example of env_sun working with sky_day01_04_hdr skybox. (LDR (left) HDR (right))
Env sun(gmod).png
C++ Class hierarchy
CSun
CBaseEntity
C++ sun.cpp

Template:Entity It places a glowing sun effect skybox where it does not parallax, giving the impression that it is nearly infinitely far away. The 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.

Icon-Important.pngImportant:This is a preserved entity in Counter-Strike: SourceHalf-Life 2: DeathmatchDay of Defeat: SourceTeam Fortress 2Left 4 DeadLeft 4 Dead 2Portal 2Counter-Strike: Global Offensive.
If the game has round restart mechanics this entity may not behave as expected:
More info
  • On a new round entities with this classname will intentionally not reset. You can use logic_auto to emulate resetting it.
  • Killing it removes it forever, as it is not respawned on a new round.
  • It cannot be spawned with a point_template.
  • Parenting this with non-preserved entities may have undesirable effects.

When the sun is looked at directly, it will transition to the properties of an "overlay".

Icon-Bug.pngBug:Centering the player's view perfectly on the sun will render it invisible, even if there is no crosshair. This has been fixed since Left 4 Dead.  [todo tested in ?]

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

UseAngles (use_angles) <boolean>
The old way to orient env_sun is to use Viewer entity. The new way is by Pitch Yaw Roll. If you want to use the new way, set this property to YES.
Viewer entity (target) <targetname>
Name of an entity (probably sky_camera) used to determine where the sun is in the skybox. The resulting sun sprite will be positioned based on a line starting from the Viewer entity towards the env_sun.
Pitch (pitch) <float>
This value sets the pitch position of the sun. It overrides the Pitch in Pitch Yaw Roll, even if left at 0, so it needs to be specified. This Pitch is reverse of the normal, so 90 is straight up, while -90 is straight down.
Yaw (angle) <float> !FGD
Override for Yaw in Pitch Yaw Roll, similar to Pitch.
Sun Color (R G B) (rendercolor) <color255>
Color of the sun. 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.
Overlay Color (R G B) (overlaycolor) <color255>
Color of the sun overlay.
Size (size) <integer>
Size of the sun.
Overlay Size (overlaysize) <integer>
A value of -1 means the overlay will act the old way[Clarify].
Material Name (material) <sprite>
Material of the inner glow.
Overlay Material Name (overlaymaterial) <sprite>
Material of the overlay glow.
HDR color scale (HDRColorScale) <float>
Color multiplier when in HDR mode.
Glow Distance Scale (glowDistanceScale) <float> (in all games since Counter-Strike: Global Offensive)
Scales the distance used to test for sun glow occlusion. If the player can see any part of the skybox within this range, the overlay will render.

Inputs

TurnOn
Enable sun rendering.
TurnOff
Disable sun rendering.
SetColor <color255RedirectInput/color32>
Sets Sun Color.