class_decal.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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 Decal.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Decal:
  6. Decal
  7. =====
  8. **Inherits:** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Node that projects a texture onto a :ref:`MeshInstance3D<class_MeshInstance3D>`.
  10. Description
  11. -----------
  12. ``Decal``\ s are used to project a texture onto a :ref:`Mesh<class_Mesh>` in the scene. Use Decals to add detail to a scene without affecting the underlying :ref:`Mesh<class_Mesh>`. They are often used to add weathering to building, add dirt or mud to the ground, or add variety to props. Decals can be moved at any time, making them suitable for things like blob shadows or laser sight dots.
  13. They are made of an :ref:`AABB<class_AABB>` and a group of :ref:`Texture2D<class_Texture2D>`\ s specifying :ref:`Color<class_Color>`, normal, ORM (ambient occlusion, roughness, metallic), and emission. Decals are projected within their :ref:`AABB<class_AABB>` so altering the orientation of the Decal affects the direction in which they are projected. By default, Decals are projected down (i.e. from positive Y to negative Y).
  14. The :ref:`Texture2D<class_Texture2D>`\ s associated with the Decal are automatically stored in a texture atlas which is used for drawing the decals so all decals can be drawn at once. Godot uses clustered decals, meaning they are stored in cluster data and drawn when the mesh is drawn, they are not drawn as a post-processing effect after.
  15. \ **Note:** Decals cannot affect an underlying material's transparency, regardless of its transparency mode (alpha blend, alpha scissor, alpha hash, opaque pre-pass). This means translucent or transparent areas of a material will remain translucent or transparent even if an opaque decal is applied on them.
  16. Properties
  17. ----------
  18. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  19. | :ref:`float<class_float>` | :ref:`albedo_mix<class_Decal_property_albedo_mix>` | ``1.0`` |
  20. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  21. | :ref:`int<class_int>` | :ref:`cull_mask<class_Decal_property_cull_mask>` | ``1048575`` |
  22. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  23. | :ref:`float<class_float>` | :ref:`distance_fade_begin<class_Decal_property_distance_fade_begin>` | ``40.0`` |
  24. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  25. | :ref:`bool<class_bool>` | :ref:`distance_fade_enabled<class_Decal_property_distance_fade_enabled>` | ``false`` |
  26. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  27. | :ref:`float<class_float>` | :ref:`distance_fade_length<class_Decal_property_distance_fade_length>` | ``10.0`` |
  28. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  29. | :ref:`float<class_float>` | :ref:`emission_energy<class_Decal_property_emission_energy>` | ``1.0`` |
  30. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  31. | :ref:`Vector3<class_Vector3>` | :ref:`extents<class_Decal_property_extents>` | ``Vector3(1, 1, 1)`` |
  32. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  33. | :ref:`float<class_float>` | :ref:`lower_fade<class_Decal_property_lower_fade>` | ``0.3`` |
  34. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  35. | :ref:`Color<class_Color>` | :ref:`modulate<class_Decal_property_modulate>` | ``Color(1, 1, 1, 1)`` |
  36. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  37. | :ref:`float<class_float>` | :ref:`normal_fade<class_Decal_property_normal_fade>` | ``0.0`` |
  38. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  39. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_albedo<class_Decal_property_texture_albedo>` | |
  40. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  41. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_emission<class_Decal_property_texture_emission>` | |
  42. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  43. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_normal<class_Decal_property_texture_normal>` | |
  44. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  45. | :ref:`Texture2D<class_Texture2D>` | :ref:`texture_orm<class_Decal_property_texture_orm>` | |
  46. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  47. | :ref:`float<class_float>` | :ref:`upper_fade<class_Decal_property_upper_fade>` | ``0.3`` |
  48. +-----------------------------------+--------------------------------------------------------------------------+-----------------------+
  49. Methods
  50. -------
  51. +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_texture<class_Decal_method_get_texture>` **(** :ref:`DecalTexture<enum_Decal_DecalTexture>` type **)** |const| |
  53. +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_texture<class_Decal_method_set_texture>` **(** :ref:`DecalTexture<enum_Decal_DecalTexture>` type, :ref:`Texture2D<class_Texture2D>` texture **)** |
  55. +-----------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. Enumerations
  57. ------------
  58. .. _enum_Decal_DecalTexture:
  59. .. _class_Decal_constant_TEXTURE_ALBEDO:
  60. .. _class_Decal_constant_TEXTURE_NORMAL:
  61. .. _class_Decal_constant_TEXTURE_ORM:
  62. .. _class_Decal_constant_TEXTURE_EMISSION:
  63. .. _class_Decal_constant_TEXTURE_MAX:
  64. enum **DecalTexture**:
  65. - **TEXTURE_ALBEDO** = **0** --- :ref:`Texture2D<class_Texture2D>` corresponding to :ref:`texture_albedo<class_Decal_property_texture_albedo>`.
  66. - **TEXTURE_NORMAL** = **1** --- :ref:`Texture2D<class_Texture2D>` corresponding to :ref:`texture_normal<class_Decal_property_texture_normal>`.
  67. - **TEXTURE_ORM** = **2** --- :ref:`Texture2D<class_Texture2D>` corresponding to :ref:`texture_orm<class_Decal_property_texture_orm>`.
  68. - **TEXTURE_EMISSION** = **3** --- :ref:`Texture2D<class_Texture2D>` corresponding to :ref:`texture_emission<class_Decal_property_texture_emission>`.
  69. - **TEXTURE_MAX** = **4** --- Max size of :ref:`DecalTexture<enum_Decal_DecalTexture>` enum.
  70. Property Descriptions
  71. ---------------------
  72. .. _class_Decal_property_albedo_mix:
  73. - :ref:`float<class_float>` **albedo_mix**
  74. +-----------+-----------------------+
  75. | *Default* | ``1.0`` |
  76. +-----------+-----------------------+
  77. | *Setter* | set_albedo_mix(value) |
  78. +-----------+-----------------------+
  79. | *Getter* | get_albedo_mix() |
  80. +-----------+-----------------------+
  81. Blends the albedo :ref:`Color<class_Color>` of the decal with albedo :ref:`Color<class_Color>` of the underlying mesh.
  82. ----
  83. .. _class_Decal_property_cull_mask:
  84. - :ref:`int<class_int>` **cull_mask**
  85. +-----------+----------------------+
  86. | *Default* | ``1048575`` |
  87. +-----------+----------------------+
  88. | *Setter* | set_cull_mask(value) |
  89. +-----------+----------------------+
  90. | *Getter* | get_cull_mask() |
  91. +-----------+----------------------+
  92. Specifies which :ref:`VisualInstance3D.layers<class_VisualInstance3D_property_layers>` this decal will project on. By default, Decals affect all layers. This is used so you can specify which types of objects receive the Decal and which do not. This is especially useful so you can ensure that dynamic objects don't accidentally receive a Decal intended for the terrain under them.
  93. ----
  94. .. _class_Decal_property_distance_fade_begin:
  95. - :ref:`float<class_float>` **distance_fade_begin**
  96. +-----------+--------------------------------+
  97. | *Default* | ``40.0`` |
  98. +-----------+--------------------------------+
  99. | *Setter* | set_distance_fade_begin(value) |
  100. +-----------+--------------------------------+
  101. | *Getter* | get_distance_fade_begin() |
  102. +-----------+--------------------------------+
  103. The distance from the camera at which the Decal begins to fade away (in 3D units).
  104. ----
  105. .. _class_Decal_property_distance_fade_enabled:
  106. - :ref:`bool<class_bool>` **distance_fade_enabled**
  107. +-----------+---------------------------------+
  108. | *Default* | ``false`` |
  109. +-----------+---------------------------------+
  110. | *Setter* | set_enable_distance_fade(value) |
  111. +-----------+---------------------------------+
  112. | *Getter* | is_distance_fade_enabled() |
  113. +-----------+---------------------------------+
  114. If ``true``, decals will smoothly fade away when far from the active :ref:`Camera3D<class_Camera3D>` starting at :ref:`distance_fade_begin<class_Decal_property_distance_fade_begin>`. The Decal will fade out over :ref:`distance_fade_begin<class_Decal_property_distance_fade_begin>` + :ref:`distance_fade_length<class_Decal_property_distance_fade_length>`, after which it will be culled and not sent to the shader at all. Use this to reduce the number of active Decals in a scene and thus improve performance.
  115. ----
  116. .. _class_Decal_property_distance_fade_length:
  117. - :ref:`float<class_float>` **distance_fade_length**
  118. +-----------+---------------------------------+
  119. | *Default* | ``10.0`` |
  120. +-----------+---------------------------------+
  121. | *Setter* | set_distance_fade_length(value) |
  122. +-----------+---------------------------------+
  123. | *Getter* | get_distance_fade_length() |
  124. +-----------+---------------------------------+
  125. The distance over which the Decal fades (in 3D units). The Decal becomes slowly more transparent over this distance and is completely invisible at the end.
  126. ----
  127. .. _class_Decal_property_emission_energy:
  128. - :ref:`float<class_float>` **emission_energy**
  129. +-----------+----------------------------+
  130. | *Default* | ``1.0`` |
  131. +-----------+----------------------------+
  132. | *Setter* | set_emission_energy(value) |
  133. +-----------+----------------------------+
  134. | *Getter* | get_emission_energy() |
  135. +-----------+----------------------------+
  136. Energy multiplier for the emission texture. This will make the decal emit light at a higher intensity.
  137. ----
  138. .. _class_Decal_property_extents:
  139. - :ref:`Vector3<class_Vector3>` **extents**
  140. +-----------+----------------------+
  141. | *Default* | ``Vector3(1, 1, 1)`` |
  142. +-----------+----------------------+
  143. | *Setter* | set_extents(value) |
  144. +-----------+----------------------+
  145. | *Getter* | get_extents() |
  146. +-----------+----------------------+
  147. Sets the size of the :ref:`AABB<class_AABB>` used by the decal. The AABB goes from ``-extents`` to ``extents``.
  148. ----
  149. .. _class_Decal_property_lower_fade:
  150. - :ref:`float<class_float>` **lower_fade**
  151. +-----------+-----------------------+
  152. | *Default* | ``0.3`` |
  153. +-----------+-----------------------+
  154. | *Setter* | set_lower_fade(value) |
  155. +-----------+-----------------------+
  156. | *Getter* | get_lower_fade() |
  157. +-----------+-----------------------+
  158. Sets the curve over which the decal will fade as the surface gets further from the center of the :ref:`AABB<class_AABB>`. Only positive values are valid (negative values will be clamped to ``0.0``).
  159. ----
  160. .. _class_Decal_property_modulate:
  161. - :ref:`Color<class_Color>` **modulate**
  162. +-----------+-----------------------+
  163. | *Default* | ``Color(1, 1, 1, 1)`` |
  164. +-----------+-----------------------+
  165. | *Setter* | set_modulate(value) |
  166. +-----------+-----------------------+
  167. | *Getter* | get_modulate() |
  168. +-----------+-----------------------+
  169. Changes the :ref:`Color<class_Color>` of the Decal by multiplying it with this value.
  170. ----
  171. .. _class_Decal_property_normal_fade:
  172. - :ref:`float<class_float>` **normal_fade**
  173. +-----------+------------------------+
  174. | *Default* | ``0.0`` |
  175. +-----------+------------------------+
  176. | *Setter* | set_normal_fade(value) |
  177. +-----------+------------------------+
  178. | *Getter* | get_normal_fade() |
  179. +-----------+------------------------+
  180. Fades the Decal if the angle between the Decal's :ref:`AABB<class_AABB>` and the target surface becomes too large. A value of ``0`` projects the Decal regardless of angle, a value of ``1`` limits the Decal to surfaces that are nearly perpendicular.
  181. ----
  182. .. _class_Decal_property_texture_albedo:
  183. - :ref:`Texture2D<class_Texture2D>` **texture_albedo**
  184. +----------+--------------------+
  185. | *Setter* | set_texture(value) |
  186. +----------+--------------------+
  187. | *Getter* | get_texture() |
  188. +----------+--------------------+
  189. :ref:`Texture2D<class_Texture2D>` with the base :ref:`Color<class_Color>` of the Decal. Either this or the :ref:`texture_emission<class_Decal_property_texture_emission>` must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
  190. \ **Note:** Unlike :ref:`BaseMaterial3D<class_BaseMaterial3D>` whose filter mode can be adjusted on a per-material basis, the filter mode for ``Decal`` textures is set globally with :ref:`ProjectSettings.rendering/textures/decals/filter<class_ProjectSettings_property_rendering/textures/decals/filter>`.
  191. ----
  192. .. _class_Decal_property_texture_emission:
  193. - :ref:`Texture2D<class_Texture2D>` **texture_emission**
  194. +----------+--------------------+
  195. | *Setter* | set_texture(value) |
  196. +----------+--------------------+
  197. | *Getter* | get_texture() |
  198. +----------+--------------------+
  199. :ref:`Texture2D<class_Texture2D>` with the emission :ref:`Color<class_Color>` of the Decal. Either this or the :ref:`texture_emission<class_Decal_property_texture_emission>` must be set for the Decal to be visible. Use the alpha channel like a mask to smoothly blend the edges of the decal with the underlying object.
  200. \ **Note:** Unlike :ref:`BaseMaterial3D<class_BaseMaterial3D>` whose filter mode can be adjusted on a per-material basis, the filter mode for ``Decal`` textures is set globally with :ref:`ProjectSettings.rendering/textures/decals/filter<class_ProjectSettings_property_rendering/textures/decals/filter>`.
  201. ----
  202. .. _class_Decal_property_texture_normal:
  203. - :ref:`Texture2D<class_Texture2D>` **texture_normal**
  204. +----------+--------------------+
  205. | *Setter* | set_texture(value) |
  206. +----------+--------------------+
  207. | *Getter* | get_texture() |
  208. +----------+--------------------+
  209. :ref:`Texture2D<class_Texture2D>` with the per-pixel normal map for the decal. Use this to add extra detail to decals.
  210. \ **Note:** Unlike :ref:`BaseMaterial3D<class_BaseMaterial3D>` whose filter mode can be adjusted on a per-material basis, the filter mode for ``Decal`` textures is set globally with :ref:`ProjectSettings.rendering/textures/decals/filter<class_ProjectSettings_property_rendering/textures/decals/filter>`.
  211. ----
  212. .. _class_Decal_property_texture_orm:
  213. - :ref:`Texture2D<class_Texture2D>` **texture_orm**
  214. +----------+--------------------+
  215. | *Setter* | set_texture(value) |
  216. +----------+--------------------+
  217. | *Getter* | get_texture() |
  218. +----------+--------------------+
  219. :ref:`Texture2D<class_Texture2D>` storing ambient occlusion, roughness, and metallic for the decal. Use this to add extra detail to decals.
  220. \ **Note:** Unlike :ref:`BaseMaterial3D<class_BaseMaterial3D>` whose filter mode can be adjusted on a per-material basis, the filter mode for ``Decal`` textures is set globally with :ref:`ProjectSettings.rendering/textures/decals/filter<class_ProjectSettings_property_rendering/textures/decals/filter>`.
  221. ----
  222. .. _class_Decal_property_upper_fade:
  223. - :ref:`float<class_float>` **upper_fade**
  224. +-----------+-----------------------+
  225. | *Default* | ``0.3`` |
  226. +-----------+-----------------------+
  227. | *Setter* | set_upper_fade(value) |
  228. +-----------+-----------------------+
  229. | *Getter* | get_upper_fade() |
  230. +-----------+-----------------------+
  231. Sets the curve over which the decal will fade as the surface gets further from the center of the :ref:`AABB<class_AABB>`. Only positive values are valid (negative values will be clamped to ``0.0``).
  232. Method Descriptions
  233. -------------------
  234. .. _class_Decal_method_get_texture:
  235. - :ref:`Texture2D<class_Texture2D>` **get_texture** **(** :ref:`DecalTexture<enum_Decal_DecalTexture>` type **)** |const|
  236. Returns the :ref:`Texture2D<class_Texture2D>` associated with the specified :ref:`DecalTexture<enum_Decal_DecalTexture>`. This is a convenience method, in most cases you should access the texture directly.
  237. For example, instead of ``albedo_tex = $Decal.get_texture(Decal.TEXTURE_ALBEDO)``, use ``albedo_tex = $Decal.texture_albedo``.
  238. One case where this is better than accessing the texture directly is when you want to copy one Decal's textures to another. For example:
  239. .. tabs::
  240. .. code-tab:: gdscript
  241. for i in Decal.TEXTURE_MAX:
  242. $NewDecal.set_texture(i, $OldDecal.get_texture(i))
  243. .. code-tab:: csharp
  244. for (int i = 0; i < (int)Decal.DecalTexture.Max; i++)
  245. {
  246. GetNode<Decal>("NewDecal").SetTexture(i, GetNode<Decal>("OldDecal").GetTexture(i));
  247. }
  248. ----
  249. .. _class_Decal_method_set_texture:
  250. - void **set_texture** **(** :ref:`DecalTexture<enum_Decal_DecalTexture>` type, :ref:`Texture2D<class_Texture2D>` texture **)**
  251. Sets the :ref:`Texture2D<class_Texture2D>` associated with the specified :ref:`DecalTexture<enum_Decal_DecalTexture>`. This is a convenience method, in most cases you should access the texture directly.
  252. For example, instead of ``$Decal.set_texture(Decal.TEXTURE_ALBEDO, albedo_tex)``, use ``$Decal.texture_albedo = albedo_tex``.
  253. One case where this is better than accessing the texture directly is when you want to copy one Decal's textures to another. For example:
  254. .. tabs::
  255. .. code-tab:: gdscript
  256. for i in Decal.TEXTURE_MAX:
  257. $NewDecal.set_texture(i, $OldDecal.get_texture(i))
  258. .. code-tab:: csharp
  259. for (int i = 0; i < (int)Decal.DecalTexture.Max; i++)
  260. {
  261. GetNode<Decal>("NewDecal").SetTexture(i, GetNode<Decal>("OldDecal").GetTexture(i));
  262. }
  263. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  264. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  265. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  266. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  267. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  268. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`