env_fog_controller

From Valve Developer Community
Jump to: navigation, search
Fog controller.png
env_fog_controller is a point entity available in all Source games. It determines the properties of aerial fog for the whole map.
Tip:In multiplayer games, fog may be changed per-client by sending the player entity (probably best accessed through !activator) a SetFogController input.

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.

Warning: In some/all multiplayer games, this entity will intentionally not reset itself to its default properties (including position) when a new round begins. If this is an issue, use inputs to emulate resetting it.

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: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 class CFogController, defined in fogcontroller.cpp.

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> (New with Left 4 Dead)
Multiplier for fog color when in HDR mode.
Zoom Fog Scale (ZoomFogScale) <float> (New with 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>
Maximum DX Level (maxdxlevel)<choices>
The entity will not exist if the engine is running outside the given range of DirectX Versions. Only used by Orange Box and 2013 SDK games.
Warning: If these are used, the object may break when the user switches their DirectX settings.
  • Default (no bounding)
  • DX7
  • DX8
  • DX8.1
  • DX9 SM2
  • DX9 SM3

SystemLevelChoice:

Minimum CPU Level (mincpulevel) <choices> (New with Left 4 Dead)
A user with a CPU level lower than this will not see this object rendered in-game. It's unclear how the CPU level is decided, but most systems are classified as "high".
Maximum CPU Level (maxcpulevel) <choices> (New with Left 4 Dead)
  • 0: Default
  • 1: Low
  • 2: Medium
  • 3: High
Minimum GPU Level (mingpulevel) <choices> (New with Left 4 Dead)
Maximum GPU Level (maxgpulevel) <choices> (New with Left 4 Dead)
  • 0: Default
  • 1: Very low
  • 2: Low
  • 3: Medium
  • 4: High

Base:

Classname (classname) <string>
The classname defines the type of entity. Classnames can be changed using AddOutput, which will influence how the engine deals with the entity in certain circumstances.
Name (targetname) <string>
The name that other entities refer to this entity by.
Global Entity Name (globalname) <string>
Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.
Parent (parentname) <targetname>
Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma. Every entity can be parented, even point entities. Entities which are parented will be forced to transition to the next map, such as from a trigger_transition. Some entities which aren't intended to be parented may not function correctly. phys_constraint can be used as a workaround to parenting.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
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:This works on brush entities, although Hammer doesn't show the new angles.
Flags (spawnflags) <integer>
Toggles features of an entity, its specific number is determined by the combination of flags added.
Response Contexts (ResponseContext) <string>
Pre-defined response system contexts for this entity. Format is key:value,key:value,.... Contexts may be filtered.
Effects (effects) <integer> !FGD
Combination of effect flags to use.
Local Time (ltime) <float> !FGD
The local time of the entity, independent of the global clock. Used mainly for physics calculations.
Next Think (nextthink) <float> !FGD
Amount of time before the entity thinks again.
Hammer ID (hammerid) <integer> !FGD
The entity's Hammer ID. Mainly used by plugins and debugging commands, such as ent_keyvalue. Can be manually assigned with the "hammerid" or "id" keyvalue. Entities spawned at run-time are not assigned any Hammer ID.
Disable for Xbox 360 (disableX360) <boolean> (New with Left 4 Dead 2) !FGD
If Yes, disables this entity on the Xbox 360 version of Source.
Entity Scripts (vscripts) <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 (thinkfunction) <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. Try to avoid expensive operations in this function, as it may cause performance problems.
Lag Compensation (LagCompensate) <boolean> (New with 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> (New with 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> (New with 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> (New with Counter-Strike: Global Offensive)
Sets the Zoom Fog Scale.
SetColorLerpTo  <color255> (New with Source 2006)
Stores a value for Primary Fog Color that is set once the StartFogTransition input fires.
SetColorSecondaryLerpTo  <color255> (New with Source 2006)
Stores a value for Secondary Fog Color that is set once the StartFogTransition input fires.
SetStartDistLerpTo  <float> (New with Source 2006)
Stores a value for Fog Start that is set once the StartFogTransition input fires.
SetEndDistLerpTo  <float> (New with Source 2006)
Stores a value for Fog End that is set once the StartFogTransition input fires.
SetMaxDensityLerpTo  <float> (New with 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> (New with 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  (New with Source 2006)
When fired, the fog fades to any new values sent through the "LerpTo" inputs. Fade time is determined by the Interpolate time keyvalue.
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 2><Counter-Strike: Global Offensive>.

Base:

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.
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.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.
AddOutput  <string>
Evaluates a keyvalue/output on this entity.
Format: <key> <value>
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. Can also be invoked by creating an output that does not specify an input.
This input is not included in Valve's FGDs.
DispatchEffect  <string> !FGD
Dispatches a special effect from the entity's origin. Replaced entirely by the particle system since Left 4 Dead.
DispatchResponse  <string> !FGD
Dispatches a response to the entity. See Response and Concept.
AddContext  <string>
Adds to the entity's list of response contexts. Format is <key>:<value>.
RemoveContext  <string>
Remove a context from this entity's list. The name should match the key of an existing context.
ClearContext  <string>
Removes all contexts from this entity's list.
RunScriptFile  <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.
RunScriptCode  <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 <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> (New with Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin  <coordinates> (New with Portal 2) !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> (New with Portal 2) !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  (New with Left 4 Dead)
This output fires when the entity is killed and removed from the game. <Left 4 Dead> only.

See Also