Fog

Fog is a rendering feature intended for obscuring the player's view distance, usually for atmospheric effect or for seamlessly occluding sharp boundaries such as unloaded chunks. While traditionally referring to render distance, there are many other types of fog that can be encountered in-game under specific circumstances.

Fog types
There are four fog types four different circumstances.

Distance fog
This refers to fog which is rendered in normal circumstances, and becomes the most notable with low render distance.

The sight distance in the distance fog is equal to the render distance, and the shape is a cylinder. Its color depends mainly on the biome the camera is in, and is affected by:
 * the current day-time, and the effect the dimension uses
 * For overworld effect, the brightness of the color changes with day time.
 * For the nether effect, the brightness of the color is NOT affected by day time.
 * For the end effect, the brightness of the color does not change with day time, but is 15% of the biome fog color.
 * the current sky color<!affected by lightning>, and the render distance
 * The smaller the rendering distance, the closer the color of the fog is adjusted to the sky color.
 * When the rendering distance is 32, the color of the fog is not affected by the sky color.
 * the direction the player is facing during a sunrise or sunset if the render distance is not less than 4
 * the current weather

Water fog
When the camera is in water, a dedicated fog in the shape of a cylinder is applied to simulate this. Underwater fog progressively recedes with time spent underwater. The color is depends on the biome the camera is in. The color of the water fog changes gradually for 5 seconds when the camera travelled in water into another biome. Notably, swamps and mangrove swamps have a thicker fog than most other biomes, which is controlled by the biome tag.

Lava fog
When the camera is in lava, an even thicker fog in the shape of a sphere is applied. Its color is RGB(0.6,0.1,0.0). With this fog, normally the player can see only 1 block away. The Fire Resistance effect can mitigate the fog so that the sight distance becomes 3 blocks. In spectator mode, the fog becomes more thinner so that things within half of the render distance are visible.

Powder snow fog
Being beneath powder snow imparts another fog in the shape of a sphere. Its color is RGB(0.623, 0.734, 0.785). With this fog, normally the player can see only 2 blocks away. In spectator mode, the fog becomes more thinner so that things within half of the render distance are visible.

Height
If the world is not a superflat world, and the camera is not in lava and not in powder snow, the brightness becomes  of the original, which means that the color changes to pure black gradually from   to.

Blindness and darkness
Blindness and darkness set the color to pure black. The sight distance with blindness is 5 blocks, while the sight distance with darkness is 15 blocks. And the shape of the fog becomes a sphere.

A difference between the two is that darkness has fade-in and fade-out, while blinding has only fade-out.

Blindness has a higher priority than darkness. The two effectS do not work if the camera is in lava or powder snow.

Wither
If there is a wither boss event, the color becomes darker and slightly redder.

Night vision
If the camera is not in water, and the entity has no darkness effect, night vision makes the color brighter.

Nether and ender dragon
If the entity has no blindness or darkness, in a dimension with the nether effect, or a dimension where there's an ender dragon boss event，the sight distance in the distance fog (not water, lava, powder snow fog) is half of the rendering distance, and the maximum sight distance is 96 blocks. The shape becomes a sphere.

Void fog


In prior versions of Java Edition (specifically Beta 1.8 Pre-release through 14w34b inclusive, up to its removal in 14w34c), a thick black fog was introduced. As the player descended below Y=17 in the Overworld, this fog would start to appear. As the player traveled deeper, the fog at the edge of the render distance would become closer until the player reached the first layers of bedrock, where visibility was reduced to just a few blocks, beyond which was complete darkness. The gray void particles appeared below Y=17, as well as in the void.

The existence of this fog depended on a lack of sky lighting. If vent holes were opened up to allow sky light to enter an otherwise secluded underground space, void fog would no longer be present so long as the player kept near this sky light source.

Void fog was removed late into 1.8's development for performance reasons and general community distaste.

Bedrock Edition
$$, fogs has six types used in six different circumstances:
 * air: When the camera is in air
 * water: When the camera is in water
 * lava: When the camera is in lava, and the player has no fire resistance
 * lava resistance: When the camera is in lava, and the player has fire resistance
 * weather: When in air and it's raining
 * powder snow: When the camera is in powder snow

In a fog setting file in a resource pack, one or more of above types can be specified. Active fog settings are determined from three aspects:
 * Custom fog stack (from command)
 * Fog settings for the current biome
 * Default fog setting

Whenever the game needs to get the current fog, it checks the fog settings from these three aspects from the top (the newest fog setting in the fog stack from the command) to the bottom (default fog setting) in order, until it finds a fog definition for the current fog type. If it finds no matching setting, the game uses the hardcoded defaults of the engine.

In other words, this is equivalent to that all fog settings from the three aspects are applied one by one from the bottom (default fog setting) to the top (the newest fog setting in the fog stack from the command) in order. The fogs defined in the later fog setting overrides the earlier's. Each fog type works independently. Hardcoded default setting of the engine is applied before settings from these three aspects.

See also this official document.

Vanilla fog settings
Here are all the fog setting IDs that are currently in the vanilla game.