迷雾简介

迷雾是一种渲染功能,可用于遮挡玩家的视距。 您可以使用迷雾来遮挡边界,例如卸载超出渲染距离的区块,或产生大气效果。 有几种类型的迷雾可用于许多不同的情况。

迷雾在资源包中 fogs 目录下的单个 JSON 文件中设置。

迷雾模式

{
    version "format_version"
    object "minecraft:fog_settings"
    {
        object "description"
        {
            string "identifier" // The identifier for these fog settings. The identifier must include a namespace.
        }
        object "distance" : opt // The distance fog settings for different camera locations.
        {
            object "air" : opt // The fog settings when the camera is in the air.
            {
                color "fog_color" // The color that the fog will take on.
                float "fog_start"<0.000000-*> // The distance from the player that the fog will begin to appear. 'fog_start' must be less than or equal to 'fog_end'.
                float "fog_end"<0.000000-*> // The distance from the player that the fog will become fully opaque. 'fog_end' must be greater than or equal to 'fog_start'.
                string "render_distance_type"<"fixed", "render"> // Determines how distance value is used. Fixed distance is measured in blocks. Dynamic distance is multiplied by the current render distance.
            }
            object "weather" : opt // The fog settings for when the camera is in the air with active weather (rain, snow, etc..).
            {
                color "fog_color" // The color that the fog will take on.
                float "fog_start"<0.000000-*> // The distance from the player that the fog will begin to appear. 'fog_start' must be less than or equal to 'fog_end'.
                float "fog_end"<0.000000-*> // The distance from the player that the fog will become fully opaque. 'fog_end' must be greater than or equal to 'fog_start'.
                string "render_distance_type"<"fixed", "render"> // Determines how distance value is used. Fixed distance is measured in blocks. Dynamic distance is multiplied by the current render distance.
            }
            object "water" : opt // The fog settings when the camera is in water.
            {
                color "fog_color" // The color that the fog will take on.
                float "fog_start"<0.000000-*> // The distance from the player that the fog will begin to appear. 'fog_start' must be less than or equal to 'fog_end'.
                float "fog_end"<0.000000-*> // The distance from the player that the fog will become fully opaque. 'fog_end' must be greater than or equal to 'fog_start'.
                string "render_distance_type"<"fixed", "render"> // Determines how distance value is used. Fixed distance is measured in blocks. Dynamic distance is multiplied by the current render distance.
            }
            object "lava" : opt // The fog settings when the camera is in lava.
            {
                color "fog_color" // The color that the fog will take on.
                float "fog_start"<0.000000-*> // The distance from the player that the fog will begin to appear. 'fog_start' must be less than or equal to 'fog_end'.
                float "fog_end"<0.000000-*> // The distance from the player that the fog will become fully opaque. 'fog_end' must be greater than or equal to 'fog_start'.
                string "render_distance_type"<"fixed", "render"> // Determines how distance value is used. Fixed distance is measured in blocks. Dynamic distance is multiplied by the current render distance.
            }
            object "lava_resistance" : opt // The fog settings when the camera is in lava and the player has the lava resistance effect active.
            {
                color "fog_color" // The color that the fog will take on.
                float "fog_start"<0.000000-*> // The distance from the player that the fog will begin to appear. 'fog_start' must be less than or equal to 'fog_end'.
                float "fog_end"<0.000000-*> // The distance from the player that the fog will become fully opaque. 'fog_end' must be greater than or equal to 'fog_start'.
                string "render_distance_type"<"fixed", "render"> // Determines how distance value is used. Fixed distance is measured in blocks. Dynamic distance is multiplied by the current render distance.
            }
            object "powder_snow" : opt // The fog settings when the camera is inside a Powder Snow block.
            {
                color "fog_color" // The color that the fog will take on.
                float "fog_start"<0.000000-*> // The distance from the player that the fog will begin to appear. 'fog_start' must be less than or equal to 'fog_end'.
                float "fog_end"<0.000000-*> // The distance from the player that the fog will become fully opaque. 'fog_end' must be greater than or equal to 'fog_start'.
                string "render_distance_type"<"fixed", "render"> // Determines how distance value is used. Fixed distance is measured in blocks. Dynamic distance is multiplied by the current render distance.
            }
        }
        object "volumetric" : opt // The volumetric fog settings.
        {
            object "density" : opt // The density settings for different camera locations.
            {
                object "air" : opt // Fog density values as light passes through air blocks.
                {
                    float "max_density"<0.000000-1.000000> // The maximum amount of opaqueness that the ground fog will take on. A value from [0.0, 1.0].
                    float "max_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will become it's maximum density.
                    float "zero_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will be completely transparent and begin to appear. This value needs to be at least 1 higher than 'max_density_height'.
                    bool "uniform" : opt // When set to true, the density will be uniform across all heights.
                }
                object "water" : opt // Fog density values as light passes through water blocks.
                {
                    float "max_density"<0.000000-1.000000> // The maximum amount of opaqueness that the ground fog will take on. A value from [0.0, 1.0].
                    float "max_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will become it's maximum density.
                    float "zero_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will be completely transparent and begin to appear. This value needs to be at least 1 higher than 'max_density_height'.
                    bool "uniform" : opt // When set to true, the density will be uniform across all heights.
                }
                object "lava" : opt // Fog density values as light passes through lava blocks.
                {
                    float "max_density"<0.000000-1.000000> // The maximum amount of opaqueness that the ground fog will take on. A value from [0.0, 1.0].
                    float "max_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will become it's maximum density.
                    float "zero_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will be completely transparent and begin to appear. This value needs to be at least 1 higher than 'max_density_height'.
                    bool "uniform" : opt // When set to true, the density will be uniform across all heights.
                }
                object "lava_resistance" : opt // Fog density values as light passes through lava blocks while the player has lava resistance.
                {
                    float "max_density"<0.000000-1.000000> // The maximum amount of opaqueness that the ground fog will take on. A value from [0.0, 1.0].
                    float "max_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will become it's maximum density.
                    float "zero_density_height"<0.000000-320.000000> : opt // The height in blocks that the ground fog will be completely transparent and begin to appear. This value needs to be at least 1 higher than 'max_density_height'.
                    bool "uniform" : opt // When set to true, the density will be uniform across all heights.
                }
            }
            object "media_coefficients" : opt // The coefficient settings for the volumetric fog in different blocks.
            {
                object "air" : opt // Fog coefficient values while light passes through air.
                {
                    color "scattering" // Proportion of light that is scattered per block.
                    color "absorption" // Proportion of light that is absorbed (lost) per block.
                }
                object "water" : opt // Fog coefficient values while light passes through water.
                {
                    color "scattering" // Proportion of light that is scattered per block.
                    color "absorption" // Proportion of light that is absorbed (lost) per block.
                }
                object "cloud" : opt // Fog coefficient values while light passes through clouds.
                {
                    color "scattering" // Proportion of light that is scattered per block.
                    color "absorption" // Proportion of light that is absorbed (lost) per block.
                }
            }
        }
    }
}

