env_fog_controller

From Valve Developer Community
Jump to: navigation, search
English 简体中文
Fog controller.png

env_fog_controller is a point entity available in all Source Source games. It determines the properties of aerial fog for the whole map.

Tip.png Tip: In multiplayer games, fog may be changed per-client by sending the player entity (probably best accessed through !activator) a SetFogController input. (Also applies to single player sessions, like in Portal 2)

In Left 4 Dead Left 4 Dead 2, multiple env_fog_controllers may be used in conjunction with fog_volumes to create different fog effects where needed. In addition, an env_fog_controller can be set as the Master fog controller under flags, in cases where a fog_volume is not tied to any specific env_fog_controller, or if no fog_volume is used in a region.

Note.png Note: In some/all multiplayer games, this is a preserved entity.
  • On a new round, it will intentionally not reset itself to its default properties (including position).
    Placementtip.gif Workaround: If this is an issue, 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.

Adding fog to a map can cause/require changes to the lighting for realism. Light is scattered and absorbed as it passes through fog. The denser the fog, the greater the effect:

  • Falloff - (or attenuation) is the rate at which light intensity decreases over distance. Falloff distance decreases as fog gets thicker.
  • Tyndall effects - can be seen when the fog particles reflect light toward the viewer. Halos and light beams become more visible as fog gets thicker.
  • Diffused Lighting - the boundary-line between light and shadow becomes more blurred (diffuse) as fog gets thicker. See Lightmap Scale and shadow_control's "distance" parameter.

Older Source games render fog as a plane a certain distance away from the camera. This method is bad, as rotating the camera will strengthen or weaken the apparent amount of fog in a particular spot, even though the viewer hasn't moved at all. In Left 4 Dead[confirm] onward, this is fixed by implementing a new radial method which is independent from the viewing angle.

Note.png Note: The 3D Skybox fog levels set by the sky_camera parameters should correspond to your env_fog_controller settings.
In code, it is represented by theCFogControllerclass, defined in thefogcontroller.cppfile.

Flags

  • 1: Master - If multiple env_fog_controllers are active, this one will always take priority.

Keyvalues

Fog Enabled (fogenable) <boolean>
Make fog start active.
Fog Start (fogstart) <float>
How far away from the viewer the fog should start.
Fog End (fogend) <float>
How far away from the viewer the fog reaches Fog Max Density.
Fog Max Density (fogmaxdensity) <float>
Maximum density the fog may reach. Expressed as a decimal percent, so for 45% put 0.45.
Far Z Clip Plane (farz) <integer>
Anything beyond this distance in world units will not be rendered. This should be higher than Fog End. If this is used, Fog Max Density should be set to 1 otherwise the void may be visible.
Primary Fog Color (fogcolor) <color255>
Primary Fog Color.
Secondary Fog Color (fogcolor2) <color255>
Secondary Fog Color. If Fog Blend is disabled, this color will never appear.
Fog Blend (fogblend) <boolean>
Enables color blending between Primary Fog Color and Secondary Fog Color. When the viewer looks in the Primary Fog Direction, fog will appear as the Primary color. When looking away from the specified direction, fog appears as the Secondary color. If the camera is not pointed directly at or away from the direction, a blend of the two colors will result. Sunlight with a Yaw of 45 degrees and a Pitch of -45 degrees could be enhanced using a Primary Fog Direction of "-1 -1 1", a Primary Fog Color of "120 110 100" and a Secondary Fog Color of "80 70 60".
Primary Fog Direction (fogdir) <vector>
A vector (given by three space-separated numbers X Y Z) which the viewer camera is checked against to figure out the blend between the primary and secondary fog colors.
Use Angles for Fog Dir (use_angles) <boolean>
Use Pitch Yaw Roll for the Fog Blend direction instead of Primary Fog Direction. There isn't much use for this unless you want the direction to rotate.
Interpolate time (foglerptime) <float>
Fade time for the StartFogTransition input.
HDR Color Scale (HDRColorScale) <float> (in all games since Left 4 Dead)
Multiplier for fog color when in HDR mode.
Zoom Fog Scale (ZoomFogScale) <float> (in all games since Counter-Strike: Global Offensive)
Scalar for fog start and end distances when the player is looking through a gun's scope (e.g. AWP).

DXLevelChoice:

Minimum DX Level (mindxlevel) <choices>
The entity will not exist if the engine is running outside the given range of DirectX Versions. Replaced by SystemLevelChoice from Left 4 Dead Left 4 Dead onwards.
Warning.png Warning: If these are used, the object may break when the user switches their DirectX settings.
Maximum DX Level (maxdxlevel) <choices>

SystemLevelChoice:

Minimum Effect Details Level (mincpulevel) <choices> (in all games since Left 4 Dead)
Maximum Effect Details Level (maxcpulevel) <choices> (in all games since Left 4 Dead)
Don't render for players with Effect Details levels that exceed the minimum or maximum.


