World - Fog Module
anvil.api.pbr.fog
FogSettings
Bases: AddonObject
Represents a Minecraft Fog resource pack definition.
Generates a .fog.json file in the pack's fogs/ directory. Fog settings define
both distance-based fog properties and volumetric (PBR/Ray Tracing) settings.
Settings are resolved in the game via the Active Fog Stack:
Command (highest precedence) -> Biomes -> Data Default -> Engine Default (lowest).
identifier
property
Returns the identifier of the addon object in the format 'namespace:name'.
Returns:
| Name | Type | Description |
|---|---|---|
str |
Identifier
|
The identifier of the addon object. |
name
property
Returns the name of the addon object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the addon object. |
__export__()
Exports the addon object after potentially shortening its content and replacing backslashes. Logs the event and writes the object to a file.
__init__(name='fog', is_vanilla=False)
Initializes a Fog definition instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The identifier and filename of the fog setting. Defaults to "fog". |
'fog'
|
is_vanilla
|
bool
|
True if referencing/overriding a vanilla fog definition
(under the |
False
|
add_distance_location(color, fog_start, fog_end, render_distance_type=RenderDistanceType.Render, camera_location=FogCameraLocation.Air)
Adds and configures distance-based fog settings for a specific camera location environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
str
|
Hex color code of the fog (e.g. |
required |
fog_start
|
float | int
|
Relative ratio or absolute block distance where fog begins to appear.
Maps to |
required |
fog_end
|
float | int
|
Relative ratio or absolute block distance where fog becomes fully opaque.
Maps to |
required |
render_distance_type
|
RenderDistanceType
|
Determines how start and end values are used.
- |
Render
|
camera_location
|
FogCameraLocation
|
The camera location environment (e.g., Air, Water, Weather, Lava, LavaResistance) matching the corresponding key in the JSON schema. Defaults to FogCameraLocation.Air. |
Air
|
Returns:
| Name | Type | Description |
|---|---|---|
_FogDistance |
The configured distance settings object for method chaining. |
air_density(max_density, uniform=False, zero_density_height=0.0, max_density_height=0.0)
Sets the volumetric density parameters for air. Used for Ray Tracing / PBR rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_density
|
float
|
Density multiplier disrupting light passing through air. Range: [0.0 (no fog), 1.0 (near opaque)]. |
required |
uniform
|
bool
|
If True, fog density is uniform at all heights. Defaults to False. |
False
|
zero_density_height
|
float
|
Y-level height in blocks where air fog density fades to 0.0.
Only active when |
0.0
|
max_density_height
|
float
|
Y-level height in blocks where air fog density starts at max_density.
Only active when |
0.0
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If PBR is not enabled in CONFIG. |
ValueError
|
If zero_density_height is less than max_density_height. |
content(content)
Sets the content of the addon object and returns the object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
any
|
The content to be set for the addon object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
self |
AddonObject
|
The instance of the current AddonObject. |
henyey_greenstein_g(air_g=0.0, water_g=0.0)
Sets Henyey-Greenstein phase function asymmetry parameters for air and water. Supported in format_version 1.21.90+ and only applicable in Vibrant Visuals (PBR) packs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
air_g
|
float
|
Asymmetry factor for air scattering. Range [-1.0 (back-scattering), 1.0 (forward-scattering)]. Default is 0.75. |
0.0
|
water_g
|
float
|
Asymmetry factor for water scattering. Range [-1.0 (back-scattering), 1.0 (forward-scattering)]. Default is 0.6. |
0.0
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If PBR is not enabled in CONFIG. |
media_coefficients(water_scattering=None, water_absorption=None, air_scattering=None, air_absorption=None)
Sets media scattering and absorption RGB coefficients for water and air volumetric mediums.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
water_scattering
|
Color
|
RGB scattering multipliers. |
None
|
water_absorption
|
Color
|
RGB absorption multipliers. |
None
|
air_scattering
|
Color
|
RGB scattering multipliers. |
None
|
air_absorption
|
Color
|
RGB absorption multipliers. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If PBR is not enabled in CONFIG. |
queue()
Validates, orders the JSON structure canonically, and queues the fog file for export.
Arranges properties in the canonical order: description -> distance -> volumetric
as required or recommended by Minecraft Bedrock schemas.
set_identifier_data(data)
Sets the data of the addon object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
any
|
The data to be set for the addon object. |
required |
water_density(max_density, uniform=True, zero_density_height=0.0, max_density_height=0.0)
Sets the volumetric density parameters for water. Used for Ray Tracing / PBR rendering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_density
|
float
|
Density multiplier disrupting light passing through water. Range: [0.0 (no fog), 1.0 (near opaque)]. |
required |
uniform
|
bool
|
If True, fog density is uniform at all heights. Defaults to True. |
True
|
zero_density_height
|
float
|
Y-level height in blocks where water fog density fades to 0.0.
Only active when |
0.0
|
max_density_height
|
float
|
Y-level height in blocks where water fog density starts at max_density.
Only active when |
0.0
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If PBR is not enabled in CONFIG. |
ValueError
|
If zero_density_height is less than max_density_height. |