class_light.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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 Light.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Light:
  6. Light
  7. =====
  8. **Inherits:** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`DirectionalLight<class_DirectionalLight>`, :ref:`OmniLight<class_OmniLight>`, :ref:`SpotLight<class_SpotLight>`
  10. **Category:** Core
  11. Brief Description
  12. -----------------
  13. Provides a base class for different kinds of light nodes.
  14. Properties
  15. ----------
  16. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  17. | :ref:`bool<class_bool>` | :ref:`editor_only<class_Light_property_editor_only>` | false |
  18. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  19. | :ref:`BakeMode<enum_Light_BakeMode>` | :ref:`light_bake_mode<class_Light_property_light_bake_mode>` | 1 |
  20. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  21. | :ref:`Color<class_Color>` | :ref:`light_color<class_Light_property_light_color>` | Color( 1, 1, 1, 1 ) |
  22. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  23. | :ref:`int<class_int>` | :ref:`light_cull_mask<class_Light_property_light_cull_mask>` | 4294967295 |
  24. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  25. | :ref:`float<class_float>` | :ref:`light_energy<class_Light_property_light_energy>` | 1.0 |
  26. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  27. | :ref:`float<class_float>` | :ref:`light_indirect_energy<class_Light_property_light_indirect_energy>` | 1.0 |
  28. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  29. | :ref:`bool<class_bool>` | :ref:`light_negative<class_Light_property_light_negative>` | false |
  30. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  31. | :ref:`float<class_float>` | :ref:`light_specular<class_Light_property_light_specular>` | 0.5 |
  32. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  33. | :ref:`float<class_float>` | :ref:`shadow_bias<class_Light_property_shadow_bias>` | 0.15 |
  34. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  35. | :ref:`Color<class_Color>` | :ref:`shadow_color<class_Light_property_shadow_color>` | Color( 0, 0, 0, 1 ) |
  36. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  37. | :ref:`float<class_float>` | :ref:`shadow_contact<class_Light_property_shadow_contact>` | 0.0 |
  38. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  39. | :ref:`bool<class_bool>` | :ref:`shadow_enabled<class_Light_property_shadow_enabled>` | false |
  40. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  41. | :ref:`bool<class_bool>` | :ref:`shadow_reverse_cull_face<class_Light_property_shadow_reverse_cull_face>` | false |
  42. +--------------------------------------+--------------------------------------------------------------------------------+---------------------+
  43. Methods
  44. -------
  45. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_param<class_Light_method_get_param>` **(** :ref:`Param<enum_Light_Param>` param **)** const |
  47. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_param<class_Light_method_set_param>` **(** :ref:`Param<enum_Light_Param>` param, :ref:`float<class_float>` value **)** |
  49. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------+
  50. Enumerations
  51. ------------
  52. .. _enum_Light_Param:
  53. .. _class_Light_constant_PARAM_ENERGY:
  54. .. _class_Light_constant_PARAM_INDIRECT_ENERGY:
  55. .. _class_Light_constant_PARAM_SPECULAR:
  56. .. _class_Light_constant_PARAM_RANGE:
  57. .. _class_Light_constant_PARAM_ATTENUATION:
  58. .. _class_Light_constant_PARAM_SPOT_ANGLE:
  59. .. _class_Light_constant_PARAM_SPOT_ATTENUATION:
  60. .. _class_Light_constant_PARAM_CONTACT_SHADOW_SIZE:
  61. .. _class_Light_constant_PARAM_SHADOW_MAX_DISTANCE:
  62. .. _class_Light_constant_PARAM_SHADOW_SPLIT_1_OFFSET:
  63. .. _class_Light_constant_PARAM_SHADOW_SPLIT_2_OFFSET:
  64. .. _class_Light_constant_PARAM_SHADOW_SPLIT_3_OFFSET:
  65. .. _class_Light_constant_PARAM_SHADOW_NORMAL_BIAS:
  66. .. _class_Light_constant_PARAM_SHADOW_BIAS:
  67. .. _class_Light_constant_PARAM_SHADOW_BIAS_SPLIT_SCALE:
  68. .. _class_Light_constant_PARAM_MAX:
  69. enum **Param**:
  70. - **PARAM_ENERGY** = **0**
  71. - **PARAM_INDIRECT_ENERGY** = **1**
  72. - **PARAM_SPECULAR** = **2**
  73. - **PARAM_RANGE** = **3**
  74. - **PARAM_ATTENUATION** = **4**
  75. - **PARAM_SPOT_ANGLE** = **5**
  76. - **PARAM_SPOT_ATTENUATION** = **6**
  77. - **PARAM_CONTACT_SHADOW_SIZE** = **7**
  78. - **PARAM_SHADOW_MAX_DISTANCE** = **8**
  79. - **PARAM_SHADOW_SPLIT_1_OFFSET** = **9**
  80. - **PARAM_SHADOW_SPLIT_2_OFFSET** = **10**
  81. - **PARAM_SHADOW_SPLIT_3_OFFSET** = **11**
  82. - **PARAM_SHADOW_NORMAL_BIAS** = **12**
  83. - **PARAM_SHADOW_BIAS** = **13**
  84. - **PARAM_SHADOW_BIAS_SPLIT_SCALE** = **14**
  85. - **PARAM_MAX** = **15** --- Represents the size of the :ref:`Param<enum_Light_Param>` enum.
  86. .. _enum_Light_BakeMode:
  87. .. _class_Light_constant_BAKE_DISABLED:
  88. .. _class_Light_constant_BAKE_INDIRECT:
  89. .. _class_Light_constant_BAKE_ALL:
  90. enum **BakeMode**:
  91. - **BAKE_DISABLED** = **0** --- Light is ignored when baking.
  92. **Note:** Hiding a light does *not* affect baking.
  93. - **BAKE_INDIRECT** = **1** --- Only indirect lighting will be baked (default).
  94. - **BAKE_ALL** = **2** --- Both direct and indirect light will be baked.
  95. **Note:** You should hide the light if you don't want it to appear twice (dynamic and baked).
  96. Description
  97. -----------
  98. Light is the abstract base class for light nodes, so it shouldn't be used directly (it can't be instanced). Other types of light nodes inherit from it. Light contains the common variables and parameters used for lighting.
  99. Tutorials
  100. ---------
  101. - :doc:`../tutorials/3d/lights_and_shadows`
  102. Property Descriptions
  103. ---------------------
  104. .. _class_Light_property_editor_only:
  105. - :ref:`bool<class_bool>` **editor_only**
  106. +-----------+------------------------+
  107. | *Default* | false |
  108. +-----------+------------------------+
  109. | *Setter* | set_editor_only(value) |
  110. +-----------+------------------------+
  111. | *Getter* | is_editor_only() |
  112. +-----------+------------------------+
  113. If ``true``, the light only appears in the editor and will not be visible at runtime.
  114. .. _class_Light_property_light_bake_mode:
  115. - :ref:`BakeMode<enum_Light_BakeMode>` **light_bake_mode**
  116. +-----------+----------------------+
  117. | *Default* | 1 |
  118. +-----------+----------------------+
  119. | *Setter* | set_bake_mode(value) |
  120. +-----------+----------------------+
  121. | *Getter* | get_bake_mode() |
  122. +-----------+----------------------+
  123. The light's bake mode. See :ref:`BakeMode<enum_Light_BakeMode>`.
  124. .. _class_Light_property_light_color:
  125. - :ref:`Color<class_Color>` **light_color**
  126. +-----------+---------------------+
  127. | *Default* | Color( 1, 1, 1, 1 ) |
  128. +-----------+---------------------+
  129. | *Setter* | set_color(value) |
  130. +-----------+---------------------+
  131. | *Getter* | get_color() |
  132. +-----------+---------------------+
  133. The light's color.
  134. .. _class_Light_property_light_cull_mask:
  135. - :ref:`int<class_int>` **light_cull_mask**
  136. +-----------+----------------------+
  137. | *Default* | 4294967295 |
  138. +-----------+----------------------+
  139. | *Setter* | set_cull_mask(value) |
  140. +-----------+----------------------+
  141. | *Getter* | get_cull_mask() |
  142. +-----------+----------------------+
  143. The light will affect objects in the selected layers.
  144. .. _class_Light_property_light_energy:
  145. - :ref:`float<class_float>` **light_energy**
  146. +-----------+------------------+
  147. | *Default* | 1.0 |
  148. +-----------+------------------+
  149. | *Setter* | set_param(value) |
  150. +-----------+------------------+
  151. | *Getter* | get_param() |
  152. +-----------+------------------+
  153. The light's strength multiplier.
  154. .. _class_Light_property_light_indirect_energy:
  155. - :ref:`float<class_float>` **light_indirect_energy**
  156. +-----------+------------------+
  157. | *Default* | 1.0 |
  158. +-----------+------------------+
  159. | *Setter* | set_param(value) |
  160. +-----------+------------------+
  161. | *Getter* | get_param() |
  162. +-----------+------------------+
  163. Secondary multiplier used with indirect light (light bounces). This works on both :ref:`BakedLightmap<class_BakedLightmap>` and :ref:`GIProbe<class_GIProbe>`.
  164. .. _class_Light_property_light_negative:
  165. - :ref:`bool<class_bool>` **light_negative**
  166. +-----------+---------------------+
  167. | *Default* | false |
  168. +-----------+---------------------+
  169. | *Setter* | set_negative(value) |
  170. +-----------+---------------------+
  171. | *Getter* | is_negative() |
  172. +-----------+---------------------+
  173. If ``true``, the light's effect is reversed, darkening areas and casting bright shadows.
  174. .. _class_Light_property_light_specular:
  175. - :ref:`float<class_float>` **light_specular**
  176. +-----------+------------------+
  177. | *Default* | 0.5 |
  178. +-----------+------------------+
  179. | *Setter* | set_param(value) |
  180. +-----------+------------------+
  181. | *Getter* | get_param() |
  182. +-----------+------------------+
  183. The intensity of the specular blob in objects affected by the light. At ``0`` the light becomes a pure diffuse light.
  184. .. _class_Light_property_shadow_bias:
  185. - :ref:`float<class_float>` **shadow_bias**
  186. +-----------+------------------+
  187. | *Default* | 0.15 |
  188. +-----------+------------------+
  189. | *Setter* | set_param(value) |
  190. +-----------+------------------+
  191. | *Getter* | get_param() |
  192. +-----------+------------------+
  193. Used to adjust shadow appearance. Too small a value results in self-shadowing, while too large a value causes shadows to separate from casters. Adjust as needed.
  194. .. _class_Light_property_shadow_color:
  195. - :ref:`Color<class_Color>` **shadow_color**
  196. +-----------+-------------------------+
  197. | *Default* | Color( 0, 0, 0, 1 ) |
  198. +-----------+-------------------------+
  199. | *Setter* | set_shadow_color(value) |
  200. +-----------+-------------------------+
  201. | *Getter* | get_shadow_color() |
  202. +-----------+-------------------------+
  203. The color of shadows cast by this light.
  204. .. _class_Light_property_shadow_contact:
  205. - :ref:`float<class_float>` **shadow_contact**
  206. +-----------+------------------+
  207. | *Default* | 0.0 |
  208. +-----------+------------------+
  209. | *Setter* | set_param(value) |
  210. +-----------+------------------+
  211. | *Getter* | get_param() |
  212. +-----------+------------------+
  213. Attempts to reduce :ref:`shadow_bias<class_Light_property_shadow_bias>` gap.
  214. .. _class_Light_property_shadow_enabled:
  215. - :ref:`bool<class_bool>` **shadow_enabled**
  216. +-----------+-------------------+
  217. | *Default* | false |
  218. +-----------+-------------------+
  219. | *Setter* | set_shadow(value) |
  220. +-----------+-------------------+
  221. | *Getter* | has_shadow() |
  222. +-----------+-------------------+
  223. If ``true``, the light will cast shadows.
  224. .. _class_Light_property_shadow_reverse_cull_face:
  225. - :ref:`bool<class_bool>` **shadow_reverse_cull_face**
  226. +-----------+-------------------------------------+
  227. | *Default* | false |
  228. +-----------+-------------------------------------+
  229. | *Setter* | set_shadow_reverse_cull_face(value) |
  230. +-----------+-------------------------------------+
  231. | *Getter* | get_shadow_reverse_cull_face() |
  232. +-----------+-------------------------------------+
  233. Method Descriptions
  234. -------------------
  235. .. _class_Light_method_get_param:
  236. - :ref:`float<class_float>` **get_param** **(** :ref:`Param<enum_Light_Param>` param **)** const
  237. .. _class_Light_method_set_param:
  238. - void **set_param** **(** :ref:`Param<enum_Light_Param>` param, :ref:`float<class_float>` value **)**