:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/4.2/modules/noise/doc_classes/FastNoiseLite.xml. .. _class_FastNoiseLite: FastNoiseLite ============= **继承:** :ref:`Noise` **<** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` 使用 FastNoiseLite 库生成噪声。 .. rst-class:: classref-introduction-group 描述 ---- 该类使用 FastNoiseLite 库生成噪声,该库是多种噪声算法的集合,包括 Cellular、Perlin、Value 等。 大多数生成的噪声值都在 ``[-1, 1]`` 范围内,但并非总是如此。一些蜂窝噪声算法返回高于 ``1`` 的结果。 .. rst-class:: classref-reftable-group 属性 ---- .. table:: :widths: auto +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`CellularDistanceFunction` | :ref:`cellular_distance_function` | ``0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`cellular_jitter` | ``1.0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`CellularReturnType` | :ref:`cellular_return_type` | ``1`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`domain_warp_amplitude` | ``30.0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`bool` | :ref:`domain_warp_enabled` | ``false`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`domain_warp_fractal_gain` | ``0.5`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`domain_warp_fractal_lacunarity` | ``6.0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`int` | :ref:`domain_warp_fractal_octaves` | ``5`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`DomainWarpFractalType` | :ref:`domain_warp_fractal_type` | ``1`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`domain_warp_frequency` | ``0.05`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`DomainWarpType` | :ref:`domain_warp_type` | ``0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`fractal_gain` | ``0.5`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`fractal_lacunarity` | ``2.0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`int` | :ref:`fractal_octaves` | ``5`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`fractal_ping_pong_strength` | ``2.0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`FractalType` | :ref:`fractal_type` | ``1`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`fractal_weighted_strength` | ``0.0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`float` | :ref:`frequency` | ``0.01`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`NoiseType` | :ref:`noise_type` | ``1`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`Vector3` | :ref:`offset` | ``Vector3(0, 0, 0)`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ | :ref:`int` | :ref:`seed` | ``0`` | +------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+----------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 枚举 ---- .. _enum_FastNoiseLite_NoiseType: .. rst-class:: classref-enumeration enum **NoiseType**: .. _class_FastNoiseLite_constant_TYPE_VALUE: .. rst-class:: classref-enumeration-constant :ref:`NoiseType` **TYPE_VALUE** = ``5`` 点阵被分配随机值,然后根据相邻值进行插值。 .. _class_FastNoiseLite_constant_TYPE_VALUE_CUBIC: .. rst-class:: classref-enumeration-constant :ref:`NoiseType` **TYPE_VALUE_CUBIC** = ``4`` 类似于 Value 噪声,但速度较慢。波峰和波谷的变化更大。 在使用值噪声创建凹凸贴图时,可以使用三次噪声来避免某些伪影。一般来说,如果值噪声用于高度图或凹凸贴图,则应始终使用此模式。 .. _class_FastNoiseLite_constant_TYPE_PERLIN: .. rst-class:: classref-enumeration-constant :ref:`NoiseType` **TYPE_PERLIN** = ``3`` 随机渐变的一种格子。对它们的点积进行插值,以获得格子之间的值。 .. _class_FastNoiseLite_constant_TYPE_CELLULAR: .. rst-class:: classref-enumeration-constant :ref:`NoiseType` **TYPE_CELLULAR** = ``2`` 蜂窝包括 Worley 噪声图和 Voronoi 图,它们创建了相同值的不同区域。 .. _class_FastNoiseLite_constant_TYPE_SIMPLEX: .. rst-class:: classref-enumeration-constant :ref:`NoiseType` **TYPE_SIMPLEX** = ``0`` 与 :ref:`TYPE_PERLIN` 不同,渐变存在于单纯形点阵中,而不是网格点阵中,从而避免了定向伪影。 .. _class_FastNoiseLite_constant_TYPE_SIMPLEX_SMOOTH: .. rst-class:: classref-enumeration-constant :ref:`NoiseType` **TYPE_SIMPLEX_SMOOTH** = ``1`` 对 :ref:`TYPE_SIMPLEX` 修改后得到的更高质量版本,但速度较慢。 .. rst-class:: classref-item-separator ---- .. _enum_FastNoiseLite_FractalType: .. rst-class:: classref-enumeration enum **FractalType**: .. _class_FastNoiseLite_constant_FRACTAL_NONE: .. rst-class:: classref-enumeration-constant :ref:`FractalType` **FRACTAL_NONE** = ``0`` 无分形噪声。 .. _class_FastNoiseLite_constant_FRACTAL_FBM: .. rst-class:: classref-enumeration-constant :ref:`FractalType` **FRACTAL_FBM** = ``1`` 使用分形布朗运动将八度音阶组合成分形的方法。 .. _class_FastNoiseLite_constant_FRACTAL_RIDGED: .. rst-class:: classref-enumeration-constant :ref:`FractalType` **FRACTAL_RIDGED** = ``2`` 将八度音阶组合成分形的方法,从而产生一种“脊状”外观。 .. _class_FastNoiseLite_constant_FRACTAL_PING_PONG: .. rst-class:: classref-enumeration-constant :ref:`FractalType` **FRACTAL_PING_PONG** = ``3`` 将八度音阶组合成具有乒乓效果的分形的方法。 .. rst-class:: classref-item-separator ---- .. _enum_FastNoiseLite_CellularDistanceFunction: .. rst-class:: classref-enumeration enum **CellularDistanceFunction**: .. _class_FastNoiseLite_constant_DISTANCE_EUCLIDEAN: .. rst-class:: classref-enumeration-constant :ref:`CellularDistanceFunction` **DISTANCE_EUCLIDEAN** = ``0`` 到最近点的欧几里得距离。 .. _class_FastNoiseLite_constant_DISTANCE_EUCLIDEAN_SQUARED: .. rst-class:: classref-enumeration-constant :ref:`CellularDistanceFunction` **DISTANCE_EUCLIDEAN_SQUARED** = ``1`` 到最近点的欧几里得距离的平方。 .. _class_FastNoiseLite_constant_DISTANCE_MANHATTAN: .. rst-class:: classref-enumeration-constant :ref:`CellularDistanceFunction` **DISTANCE_MANHATTAN** = ``2`` 到最近点的曼哈顿距离(出租车度量法)。 .. _class_FastNoiseLite_constant_DISTANCE_HYBRID: .. rst-class:: classref-enumeration-constant :ref:`CellularDistanceFunction` **DISTANCE_HYBRID** = ``3`` :ref:`DISTANCE_EUCLIDEAN` 和 :ref:`DISTANCE_MANHATTAN` 的混合,以给出弯曲的单元格边界 .. rst-class:: classref-item-separator ---- .. _enum_FastNoiseLite_CellularReturnType: .. rst-class:: classref-enumeration enum **CellularReturnType**: .. _class_FastNoiseLite_constant_RETURN_CELL_VALUE: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_CELL_VALUE** = ``0`` 蜂窝单元格距离函数,将为单元格内的所有点返回相同的值。 .. _class_FastNoiseLite_constant_RETURN_DISTANCE: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_DISTANCE** = ``1`` 蜂窝单元格距离函数,将返回一个由到最近点的距离确定的值。 .. _class_FastNoiseLite_constant_RETURN_DISTANCE2: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_DISTANCE2** = ``2`` 蜂窝单元格距离函数,将返回到第二最近点的距离。 .. _class_FastNoiseLite_constant_RETURN_DISTANCE2_ADD: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_DISTANCE2_ADD** = ``3`` 将最近点的距离与次近点的距离相加。 .. _class_FastNoiseLite_constant_RETURN_DISTANCE2_SUB: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_DISTANCE2_SUB** = ``4`` 将最近点的距离与次近点的距离相减。 .. _class_FastNoiseLite_constant_RETURN_DISTANCE2_MUL: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_DISTANCE2_MUL** = ``5`` 将最近点的距离与次近点的距离相乘。 .. _class_FastNoiseLite_constant_RETURN_DISTANCE2_DIV: .. rst-class:: classref-enumeration-constant :ref:`CellularReturnType` **RETURN_DISTANCE2_DIV** = ``6`` 将最近点的距离与次近点的距离相除。 .. rst-class:: classref-item-separator ---- .. _enum_FastNoiseLite_DomainWarpType: .. rst-class:: classref-enumeration enum **DomainWarpType**: .. _class_FastNoiseLite_constant_DOMAIN_WARP_SIMPLEX: .. rst-class:: classref-enumeration-constant :ref:`DomainWarpType` **DOMAIN_WARP_SIMPLEX** = ``0`` 使用单纯形噪声算法,对域进行扭曲。 .. _class_FastNoiseLite_constant_DOMAIN_WARP_SIMPLEX_REDUCED: .. rst-class:: classref-enumeration-constant :ref:`DomainWarpType` **DOMAIN_WARP_SIMPLEX_REDUCED** = ``1`` 使用简化版的单纯形噪声算法,对域进行扭曲。 .. _class_FastNoiseLite_constant_DOMAIN_WARP_BASIC_GRID: .. rst-class:: classref-enumeration-constant :ref:`DomainWarpType` **DOMAIN_WARP_BASIC_GRID** = ``2`` 使用简单的噪声栅格(不像其他方法那样平滑,但性能更高),对域进行扭曲。 .. rst-class:: classref-item-separator ---- .. _enum_FastNoiseLite_DomainWarpFractalType: .. rst-class:: classref-enumeration enum **DomainWarpFractalType**: .. _class_FastNoiseLite_constant_DOMAIN_WARP_FRACTAL_NONE: .. rst-class:: classref-enumeration-constant :ref:`DomainWarpFractalType` **DOMAIN_WARP_FRACTAL_NONE** = ``0`` 没有用于扭曲空间的分形噪声。 .. _class_FastNoiseLite_constant_DOMAIN_WARP_FRACTAL_PROGRESSIVE: .. rst-class:: classref-enumeration-constant :ref:`DomainWarpFractalType` **DOMAIN_WARP_FRACTAL_PROGRESSIVE** = ``1`` 逐渐扭曲空间,一个八度一个八度,导致更“液化”的失真。 .. _class_FastNoiseLite_constant_DOMAIN_WARP_FRACTAL_INDEPENDENT: .. rst-class:: classref-enumeration-constant :ref:`DomainWarpFractalType` **DOMAIN_WARP_FRACTAL_INDEPENDENT** = ``2`` 为每个八度音阶独立地扭曲空间,从而导致更混乱的失真。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 属性说明 -------- .. _class_FastNoiseLite_property_cellular_distance_function: .. rst-class:: classref-property :ref:`CellularDistanceFunction` **cellular_distance_function** = ``0`` .. rst-class:: classref-property-setget - void **set_cellular_distance_function** **(** :ref:`CellularDistanceFunction` value **)** - :ref:`CellularDistanceFunction` **get_cellular_distance_function** **(** **)** 确定如何计算到最近/第二最近点的距离。有关选项,请参阅 :ref:`CellularDistanceFunction`\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_cellular_jitter: .. rst-class:: classref-property :ref:`float` **cellular_jitter** = ``1.0`` .. rst-class:: classref-property-setget - void **set_cellular_jitter** **(** :ref:`float` value **)** - :ref:`float` **get_cellular_jitter** **(** **)** 一个点可以离开其栅格位置的最大距离。对于偶数栅格,设置为 ``0``\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_cellular_return_type: .. rst-class:: classref-property :ref:`CellularReturnType` **cellular_return_type** = ``1`` .. rst-class:: classref-property-setget - void **set_cellular_return_type** **(** :ref:`CellularReturnType` value **)** - :ref:`CellularReturnType` **get_cellular_return_type** **(** **)** 蜂窝噪声计算的返回类型。请参阅 :ref:`CellularReturnType`\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_amplitude: .. rst-class:: classref-property :ref:`float` **domain_warp_amplitude** = ``30.0`` .. rst-class:: classref-property-setget - void **set_domain_warp_amplitude** **(** :ref:`float` value **)** - :ref:`float` **get_domain_warp_amplitude** **(** **)** 设置距原点的最大扭曲距离。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_enabled: .. rst-class:: classref-property :ref:`bool` **domain_warp_enabled** = ``false`` .. rst-class:: classref-property-setget - void **set_domain_warp_enabled** **(** :ref:`bool` value **)** - :ref:`bool` **is_domain_warp_enabled** **(** **)** 如果启用,则另一个 FastNoiseLite 实例将被用于扭曲空间,从而导致噪声失真。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_fractal_gain: .. rst-class:: classref-property :ref:`float` **domain_warp_fractal_gain** = ``0.5`` .. rst-class:: classref-property-setget - void **set_domain_warp_fractal_gain** **(** :ref:`float` value **)** - :ref:`float` **get_domain_warp_fractal_gain** **(** **)** 确定用于扭曲空间的噪声的每个后续层的强度。 较低的值更强调较低频率的基础层,而较高的值则更强调较高频率的层。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_fractal_lacunarity: .. rst-class:: classref-property :ref:`float` **domain_warp_fractal_lacunarity** = ``6.0`` .. rst-class:: classref-property-setget - void **set_domain_warp_fractal_lacunarity** **(** :ref:`float` value **)** - :ref:`float` **get_domain_warp_fractal_lacunarity** **(** **)** 扭曲空间的分形噪声的八度音阶空隙。增加此值,会导致更高的八度音阶,从而产生细节更精细、外观更粗糙的噪声。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_fractal_octaves: .. rst-class:: classref-property :ref:`int` **domain_warp_fractal_octaves** = ``5`` .. rst-class:: classref-property-setget - void **set_domain_warp_fractal_octaves** **(** :ref:`int` value **)** - :ref:`int` **get_domain_warp_fractal_octaves** **(** **)** 为获得扭曲空间的分形噪声的最终值而采样的噪声层数。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_fractal_type: .. rst-class:: classref-property :ref:`DomainWarpFractalType` **domain_warp_fractal_type** = ``1`` .. rst-class:: classref-property-setget - void **set_domain_warp_fractal_type** **(** :ref:`DomainWarpFractalType` value **)** - :ref:`DomainWarpFractalType` **get_domain_warp_fractal_type** **(** **)** 将八度音阶组合成用于扭曲空间的分形的方法。请参阅 :ref:`DomainWarpFractalType`\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_frequency: .. rst-class:: classref-property :ref:`float` **domain_warp_frequency** = ``0.05`` .. rst-class:: classref-property-setget - void **set_domain_warp_frequency** **(** :ref:`float` value **)** - :ref:`float` **get_domain_warp_frequency** **(** **)** 扭曲空间的噪音频率。低频产生平滑的噪声,而高频产生更粗糙、颗粒状更明显的噪声。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_domain_warp_type: .. rst-class:: classref-property :ref:`DomainWarpType` **domain_warp_type** = ``0`` .. rst-class:: classref-property-setget - void **set_domain_warp_type** **(** :ref:`DomainWarpType` value **)** - :ref:`DomainWarpType` **get_domain_warp_type** **(** **)** 设置扭曲算法。请参阅 :ref:`DomainWarpType`\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_fractal_gain: .. rst-class:: classref-property :ref:`float` **fractal_gain** = ``0.5`` .. rst-class:: classref-property-setget - void **set_fractal_gain** **(** :ref:`float` value **)** - :ref:`float` **get_fractal_gain** **(** **)** 确定分形噪声中噪声的每个后续层的强度。 较低的值更强调较低频率的基础层,而较高的值则更强调较高频率的层。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_fractal_lacunarity: .. rst-class:: classref-property :ref:`float` **fractal_lacunarity** = ``2.0`` .. rst-class:: classref-property-setget - void **set_fractal_lacunarity** **(** :ref:`float` value **)** - :ref:`float` **get_fractal_lacunarity** **(** **)** 后续八度音阶之间的倍频器。增加该值,会产生更高的八度音阶,从而产生细节更精细、外观更粗糙的噪声。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_fractal_octaves: .. rst-class:: classref-property :ref:`int` **fractal_octaves** = ``5`` .. rst-class:: classref-property-setget - void **set_fractal_octaves** **(** :ref:`int` value **)** - :ref:`int` **get_fractal_octaves** **(** **)** 为获得分形噪声类型的最终值而采样的噪声层数。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_fractal_ping_pong_strength: .. rst-class:: classref-property :ref:`float` **fractal_ping_pong_strength** = ``2.0`` .. rst-class:: classref-property-setget - void **set_fractal_ping_pong_strength** **(** :ref:`float` value **)** - :ref:`float` **get_fractal_ping_pong_strength** **(** **)** 设置分形乒乓类型的强度。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_fractal_type: .. rst-class:: classref-property :ref:`FractalType` **fractal_type** = ``1`` .. rst-class:: classref-property-setget - void **set_fractal_type** **(** :ref:`FractalType` value **)** - :ref:`FractalType` **get_fractal_type** **(** **)** 将八度音阶组合成分形的方法。请参阅 :ref:`FractalType`\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_fractal_weighted_strength: .. rst-class:: classref-property :ref:`float` **fractal_weighted_strength** = ``0.0`` .. rst-class:: classref-property-setget - void **set_fractal_weighted_strength** **(** :ref:`float` value **)** - :ref:`float` **get_fractal_weighted_strength** **(** **)** 较高的权重意味着如果较低的八度具有较大的影响,则较高的八度具有较小的影响。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_frequency: .. rst-class:: classref-property :ref:`float` **frequency** = ``0.01`` .. rst-class:: classref-property-setget - void **set_frequency** **(** :ref:`float` value **)** - :ref:`float` **get_frequency** **(** **)** 所有噪声类型的频率。低频产生平滑的噪声,而高频产生更粗糙、颗粒状更明显的噪声。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_noise_type: .. rst-class:: classref-property :ref:`NoiseType` **noise_type** = ``1`` .. rst-class:: classref-property-setget - void **set_noise_type** **(** :ref:`NoiseType` value **)** - :ref:`NoiseType` **get_noise_type** **(** **)** 所使用的噪声算法。见 :ref:`NoiseType`\ 。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_offset: .. rst-class:: classref-property :ref:`Vector3` **offset** = ``Vector3(0, 0, 0)`` .. rst-class:: classref-property-setget - void **set_offset** **(** :ref:`Vector3` value **)** - :ref:`Vector3` **get_offset** **(** **)** 使用给定的 :ref:`Vector3` 对噪声输入坐标进行平移。 .. rst-class:: classref-item-separator ---- .. _class_FastNoiseLite_property_seed: .. rst-class:: classref-property :ref:`int` **seed** = ``0`` .. rst-class:: classref-property-setget - void **set_seed** **(** :ref:`int` value **)** - :ref:`int` **get_seed** **(** **)** 所有噪声类型的随机数种子。 .. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)` .. |const| replace:: :abbr:`const (本方法没有副作用。不会修改该实例的任何成员变量。)` .. |vararg| replace:: :abbr:`vararg (本方法除了在此处描述的参数外,还能够继续接受任意数量的参数。)` .. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)` .. |static| replace:: :abbr:`static (调用本方法无需实例,所以可以直接使用类名调用。)` .. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效操作符。)` .. |bitfield| replace:: :abbr:`BitField (这个值是由下列标志构成的位掩码整数。)`