class_multimesh.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the MultiMesh.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_MultiMesh:
  6. MultiMesh
  7. =========
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Provides high performance mesh instancing.
  13. Properties
  14. ----------
  15. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  16. | :ref:`ColorFormat<enum_MultiMesh_ColorFormat>` | :ref:`color_format<class_MultiMesh_property_color_format>` |
  17. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  18. | :ref:`CustomDataFormat<enum_MultiMesh_CustomDataFormat>` | :ref:`custom_data_format<class_MultiMesh_property_custom_data_format>` |
  19. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`instance_count<class_MultiMesh_property_instance_count>` |
  21. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  22. | :ref:`Mesh<class_Mesh>` | :ref:`mesh<class_MultiMesh_property_mesh>` |
  23. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  24. | :ref:`TransformFormat<enum_MultiMesh_TransformFormat>` | :ref:`transform_format<class_MultiMesh_property_transform_format>` |
  25. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`visible_instance_count<class_MultiMesh_property_visible_instance_count>` |
  27. +----------------------------------------------------------+--------------------------------------------------------------------------------+
  28. Methods
  29. -------
  30. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`AABB<class_AABB>` | :ref:`get_aabb<class_MultiMesh_method_get_aabb>` **(** **)** const |
  32. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Color<class_Color>` | :ref:`get_instance_color<class_MultiMesh_method_get_instance_color>` **(** :ref:`int<class_int>` instance **)** const |
  34. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Color<class_Color>` | :ref:`get_instance_custom_data<class_MultiMesh_method_get_instance_custom_data>` **(** :ref:`int<class_int>` instance **)** const |
  36. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Transform<class_Transform>` | :ref:`get_instance_transform<class_MultiMesh_method_get_instance_transform>` **(** :ref:`int<class_int>` instance **)** const |
  38. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Transform2D<class_Transform2D>` | :ref:`get_instance_transform_2d<class_MultiMesh_method_get_instance_transform_2d>` **(** :ref:`int<class_int>` instance **)** const |
  40. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_instance_color<class_MultiMesh_method_set_instance_color>` **(** :ref:`int<class_int>` instance, :ref:`Color<class_Color>` color **)** |
  42. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_instance_custom_data<class_MultiMesh_method_set_instance_custom_data>` **(** :ref:`int<class_int>` instance, :ref:`Color<class_Color>` custom_data **)** |
  44. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_instance_transform<class_MultiMesh_method_set_instance_transform>` **(** :ref:`int<class_int>` instance, :ref:`Transform<class_Transform>` transform **)** |
  46. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_instance_transform_2d<class_MultiMesh_method_set_instance_transform_2d>` **(** :ref:`int<class_int>` instance, :ref:`Transform2D<class_Transform2D>` transform **)** |
  48. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. Enumerations
  50. ------------
  51. .. _enum_MultiMesh_TransformFormat:
  52. .. _class_MultiMesh_constant_TRANSFORM_2D:
  53. .. _class_MultiMesh_constant_TRANSFORM_3D:
  54. enum **TransformFormat**:
  55. - **TRANSFORM_2D** = **0** --- Use this when using 2D transforms.
  56. - **TRANSFORM_3D** = **1** --- Use this when using 3D transforms.
  57. ----
  58. .. _enum_MultiMesh_ColorFormat:
  59. .. _class_MultiMesh_constant_COLOR_NONE:
  60. .. _class_MultiMesh_constant_COLOR_8BIT:
  61. .. _class_MultiMesh_constant_COLOR_FLOAT:
  62. enum **ColorFormat**:
  63. - **COLOR_NONE** = **0** --- Use when you are not using per-instance :ref:`Color<class_Color>`\ s.
  64. - **COLOR_8BIT** = **1** --- Compress :ref:`Color<class_Color>` data into 8 bits when passing to shader. This uses less memory and can be faster, but the :ref:`Color<class_Color>` loses precision.
  65. - **COLOR_FLOAT** = **2** --- The :ref:`Color<class_Color>` passed into :ref:`set_instance_color<class_MultiMesh_method_set_instance_color>` will use 4 floats. Use this for highest precision :ref:`Color<class_Color>`.
  66. ----
  67. .. _enum_MultiMesh_CustomDataFormat:
  68. .. _class_MultiMesh_constant_CUSTOM_DATA_NONE:
  69. .. _class_MultiMesh_constant_CUSTOM_DATA_8BIT:
  70. .. _class_MultiMesh_constant_CUSTOM_DATA_FLOAT:
  71. enum **CustomDataFormat**:
  72. - **CUSTOM_DATA_NONE** = **0** --- Use when you are not using per-instance custom data.
  73. - **CUSTOM_DATA_8BIT** = **1** --- Compress custom_data into 8 bits when passing to shader. This uses less memory and can be faster, but loses precision.
  74. - **CUSTOM_DATA_FLOAT** = **2** --- The :ref:`Color<class_Color>` passed into :ref:`set_instance_custom_data<class_MultiMesh_method_set_instance_custom_data>` will use 4 floats. Use this for highest precision.
  75. Description
  76. -----------
  77. MultiMesh provides low level mesh instancing. Drawing thousands of :ref:`MeshInstance<class_MeshInstance>` nodes can be slow because each object is submitted to the GPU to be drawn individually.
  78. MultiMesh is much faster because it can draw thousands of instances with a single draw call, resulting in less API overhead.
  79. As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object).
  80. Since instances may have any behavior, the AABB used for visibility must be provided by the user.
  81. Tutorials
  82. ---------
  83. - :doc:`../tutorials/3d/vertex_animation/animating_thousands_of_fish`
  84. Property Descriptions
  85. ---------------------
  86. .. _class_MultiMesh_property_color_format:
  87. - :ref:`ColorFormat<enum_MultiMesh_ColorFormat>` **color_format**
  88. +----------+-------------------------+
  89. | *Setter* | set_color_format(value) |
  90. +----------+-------------------------+
  91. | *Getter* | get_color_format() |
  92. +----------+-------------------------+
  93. Format of colors in color array that gets passed to shader.
  94. ----
  95. .. _class_MultiMesh_property_custom_data_format:
  96. - :ref:`CustomDataFormat<enum_MultiMesh_CustomDataFormat>` **custom_data_format**
  97. +----------+-------------------------------+
  98. | *Setter* | set_custom_data_format(value) |
  99. +----------+-------------------------------+
  100. | *Getter* | get_custom_data_format() |
  101. +----------+-------------------------------+
  102. Format of custom data in custom data array that gets passed to shader.
  103. ----
  104. .. _class_MultiMesh_property_instance_count:
  105. - :ref:`int<class_int>` **instance_count**
  106. +----------+---------------------------+
  107. | *Setter* | set_instance_count(value) |
  108. +----------+---------------------------+
  109. | *Getter* | get_instance_count() |
  110. +----------+---------------------------+
  111. Number of instances that will get drawn.
  112. ----
  113. .. _class_MultiMesh_property_mesh:
  114. - :ref:`Mesh<class_Mesh>` **mesh**
  115. +----------+-----------------+
  116. | *Setter* | set_mesh(value) |
  117. +----------+-----------------+
  118. | *Getter* | get_mesh() |
  119. +----------+-----------------+
  120. Mesh to be drawn.
  121. ----
  122. .. _class_MultiMesh_property_transform_format:
  123. - :ref:`TransformFormat<enum_MultiMesh_TransformFormat>` **transform_format**
  124. +----------+-----------------------------+
  125. | *Setter* | set_transform_format(value) |
  126. +----------+-----------------------------+
  127. | *Getter* | get_transform_format() |
  128. +----------+-----------------------------+
  129. Format of transform used to transform mesh, either 2D or 3D.
  130. ----
  131. .. _class_MultiMesh_property_visible_instance_count:
  132. - :ref:`int<class_int>` **visible_instance_count**
  133. +----------+-----------------------------------+
  134. | *Setter* | set_visible_instance_count(value) |
  135. +----------+-----------------------------------+
  136. | *Getter* | get_visible_instance_count() |
  137. +----------+-----------------------------------+
  138. Method Descriptions
  139. -------------------
  140. .. _class_MultiMesh_method_get_aabb:
  141. - :ref:`AABB<class_AABB>` **get_aabb** **(** **)** const
  142. Returns the visibility AABB.
  143. ----
  144. .. _class_MultiMesh_method_get_instance_color:
  145. - :ref:`Color<class_Color>` **get_instance_color** **(** :ref:`int<class_int>` instance **)** const
  146. Get the color of a specific instance.
  147. ----
  148. .. _class_MultiMesh_method_get_instance_custom_data:
  149. - :ref:`Color<class_Color>` **get_instance_custom_data** **(** :ref:`int<class_int>` instance **)** const
  150. Returns the custom data that has been set for a specific instance.
  151. ----
  152. .. _class_MultiMesh_method_get_instance_transform:
  153. - :ref:`Transform<class_Transform>` **get_instance_transform** **(** :ref:`int<class_int>` instance **)** const
  154. Returns the :ref:`Transform<class_Transform>` of a specific instance.
  155. ----
  156. .. _class_MultiMesh_method_get_instance_transform_2d:
  157. - :ref:`Transform2D<class_Transform2D>` **get_instance_transform_2d** **(** :ref:`int<class_int>` instance **)** const
  158. Returns the :ref:`Transform2D<class_Transform2D>` of a specific instance.
  159. ----
  160. .. _class_MultiMesh_method_set_instance_color:
  161. - void **set_instance_color** **(** :ref:`int<class_int>` instance, :ref:`Color<class_Color>` color **)**
  162. Set the color of a specific instance.
  163. For the color to take effect, ensure that :ref:`color_format<class_MultiMesh_property_color_format>` is non-``null`` on the ``MultiMesh`` and :ref:`SpatialMaterial.vertex_color_use_as_albedo<class_SpatialMaterial_property_vertex_color_use_as_albedo>` is ``true`` on the material.
  164. ----
  165. .. _class_MultiMesh_method_set_instance_custom_data:
  166. - void **set_instance_custom_data** **(** :ref:`int<class_int>` instance, :ref:`Color<class_Color>` custom_data **)**
  167. Set custom data for a specific instance. Although :ref:`Color<class_Color>` is used, it is just a container for 4 numbers.
  168. ----
  169. .. _class_MultiMesh_method_set_instance_transform:
  170. - void **set_instance_transform** **(** :ref:`int<class_int>` instance, :ref:`Transform<class_Transform>` transform **)**
  171. Set the transform for a specific instance.
  172. ----
  173. .. _class_MultiMesh_method_set_instance_transform_2d:
  174. - void **set_instance_transform_2d** **(** :ref:`int<class_int>` instance, :ref:`Transform2D<class_Transform2D>` transform **)**