class_opensimplexnoise.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the OpenSimplexNoise.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_OpenSimplexNoise:
  6. OpenSimplexNoise
  7. ================
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Noise generator based on Open Simplex.
  10. Description
  11. -----------
  12. This resource allows you to configure and sample a fractal noise space. Here is a brief usage example that configures an OpenSimplexNoise and gets samples at various positions and dimensions:
  13. ::
  14. var noise = OpenSimplexNoise.new()
  15. # Configure
  16. noise.seed = randi()
  17. noise.octaves = 4
  18. noise.period = 20.0
  19. noise.persistence = 0.8
  20. # Sample
  21. print("Values:")
  22. print(noise.get_noise_2d(1.0, 1.0))
  23. print(noise.get_noise_3d(0.5, 3.0, 15.0))
  24. print(noise.get_noise_4d(0.5, 1.9, 4.7, 0.0))
  25. Properties
  26. ----------
  27. +---------------------------+-----------------------------------------------------------------+----------+
  28. | :ref:`float<class_float>` | :ref:`lacunarity<class_OpenSimplexNoise_property_lacunarity>` | ``2.0`` |
  29. +---------------------------+-----------------------------------------------------------------+----------+
  30. | :ref:`int<class_int>` | :ref:`octaves<class_OpenSimplexNoise_property_octaves>` | ``3`` |
  31. +---------------------------+-----------------------------------------------------------------+----------+
  32. | :ref:`float<class_float>` | :ref:`period<class_OpenSimplexNoise_property_period>` | ``64.0`` |
  33. +---------------------------+-----------------------------------------------------------------+----------+
  34. | :ref:`float<class_float>` | :ref:`persistence<class_OpenSimplexNoise_property_persistence>` | ``0.5`` |
  35. +---------------------------+-----------------------------------------------------------------+----------+
  36. | :ref:`int<class_int>` | :ref:`seed<class_OpenSimplexNoise_property_seed>` | ``0`` |
  37. +---------------------------+-----------------------------------------------------------------+----------+
  38. Methods
  39. -------
  40. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Image<class_Image>` | :ref:`get_image<class_OpenSimplexNoise_method_get_image>` **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`Vector2<class_Vector2>` noise_offset=Vector2( 0, 0 ) **)** |const| |
  42. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | :ref:`get_noise_1d<class_OpenSimplexNoise_method_get_noise_1d>` **(** :ref:`float<class_float>` x **)** |const| |
  44. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`float<class_float>` | :ref:`get_noise_2d<class_OpenSimplexNoise_method_get_noise_2d>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)** |const| |
  46. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`float<class_float>` | :ref:`get_noise_2dv<class_OpenSimplexNoise_method_get_noise_2dv>` **(** :ref:`Vector2<class_Vector2>` pos **)** |const| |
  48. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_noise_3d<class_OpenSimplexNoise_method_get_noise_3d>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |const| |
  50. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`float<class_float>` | :ref:`get_noise_3dv<class_OpenSimplexNoise_method_get_noise_3dv>` **(** :ref:`Vector3<class_Vector3>` pos **)** |const| |
  52. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`float<class_float>` | :ref:`get_noise_4d<class_OpenSimplexNoise_method_get_noise_4d>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)** |const| |
  54. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Image<class_Image>` | :ref:`get_seamless_image<class_OpenSimplexNoise_method_get_seamless_image>` **(** :ref:`int<class_int>` size **)** |const| |
  56. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. Property Descriptions
  58. ---------------------
  59. .. _class_OpenSimplexNoise_property_lacunarity:
  60. - :ref:`float<class_float>` **lacunarity**
  61. +-----------+-----------------------+
  62. | *Default* | ``2.0`` |
  63. +-----------+-----------------------+
  64. | *Setter* | set_lacunarity(value) |
  65. +-----------+-----------------------+
  66. | *Getter* | get_lacunarity() |
  67. +-----------+-----------------------+
  68. Difference in period between :ref:`octaves<class_OpenSimplexNoise_property_octaves>`.
  69. ----
  70. .. _class_OpenSimplexNoise_property_octaves:
  71. - :ref:`int<class_int>` **octaves**
  72. +-----------+--------------------+
  73. | *Default* | ``3`` |
  74. +-----------+--------------------+
  75. | *Setter* | set_octaves(value) |
  76. +-----------+--------------------+
  77. | *Getter* | get_octaves() |
  78. +-----------+--------------------+
  79. Number of OpenSimplex noise layers that are sampled to get the fractal noise. Higher values result in more detailed noise but take more time to generate.
  80. **Note:** The maximum allowed value is 9.
  81. ----
  82. .. _class_OpenSimplexNoise_property_period:
  83. - :ref:`float<class_float>` **period**
  84. +-----------+-------------------+
  85. | *Default* | ``64.0`` |
  86. +-----------+-------------------+
  87. | *Setter* | set_period(value) |
  88. +-----------+-------------------+
  89. | *Getter* | get_period() |
  90. +-----------+-------------------+
  91. Period of the base octave. A lower period results in a higher-frequency noise (more value changes across the same distance).
  92. ----
  93. .. _class_OpenSimplexNoise_property_persistence:
  94. - :ref:`float<class_float>` **persistence**
  95. +-----------+------------------------+
  96. | *Default* | ``0.5`` |
  97. +-----------+------------------------+
  98. | *Setter* | set_persistence(value) |
  99. +-----------+------------------------+
  100. | *Getter* | get_persistence() |
  101. +-----------+------------------------+
  102. Contribution factor of the different octaves. A ``persistence`` value of 1 means all the octaves have the same contribution, a value of 0.5 means each octave contributes half as much as the previous one.
  103. ----
  104. .. _class_OpenSimplexNoise_property_seed:
  105. - :ref:`int<class_int>` **seed**
  106. +-----------+-----------------+
  107. | *Default* | ``0`` |
  108. +-----------+-----------------+
  109. | *Setter* | set_seed(value) |
  110. +-----------+-----------------+
  111. | *Getter* | get_seed() |
  112. +-----------+-----------------+
  113. Seed used to generate random values, different seeds will generate different noise maps.
  114. Method Descriptions
  115. -------------------
  116. .. _class_OpenSimplexNoise_method_get_image:
  117. - :ref:`Image<class_Image>` **get_image** **(** :ref:`int<class_int>` width, :ref:`int<class_int>` height, :ref:`Vector2<class_Vector2>` noise_offset=Vector2( 0, 0 ) **)** |const|
  118. Generate a noise image in :ref:`Image.FORMAT_L8<class_Image_constant_FORMAT_L8>` format with the requested ``width`` and ``height``, based on the current noise parameters. If ``noise_offset`` is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
  119. ----
  120. .. _class_OpenSimplexNoise_method_get_noise_1d:
  121. - :ref:`float<class_float>` **get_noise_1d** **(** :ref:`float<class_float>` x **)** |const|
  122. Returns the 1D noise value ``[-1,1]`` at the given x-coordinate.
  123. **Note:** This method actually returns the 2D noise value ``[-1,1]`` with fixed y-coordinate value 0.0.
  124. ----
  125. .. _class_OpenSimplexNoise_method_get_noise_2d:
  126. - :ref:`float<class_float>` **get_noise_2d** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)** |const|
  127. Returns the 2D noise value ``[-1,1]`` at the given position.
  128. ----
  129. .. _class_OpenSimplexNoise_method_get_noise_2dv:
  130. - :ref:`float<class_float>` **get_noise_2dv** **(** :ref:`Vector2<class_Vector2>` pos **)** |const|
  131. Returns the 2D noise value ``[-1,1]`` at the given position.
  132. ----
  133. .. _class_OpenSimplexNoise_method_get_noise_3d:
  134. - :ref:`float<class_float>` **get_noise_3d** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z **)** |const|
  135. Returns the 3D noise value ``[-1,1]`` at the given position.
  136. ----
  137. .. _class_OpenSimplexNoise_method_get_noise_3dv:
  138. - :ref:`float<class_float>` **get_noise_3dv** **(** :ref:`Vector3<class_Vector3>` pos **)** |const|
  139. Returns the 3D noise value ``[-1,1]`` at the given position.
  140. ----
  141. .. _class_OpenSimplexNoise_method_get_noise_4d:
  142. - :ref:`float<class_float>` **get_noise_4d** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` z, :ref:`float<class_float>` w **)** |const|
  143. Returns the 4D noise value ``[-1,1]`` at the given position.
  144. ----
  145. .. _class_OpenSimplexNoise_method_get_seamless_image:
  146. - :ref:`Image<class_Image>` **get_seamless_image** **(** :ref:`int<class_int>` size **)** |const|
  147. Generate a tileable noise image in :ref:`Image.FORMAT_L8<class_Image_constant_FORMAT_L8>` format, based on the current noise parameters. Generated seamless images are always square (``size`` × ``size``).
  148. **Note:** Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise.
  149. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  150. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  151. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`