env_fog_controller

From Valve Developer Community
Jump to: navigation, search

env_fog_controller is a point entity available in all Source games.

Entity description

Fog controller.png

It determines the density of aerial fog for the whole map.

The properties of this entity apply to the whole map. Multiple instances of this entity within a map may cause errors.

In Left 4 Dead and 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 fog_controller, or if no fog_volume is used in a region.

In <Half-Life 2> mods/games using Source 2007 and Source 2013 you can create client-side fog changing functionality in a multiplayer game using trigger_multiple. Have at least 2 env_fog_controllers with different fog settings and one checked with the Master flag(which will be the default fog). Use OnStartTouch > !activator > SetFogController > [name of env_fog_controller entity]. The input will appear as red, but it still works. Use OnEndTouch() to change the fog back. Interpolate Time affects the transition of the fog color and fog distance parameters between controllers, however Far Z Clip Plane as well as Fog Max Density change instantaneously(which can appear jarring). Confirmed in Counter-Strike: Source.

Note:The 3D Skybox fog levels set by the sky_camera parameters should correspond to your env_fog_controller settings.
Tip:By adding fog to a level, you can hide a FarZ Clip Plane, and reduce the amount of rendered geometry, improving game performance.
Bug:
The StartFogTransition input does not seem to work correctly in <Counter-Strike: Global Offensive> Counter-Strike: Global Offensive. The fog will transition to nothing and then abruptly change to the target lerp values at the end of the interpolate time.

Adding fog (to represent haze, mist, diffuse smoke or dust) to the atmosphere has important implications for 'realistic' Lighting. 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 Lightbeams 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.

Keyvalues

Enable fog on map load.
Note:The default for this entity is False. In order to actually have fog, you will need to change this.
How far from the viewer the fog should start.
How far from the viewer the scene should be completely fogged.
Fog Max Density [0..1]
Far Z Clip Plane
This setting is used for optimizing your map. Anything beyond this distance (in world units) will not be rendered. It is recommended to keep this number higher then your fogend value and ensure fogmaxdensity is set to 1.
Primary Fog Color.
This will enable blending between fogcolor and fogcolor2, based on the direction the player is looking. If the player's viewpoint is equal to the fogdir vector, the fog will be drawn with fogcolor2 (red); if facing in the opposite direction, the fog will be drawn with fogcolor (blue). If facing perpendicular to the fogblend axis, the fog will be a 50/50 blend of fogcolor and fogcolor2 (purple).
This can be used to approximate the effect of light diffusing through the fog, but since the fogblend effect is applied for the entire rendered scene, it is best to keep the two colors relatively close to make the blending less obvious.
For example, sunlight with a Yaw of 45 degrees and a Pitch of -45 degrees could be enhanced using a fogdir of "-1 -1 1", a fogcolor of "120 110 100" and a fogcolor2 of "80 70 60".
Secondary Fog Color.
Primary Fog Direction
A vector (given by three space-separated numbers X Y Z) which points from the secondary fogcolor2 towards the primary fogcolor.
Use Angles for Fog Dir
Use angles instead of fogdir for the fogblend-axis.


Angles:

Pitch Yaw Roll (Y Z X) <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.
Interpolate time

DXLevelChoice:

Minimum DX Level <choices>
Maximum DX Level <choices>
The entity will not exist if the engine is running outside the given range of DirectX Versions. Don't use this with anything that will break saved games should a player switch dxlevel!
  • Default (no bounding)
  • DX7
  • DX8
  • DX8.1
  • DX9 SM2
  • DX9 SM3

Targetname:

Name <string>
The targetname that other entities refer to this entity by.
Entity Scripts <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 <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.
Note:Try to avoid expensive operations in this function, as it may cause performance problems.

Flags

  • 1 : Master (Has priority if multiple env_fog_controllers exist)

Inputs

Set the fog start distance.
Set the fog end distance.
  • TurnOn
Turn the fog on.
  • TurnOff
Turn the fog off.
Set the primary fog color.
Set the secondary fog color.
Set the far clip plane distance.
Set the angles to use for the secondary fog direction.
Set the primary fog color.
Set the secondary fog color.
  • SetStartDistLerpTo <float>
Set the fog start distance.
  • SetEndDistLerpTo <float>
Set the fog end distance.
  • StartFogTransition
Start fog transition.
Set the active fog controller.
Tip:This input should be used if fog_volume is not a valid entity. You can use this input by creating a trigger_multiple and setting its input to: (OnStartTouch > !activator > SetFogController > *Controller Name*)
Note:This input will also show up as red (invalid) but it will still work. If done correctly the Hammer Check For Problems Dialog should have no errors.

Targetname:

Kill
Removes this entity from the world.
KillHierarchy
Removes this entity and all its children from the world.
AddOutput  <string>
Evaluates a keyvalue/output on this entity. It can be potentially very dangerous, use with care.
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.
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)
Execute a VScript function in the scope of the receiving entity.
Note:This input is missing from some games FGD files.
SetLocalOrigin  <origin> (New with Alien Swarm)
Set this entity's origin in the map.
Note:This input is missing from some games FGD files.
SetLocalAngles  <angles> (New with Alien Swarm)
Set this entity's angles in the map.
Note:This input is missing from some games FGD files.

Outputs

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.


Fog Technique

Source 2007 fog seems to be implemented based on a plane based fog technique versus a more modern radially fog technique. As a result the viewer will be able to see further into the fog along the edges. Furthermore, the fog is rotation dependent. Something that appears under fog at one view may change if the player rotates slightly.

See also