Env fog controller/en

From Valve Developer Community
Jump to: navigation, search
env_fog_controller
Fog controller.png
TypePoint entity
EngineSource Source
AvailabilityIn all games
 
class hierarchy
CFogController defined in fogcontroller.cpp
CBaseEntity

This entity determines the properties of aerial fog for the whole map.

Tip.pngTip: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 series, 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.pngNote:This is a preserved entity in Counter-Strike: SourceHalf-Life 2: DeathmatchDay of Defeat: SourcePortalTeam Fortress 2Left 4 DeadLeft 4 Dead 2Portal 2Counter-Strike: Global Offensive.
  • On a new round, its properties including its position 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.


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 (all Source 2004-Source 2013 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.pngNote:The 3D Skybox fog levels set by the sky_camera parameters should correspond to your env_fog_controller settings.

Flags

  •  [1] : Master
       If multiple env_fog_controllers are active, this one will always take priority. There must be at least one fog_volume in the map to work!

Keyvalues

Fog Enable (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).

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.
SetMaxDensity <float> !FGD
Sets the Fog Max Density.
Note.pngNote:This input may not be in most FGD files but works in Counter-Strike: Source. Does it work in others games ? [confirm]
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.
Note.pngNote:This one does not have any non-"LerpTo" counterpart. [confirm] Is this still true ? See SetMaxDensity input.
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.
Icon-Bug.pngBug:Does not work correctly in some games. The fog will transition to nothing and then abruptly change to the new values at the end of the interpolation time in Left 4 Dead 2Counter-Strike: Global Offensive.
Blank image.pngTodo: What other games have this bug? (Works perfectly in Half-Life 2: Episode Two for example)
ActivateAllPlayers  (only in Portal 2: Community Edition)
Turns this fog on for all connected players

See also