Note.png Note: The key's names is because of thecpu_levelcommand; the command Effect Details uses.
Minimum Shader Details Level (mingpulevel) <choices> (in all games since Left 4 Dead)
Maximum Shader Details Level (maxgpulevel) <choices> (in all games since Left 4 Dead)
Don't render for players with Shader Details levels that exceed the minimum or maximum.


Note.png Note: The key's names is because of thegpu_levelcommand; the command Shader Details uses.

Base:
Name (targetname) <string>
The name that other entities use to refer to this entity.
Parent (parentname) <targetname>
Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (parentname [targetname],[attachment])
Tip.png Tip: Entities transition to the next map with their parents
Tip.png Tip: phys_constraintcan be used as a workaround if parenting fails.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Note.png Note: Hammer does not move the entities accordingly only in the editor.
Pitch Yaw Roll (X Y Z) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.png Note: This works on brush entities, although Hammer doesn't show the new angles.
Classname (classname) <string> !FGD
Determines the characteristics of the entity before it spawns.
Tip.png Tip: Changing this on runtime still has use, like making matching an entry in S_PreserveEnts will persist the entity on new rounds!
Flags (spawnflags) <integer> !FGD
Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
Effects (effects) <integer> !FGD
Combination of effect flags to use.
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.
Thinker function (thinkfunction) <string> (in all games since Left 4 Dead 2)
Name of the function within this entity's script that'll be called automatically every 100 milliseconds, or a user-defined interval if the function returns a number. Avoid expensive operations in this function, as it may cause performance problems.
Lag Compensation (LagCompensate) <boolean> (in all games since Left 4 Dead 2) !FGD
Set to Yes to lag compensate this entity. Should be used very sparingly!
Is Automatic-Aim Target (is_autoaim_target) <boolean> (in all games since Counter-Strike: Global Offensive) !FGD
If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.


Inputs

TurnOn
Turns the fog on.
TurnOff
Turns the fog off.
SetStartDist <float>
Sets the Fog Start distance.
SetEndDist <float>
Sets the Fog End distance.
SetColor <color255>
Sets the Primary Fog Color.
SetColorSecondary <color255>
Sets the Secondary Fog Color.
SetFarZ <integer>
Sets the Far Z Clip Plane distance.
SetAngles <angles>
Sets the angles to use for the Primary Fog Direction.
Set2DSkyboxFogFactor <float> (in all games since Left 4 Dead 2)
Set the current amount of fog to blend into the 2D skybox. Expressed as a decimal percent, so for 45% put 0.45. Left 4 Dead 2 only.
SetZoomFogScale <float> (in all games since Counter-Strike: Global Offensive)
Sets the Zoom Fog Scale.
SetColorLerpTo <color255> (in all games since Half-Life 2: Episode One)
Stores a value for Primary Fog Color that is set once the StartFogTransition input fires.
SetColorSecondaryLerpTo <color255> (in all games since Half-Life 2: Episode One)
Stores a value for Secondary Fog Color that is set once the StartFogTransition input fires.
SetStartDistLerpTo <float> (in all games since Half-Life 2: Episode One)
Stores a value for Fog Start that is set once the StartFogTransition input fires.
SetEndDistLerpTo <float> (in all games since Half-Life 2: Episode One)
Stores a value for Fog End that is set once the StartFogTransition input fires.
SetMaxDensityLerpTo <float> (in all games since Left 4 Dead)
Stores a value for Fog Max Density that is set once the StartFogTransition input fires. This one does not have any non-"LerpTo" counterpart.
Set2DSkyboxFogFactorLerpTo <float> (in all games since Left 4 Dead 2)
Set the current amount of fog to blend into the 2D skybox. Expressed as a decimal percent, so for 45% put 0.45. This will only change once the StartFogTransition input fires. Left 4 Dead 2 only.
StartFogTransition  (in all games since Half-Life 2: Episode One)
When fired, the fog fades to any new values sent through the "LerpTo" inputs. Fade time is determined by the Interpolate time keyvalue.
Bug.png Bug: Does not work correctly. The fog will transition to nothing and then abruptly change to the new values at the end of the interpolation time. Seen in Left 4 Dead 2Counter-Strike: Global Offensive.
ActivateAllPlayers  (only in Portal 2: Community Edition)
Turns this fog on for all connected players

Base:
AddContext <string>
Adds to the entity's list of response contexts. Format is <key>:<value>.
AddOutput <string>
Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:
Syntax: 

ClearContext
Removes all contexts from this entity's list.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.
FireUser1 to FireUser4
Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
Kill
Removes this entity and any entities parented to it from the world.
KillHierarchy
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.
RemoveContext <string>
Remove a context from this entity's list. The name should match the key of an existing context.
SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Use  !FGD
Same as a player invoking +use; no effect in most cases.
DispatchResponse <string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; see also List of Client Effects. Replaced by the particle system since Left 4 Dead.
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.png Bug: In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.
Fix: Remove the string argument 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.

Outputs

Base:

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.

See Also