Files
godot-docs/classes/class_noisetexture2d.rst
2025-06-07 03:33:02 +00:00

298 lines
15 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/modules/noise/doc_classes/NoiseTexture2D.xml.
.. _class_NoiseTexture2D:
NoiseTexture2D
==============
**Inherits:** :ref:`Texture2D<class_Texture2D>` **<** :ref:`Texture<class_Texture>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
A 2D texture filled with noise generated by a :ref:`Noise<class_Noise>` object.
.. rst-class:: classref-introduction-group
Description
-----------
Uses the :ref:`FastNoiseLite<class_FastNoiseLite>` library or other noise generators to fill the texture data of your desired size. **NoiseTexture2D** can also generate normal map textures.
The class uses :ref:`Thread<class_Thread>`\ s to generate the texture data internally, so :ref:`Texture2D.get_image()<class_Texture2D_method_get_image>` may return ``null`` if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the image and the generated byte data:
::
var texture = NoiseTexture2D.new()
texture.noise = FastNoiseLite.new()
await texture.changed
var image = texture.get_image()
var data = image.get_data()
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`as_normal_map<class_NoiseTexture2D_property_as_normal_map>` | ``false`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`bump_strength<class_NoiseTexture2D_property_bump_strength>` | ``8.0`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`Gradient<class_Gradient>` | :ref:`color_ramp<class_NoiseTexture2D_property_color_ramp>` | |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`generate_mipmaps<class_NoiseTexture2D_property_generate_mipmaps>` | ``true`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`height<class_NoiseTexture2D_property_height>` | ``512`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`in_3d_space<class_NoiseTexture2D_property_in_3d_space>` | ``false`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`invert<class_NoiseTexture2D_property_invert>` | ``false`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`Noise<class_Noise>` | :ref:`noise<class_NoiseTexture2D_property_noise>` | |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`normalize<class_NoiseTexture2D_property_normalize>` | ``true`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | resource_local_to_scene | ``false`` (overrides :ref:`Resource<class_Resource_property_resource_local_to_scene>`) |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`seamless<class_NoiseTexture2D_property_seamless>` | ``false`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`seamless_blend_skirt<class_NoiseTexture2D_property_seamless_blend_skirt>` | ``0.1`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`width<class_NoiseTexture2D_property_width>` | ``512`` |
+---------------------------------+---------------------------------------------------------------------------------+----------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_NoiseTexture2D_property_as_normal_map:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **as_normal_map** = ``false`` :ref:`🔗<class_NoiseTexture2D_property_as_normal_map>`
.. rst-class:: classref-property-setget
- |void| **set_as_normal_map**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_normal_map**\ (\ )
If ``true``, the resulting texture contains a normal map created from the original noise interpreted as a bump map.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_bump_strength:
.. rst-class:: classref-property
:ref:`float<class_float>` **bump_strength** = ``8.0`` :ref:`🔗<class_NoiseTexture2D_property_bump_strength>`
.. rst-class:: classref-property-setget
- |void| **set_bump_strength**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_bump_strength**\ (\ )
Strength of the bump maps used in this texture. A higher value will make the bump maps appear larger while a lower value will make them appear softer.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_color_ramp:
.. rst-class:: classref-property
:ref:`Gradient<class_Gradient>` **color_ramp** :ref:`🔗<class_NoiseTexture2D_property_color_ramp>`
.. rst-class:: classref-property-setget
- |void| **set_color_ramp**\ (\ value\: :ref:`Gradient<class_Gradient>`\ )
- :ref:`Gradient<class_Gradient>` **get_color_ramp**\ (\ )
A :ref:`Gradient<class_Gradient>` which is used to map the luminance of each pixel to a color value.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_generate_mipmaps:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **generate_mipmaps** = ``true`` :ref:`🔗<class_NoiseTexture2D_property_generate_mipmaps>`
.. rst-class:: classref-property-setget
- |void| **set_generate_mipmaps**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_generating_mipmaps**\ (\ )
Determines whether mipmaps are generated for this texture. Enabling this results in less texture aliasing in the distance, at the cost of increasing memory usage by roughly 33% and making the noise texture generation take longer.
\ **Note:** :ref:`generate_mipmaps<class_NoiseTexture2D_property_generate_mipmaps>` requires mipmap filtering to be enabled on the material using the **NoiseTexture2D** to have an effect.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_height:
.. rst-class:: classref-property
:ref:`int<class_int>` **height** = ``512`` :ref:`🔗<class_NoiseTexture2D_property_height>`
.. rst-class:: classref-property-setget
- |void| **set_height**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_height**\ (\ )
Height of the generated texture (in pixels).
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_in_3d_space:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **in_3d_space** = ``false`` :ref:`🔗<class_NoiseTexture2D_property_in_3d_space>`
.. rst-class:: classref-property-setget
- |void| **set_in_3d_space**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_in_3d_space**\ (\ )
Determines whether the noise image is calculated in 3D space. May result in reduced contrast.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_invert:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **invert** = ``false`` :ref:`🔗<class_NoiseTexture2D_property_invert>`
.. rst-class:: classref-property-setget
- |void| **set_invert**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_invert**\ (\ )
If ``true``, inverts the noise texture. White becomes black, black becomes white.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_noise:
.. rst-class:: classref-property
:ref:`Noise<class_Noise>` **noise** :ref:`🔗<class_NoiseTexture2D_property_noise>`
.. rst-class:: classref-property-setget
- |void| **set_noise**\ (\ value\: :ref:`Noise<class_Noise>`\ )
- :ref:`Noise<class_Noise>` **get_noise**\ (\ )
The instance of the :ref:`Noise<class_Noise>` object.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_normalize:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **normalize** = ``true`` :ref:`🔗<class_NoiseTexture2D_property_normalize>`
.. rst-class:: classref-property-setget
- |void| **set_normalize**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_normalized**\ (\ )
If ``true``, the noise image coming from the noise generator is normalized to the range ``0.0`` to ``1.0``.
Turning normalization off can affect the contrast and allows you to generate non repeating tileable noise textures.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_seamless:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **seamless** = ``false`` :ref:`🔗<class_NoiseTexture2D_property_seamless>`
.. rst-class:: classref-property-setget
- |void| **set_seamless**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **get_seamless**\ (\ )
If ``true``, a seamless texture is requested from the :ref:`Noise<class_Noise>` resource.
\ **Note:** Seamless noise textures may take longer to generate and/or can have a lower contrast compared to non-seamless noise depending on the used :ref:`Noise<class_Noise>` resource. This is because some implementations use higher dimensions for generating seamless noise.
\ **Note:** The default :ref:`FastNoiseLite<class_FastNoiseLite>` implementation uses the fallback path for seamless generation. If using a :ref:`width<class_NoiseTexture2D_property_width>` or :ref:`height<class_NoiseTexture2D_property_height>` lower than the default, you may need to increase :ref:`seamless_blend_skirt<class_NoiseTexture2D_property_seamless_blend_skirt>` to make seamless blending more effective.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_seamless_blend_skirt:
.. rst-class:: classref-property
:ref:`float<class_float>` **seamless_blend_skirt** = ``0.1`` :ref:`🔗<class_NoiseTexture2D_property_seamless_blend_skirt>`
.. rst-class:: classref-property-setget
- |void| **set_seamless_blend_skirt**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_seamless_blend_skirt**\ (\ )
Used for the default/fallback implementation of the seamless texture generation. It determines the distance over which the seams are blended. High values may result in less details and contrast. See :ref:`Noise<class_Noise>` for further details.
\ **Note:** If using a :ref:`width<class_NoiseTexture2D_property_width>` or :ref:`height<class_NoiseTexture2D_property_height>` lower than the default, you may need to increase :ref:`seamless_blend_skirt<class_NoiseTexture2D_property_seamless_blend_skirt>` to make seamless blending more effective.
.. rst-class:: classref-item-separator
----
.. _class_NoiseTexture2D_property_width:
.. rst-class:: classref-property
:ref:`int<class_int>` **width** = ``512`` :ref:`🔗<class_NoiseTexture2D_property_width>`
.. rst-class:: classref-property-setget
- |void| **set_width**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_width**\ (\ )
Width of the generated texture (in pixels).
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
.. |void| replace:: :abbr:`void (No return value.)`