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

Env fade: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Nothing to add I think.)
 
(30 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar}}
|ru=env_fade:ru
{{TabsBar|main=gs|base=env_fade}}
}}
[[File:env_fade.png|left|link=]]
{{CD|CEnvFade|file1=EnvFade.cpp}}
{{This is a|logical entity|name=env_fade}}  


{{base point|env_fade}}
It controls screen fades to or from a solid color.  Add '''Duration''' and '''Hold Time''' together for the total time this entity will be in effect.


==Entity description==
{{bug|Doesn't work in {{portal|4}} if player's health is below 100 due to the red screen.{{confirm|Is it in {{portal2|4}} as well ?}}|hidetested={{portal}}}}
[[File:env_fade.png|left|link=]]
<br>
It controls screen fades. Screen fades are used to blend regular game imagery to or from a solid color.  Add '''duration''' and '''holdtime''' together for the total time this entity will be in effect.
<br>
The modulate flag on <code>env_fade</code> uses a different kind of blending to achieve the fade. The normal fade does a straight weighted blend between the screen and the fading color (i.e. the fade color becomes a more/less opaque overlay over the scene). Modulate actually attenuates the screen colors in RGB with the fade color. So you could, for example, remove all of the red and blue from a scene with modulate and be left with a green overlay - well, sort of night vision anyway. The fade color for that would be pure green with modulate.{{clr}}
<br>
{{Note|This effect can also be achieved by using the console commands <code>fadeout</code> and <code>fadein</code>. The default transition time is 2 seconds. You can supply other parameters in curly brackets like <code>fadeout {time r g b}</code>.}}
__TOC__
== Keyvalues ==
== Keyvalues ==
{{KV|Duration (seconds)|string|The time that it will take to fade the screen in or out.}}
{{KV|Hold Fade (seconds)|string|The time to hold the faded in/out state.}}
{{KV|Fade Alpha|integer|Alpha of the fade, where 0 {{=}} fully transparent and 255 {{=}} fully opaque.}}
{{KV|Fade Color (R G B)|color255|Fade color.}}
{{KV|Reverse Fade Duration (seconds)|float|The duration of the reverse fade.|since=P2}}
{{KV Targetname}}
{{KV Targetname}}
{{KV|Duration (seconds) |intn=duration|string|The time that it will take to fade the screen in or out.}}
{{KV|Hold Fade (seconds) |intn=holdtime|string|The time to hold the faded in/out state.}}
{{KV|Fade Alpha |intn=renderamt|integer|Alpha of the fade, where 0 {{=}} fully transparent and 255 {{=}} fully opaque.}}
{{KV|Fade Color (R G B) |intn=rendercolor|color255|Fade color.}}
{{KV|Reverse Fade Duration (seconds) |intn=ReverseFadeDuration|float|The duration of the reverse fade.|since=P2}}


