Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Changes the fog smoothly over a given time period.

A fog density of 0 means no fog at all, allowing maximum view distance (which might be limited by the respective setVideoSetting). A density of 1 is maximum fog, which gives a visibility of about 125m at ground level.

V2.05+: Instead of having the same density at every altitude, it is now possible for fog to realistically become thinner with higher altitudes. The base altitude (where the fog has the exact, specified density) and its decay rate (how quickly it gets thinner) can be defined via the alternative command syntax. The decay rate is a logarithmic number, and uses the following formula:
ln(0.5)/D = A, where D is the decay rate as specified in the setFog command, and A is the altitude step that results in a doubling of the possible view distance. For example, a D value of 0.007 results in ln(0.5)/.007 => ~100, which means that for every altitude increase of 100m, the view distance is doubled. A decay rate of .014 would result a doubled view distance every 50m (ln(0.5)/.014 = ~50). See the following graph for the relations between density, altitude and view distance:

Another graph, showing just the relationship between fog density and view distance (at ground level) is available here:

Note: Be aware that these shown distances only apply, if viewing at a straight level (for example, the viewer is at 100m and the object viewed is at 100m). Once the altitudes between the viewer and the viewed object are different, then the density at the lowest point (densest fog) must be used, in order to estimate the possible view distance.


Syntax:time setFog density
  • time: Number - Transition time (in seconds). If 0, then the change is immediate.
  • density: Number - Fog intensity (0-1).
Return Value:Nothing

Alternative Syntax

Syntax:time setFog [density,decay,altitude] (V2.05+)
  • time: Number - Transition time (in seconds). If 0, then change is immediate.
  • density: Number - Fog intensity (0 - 1) at the specified altitude.
  • decay: Number - How fast fog density changes with altitude (0 - 0.1). At 0, the fog is uniformly dense, no matter the altitude. At 0.1, view distance doubles with every 7m altitude increase (default: 0.0049333 - view distance doubles every 140m,  ln(0.5)/-0.0049333).
    V3.2+: The decay can be negative (-0.1- 0.1), to reverse the decaying effect (fog becomes thicker with higher altitudes).
  • altitude: Number - Altitude of fog at which it has the full, specified density (fog gets thicker with lower, and thinner with higher altitudes) (default: 0).
Return Value:Nothing


15 setFog 0.5;
10 setFog [0.5, 0.002, 100];

Additional Information

See also: setFogEffect, fog, fog2, fogForecast, fogForecast2, nextWeatherChange
Multiplayer:Effect is not map-wide, but only around the player the command is issued from (other players who come close to this player, see the fog effect as well). For fully local fog, use setFogEffect.


Only one script command induced weather change (either setOvercast or setFog) can be happening at a time. Starting a new weather change will immediately halt the current weather change. setRain changes are independent and can occur simultaneously to a weather change.