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.

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

Its color depends only 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

The sight distance in the distance fog is equal to the render distance, and the shape is a cylinder.

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 travelling in water into another biome. Notably, swamps and mangrove swamps have a thicker fog than most other biomes, which is controlled by 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), and its shape is a sphere. With this fog, normally the player can only 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 only see only 2 block 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, while the sight distance with darkness is 15. And the shape of the fog becomes a sphere.

The 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.

These two effect 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, 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 eventboss，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 four 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 four aspects from custom fog stack to default fog setting in order, until it finds a value for the current fog type. If it finds no matching setting, the game uses the defaults defined by the engine.

See also this official document.