活动迷雾栈

活动迷雾栈用于确定在游戏中的任何给定时间使用哪种迷雾设置。 每个玩家都有一个单独的迷雾栈。

每当游戏需要确定迷雾的值时,它将从迷雾栈的顶部开始并检查,直到找到当前设置类型的值。 如果迷雾栈上没有迷雾设置匹配,游戏将继续向下查找迷雾栈并检查。 如果没有找到匹配的设置,游戏将使用引擎定义的默认值。

迷雾栈最初设置如下。 从底部开始:

  • 引擎默认:硬编码值。
  • 数据默认:默认数据驱动设置。
  • 生物群系:定义为每个生物群系的设置。
  • 命令:由服务器命令为玩家指定的设置。

引擎默认

硬编码值,在没有数据驱动值时使用;如果游戏到达迷雾栈底部时没有匹配的迷雾设置,则将加载引擎默认值。

数据默认

如果通过 fog_identifier 引用迷雾定义,则在 default 下的 biomes_client.json 中定义。

生物群系

生物群系层是玩家位置周围生物群系定义的所有设置的平均值。 生物群系设置也在 biomes_client.json 中为每个单独的生物群系定义。

命令

命令层是 /fog 命令设置的所有设置,并作为一个栈从上到下评估。 有关详细信息,请参阅 Fog 命令部分。

生物群系

可以使用 biomes_client.json 为生物群系确定迷雾设置。 在每个生物群系条目中,您可以有一个名为 fog_identifier 的变量,并设置一个名称,该名称与您要与该生物群系一起使用的迷雾设置匹配。

default 条目也可以这样设置,并将用于活动迷雾栈中的生物群系条目下方。 生物群系的迷雾设置不会完全取代默认设置,而是在默认设置之上读取生物群系,如活动迷雾栈 部分所述。

default 生物群系条目具有标签 remove_all_prior_fog,默认设置为 false。 当设置为 false(或者如果没有输入标签)时,缺失的迷雾定义将由任何填充定义的较低资源包来填充。 如果设置为 true,则在当前启用该定义的包之前的资源包中所有先前的迷雾定义将被清除,从而使当前资源包成为所有迷雾的新起点。

在每个生物群系(包括 default)中,都有一个标签 inherit_from_prior_fog 默认设置为 false。 当设置为 false(或者如果没有输入标签)时,当前资源包的生物群系将用它自己的标签覆盖当前存储的 fog_identifier 标签。 如果设置为 true,则来自所有匹配生物群系的 fog_identifier 标签将一起添加,并为该生物群系创建一个新的合并迷雾定义。

迷雾命令

/fog 命令可用于管理每个玩家的活动迷雾栈的当前层中的迷雾设置。

此层中的迷雾设置通过 /fog 命令的 pushpopremove 模式进行排序。

迷雾设置在活动迷雾栈中自上而下进行评估,先从当前层开始。

此层中的迷雾设置将被保存,然后在每个玩家的世界加载时恢复。 在世界保存之前压入的迷雾设置在世界加载后仍将应用,然后可以弹出。

压入

将指定玩家的新迷雾设置与用户提供的 ID 一起压入到玩家活动迷雾栈的迷雾命令层顶部。

弹出

从与用户提供的 ID 匹配的选定玩家中移除最顶部的迷雾设置。

移除

从与用户提供的 ID 匹配的选定玩家中移除所有匹配的迷雾设置。