== Flags ==  
== Flags ==  
[[File:Env fade flag 4.jpg|thumb|150px|right|The Flags menu will show this for Flag 4 (Turn off SmartEdit and type spawnflags 4).]]
{{fl|1|Fade From|Screen fades ''from'' the specified color instead of ''to'' it.}}
* 1 : Fade From
{{fl|2|Modulate|Uses attenuation blending to achieve the fade. The normal fade does a straight weighted blend between the screen and the fading color. Modulate actually attenuates the RGB channels. For example, a color of <code>0 255 0</code> would mute the red and blue channels and create a green nightvision-type effect.}}
:Essentially a "fade in," where the screen begins from an opaque color.  
{{fl|4|nofgd=1|Triggering player only| Only affects the screen of the {{ent|!activator}}. <code>!activator</code> is probably the easiest to reach through a [[trigger]] entity. If not checked, the fade will apply to all players.}}
* 2 : Modulate
{{fl|8|Stay Out|Fade remains indefinitely until another fade deactivates it.{{Bug|tested={{tf2}}|Fades applied to {{ent|!activator}} only that are also set to <Code>Stay Out</code> will not be deactivated by a new fade!}}}}
:Use attenuation blending, see [[#Entity Description|Entity Description]].
:{{todo|Test in other games, test if the <code>ScreenFade</code> VScript function is also affected}}
* 4 : Triggering player only  
 
:Only affect activator.
== Inputs ==
:{{note|This flag exists in all Source games, but isn't listed in the FGDs for some, if you don't want to edit the FGD to get it, just add 4 to your current spawnflags.}}  
{{I|Fade|Start the screen fade.}}
* 8 : Stay Out
{{I|FadeReverse|Begin doing the reverse of the current fade.|since=P2}}
:The fade remains indefinitely until another fade deactivates it. This prevents the ondeath-fadeout used in Portal 2.
{{I|Alpha|nofgd=1|Changes '''Fade Alpha'''.}}
{{I|Color|nofgd=1|Changes '''Fade Color'''.}}


==Inputs==
== Outputs ==
{{IO|Fade|Start the screen fade.}}
{{O|OnBeginFade|Fired when the fade has begun.}}
{{IO|FadeReverse|Begin doing the reverse of the current fade.|since=P2}}
{{I Targetname}}


==Outputs==
== ConCommands ==
{{IO|OnBeginFade|Fired when the fade has begun.}}
{{varcom|start}}
{{O Targetname}}
{{varcom|fadein|float int int int int|Time (seconds), Red, Green, Blue, Alpha|Makes the screen black (or the specified color), then fades to the normal view.}}
{{varcom|fadeout|float int int int int|Time (seconds), Red, Green, Blue, Alpha|Fades the screen to black (or the specified color).}}
{{varcom|end}}
{{bug|hidetested=1|Due to a mistake in the code, the alpha value isn't read properly from these commands; if you specify rgb it also has to be specified for the fade to work.}}


[[Category:GUI Entities]]
[[Category:GUI Entities]]

Latest revision as of 05:47, 4 July 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)
Env fade.png
C++ Class hierarchy
CEnvFade
CLogicalEntity
CServerOnlyEntity
CBaseEntity
C++ EnvFade.cpp

env_fade is a logical entity available in all Source Source games.

It controls screen fades to or from a solid color. Add Duration and Hold Time together for the total time this entity will be in effect.

Icon-Bug.pngBug:Doesn't work in Portal Portal if player's health is below 100 due to the red screen.
Confirm:Is it in Portal 2 Portal 2 as well ?




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

Duration (seconds) (duration) <string>
The time that it will take to fade the screen in or out.
Hold Fade (seconds) (holdtime) <string>
The time to hold the faded in/out state.
Fade Alpha (renderamt) <integer>
Alpha of the fade, where 0 = fully transparent and 255 = fully opaque.
Fade Color (R G B) (rendercolor) <color255>
Fade color.
Reverse Fade Duration (seconds) (ReverseFadeDuration) <float> (in all games since Portal 2)
The duration of the reverse fade.

Flags

Fade From : [1]
Screen fades from the specified color instead of to it.
Modulate : [2]
Uses attenuation blending to achieve the fade. The normal fade does a straight weighted blend between the screen and the fading color. Modulate actually attenuates the RGB channels. For example, a color of 0 255 0 would mute the red and blue channels and create a green nightvision-type effect.
Triggering player only : [4] !FGD
Only affects the screen of the !activator. !activator is probably the easiest to reach through a trigger entity. If not checked, the fade will apply to all players.
Stay Out : [8]
Fade remains indefinitely until another fade deactivates it.
Icon-Bug.pngBug:Fades applied to !activator only that are also set to Stay Out will not be deactivated by a new fade!  (tested in: Team Fortress 2)
Todo: Test in other games, test if the ScreenFade VScript function is also affected

Inputs

Fade
Start the screen fade.
FadeReverse  (in all games since Portal 2)
Begin doing the reverse of the current fade.
Alpha  !FGD
Changes Fade Alpha.
Color  !FGD
Changes Fade Color.

Outputs

OnBeginFade
Fired when the fade has begun.

ConCommands

Cvar/Command Parameters or default value Descriptor Effect
fadein float int int int int Time (seconds), Red, Green, Blue, Alpha Makes the screen black (or the specified color), then fades to the normal view.
fadeout float int int int int Time (seconds), Red, Green, Blue, Alpha Fades the screen to black (or the specified color).
Icon-Bug.pngBug:Due to a mistake in the code, the alpha value isn't read properly from these commands; if you specify rgb it also has to be specified for the fade to work.