class_directionallight.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/DirectionalLight.xml.
  6. .. _class_DirectionalLight:
  7. DirectionalLight
  8. ================
  9. **Inherits:** :ref:`Light<class_Light>` **<** :ref:`VisualInstance<class_VisualInstance>` **<** :ref:`CullInstance<class_CullInstance>` **<** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Directional light from a distance, as from the Sun.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A directional light is a type of :ref:`Light<class_Light>` node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene to model sunlight or moonlight. The worldspace location of the DirectionalLight transform (origin) is ignored. Only the basis is used to determine light direction.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`../tutorials/3d/lights_and_shadows`
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`directional_shadow_bias_split_scale<class_DirectionalLight_property_directional_shadow_bias_split_scale>` | ``0.25`` |
  26. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`directional_shadow_blend_splits<class_DirectionalLight_property_directional_shadow_blend_splits>` | ``false`` |
  28. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  29. | :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` | :ref:`directional_shadow_depth_range<class_DirectionalLight_property_directional_shadow_depth_range>` | ``0`` |
  30. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`directional_shadow_max_distance<class_DirectionalLight_property_directional_shadow_max_distance>` | ``100.0`` |
  32. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  33. | :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` | :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` | ``2`` |
  34. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`directional_shadow_normal_bias<class_DirectionalLight_property_directional_shadow_normal_bias>` | ``0.8`` |
  36. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  37. | :ref:`float<class_float>` | :ref:`directional_shadow_split_1<class_DirectionalLight_property_directional_shadow_split_1>` | ``0.1`` |
  38. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  39. | :ref:`float<class_float>` | :ref:`directional_shadow_split_2<class_DirectionalLight_property_directional_shadow_split_2>` | ``0.2`` |
  40. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`directional_shadow_split_3<class_DirectionalLight_property_directional_shadow_split_3>` | ``0.5`` |
  42. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  43. | :ref:`float<class_float>` | shadow_bias | ``0.1`` (overrides :ref:`Light<class_Light_property_shadow_bias>`) |
  44. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------+
  45. .. rst-class:: classref-section-separator
  46. ----
  47. .. rst-class:: classref-descriptions-group
  48. Enumerations
  49. ------------
  50. .. _enum_DirectionalLight_ShadowMode:
  51. .. rst-class:: classref-enumeration
  52. enum **ShadowMode**:
  53. .. _class_DirectionalLight_constant_SHADOW_ORTHOGONAL:
  54. .. rst-class:: classref-enumeration-constant
  55. :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` **SHADOW_ORTHOGONAL** = ``0``
  56. Renders the entire scene's shadow map from an orthogonal point of view. This is the fastest directional shadow mode. May result in blurrier shadows on close objects.
  57. .. _class_DirectionalLight_constant_SHADOW_PARALLEL_2_SPLITS:
  58. .. rst-class:: classref-enumeration-constant
  59. :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` **SHADOW_PARALLEL_2_SPLITS** = ``1``
  60. Splits the view frustum in 2 areas, each with its own shadow map. This shadow mode is a compromise between :ref:`SHADOW_ORTHOGONAL<class_DirectionalLight_constant_SHADOW_ORTHOGONAL>` and :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight_constant_SHADOW_PARALLEL_4_SPLITS>` in terms of performance.
  61. .. _class_DirectionalLight_constant_SHADOW_PARALLEL_4_SPLITS:
  62. .. rst-class:: classref-enumeration-constant
  63. :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` **SHADOW_PARALLEL_4_SPLITS** = ``2``
  64. Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode.
  65. .. rst-class:: classref-item-separator
  66. ----
  67. .. _enum_DirectionalLight_ShadowDepthRange:
  68. .. rst-class:: classref-enumeration
  69. enum **ShadowDepthRange**:
  70. .. _class_DirectionalLight_constant_SHADOW_DEPTH_RANGE_STABLE:
  71. .. rst-class:: classref-enumeration-constant
  72. :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` **SHADOW_DEPTH_RANGE_STABLE** = ``0``
  73. Keeps the shadow stable when the camera moves, at the cost of lower effective shadow resolution.
  74. .. _class_DirectionalLight_constant_SHADOW_DEPTH_RANGE_OPTIMIZED:
  75. .. rst-class:: classref-enumeration-constant
  76. :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` **SHADOW_DEPTH_RANGE_OPTIMIZED** = ``1``
  77. Tries to achieve maximum shadow resolution. May result in saw effect on shadow edges. This mode typically works best in games where the camera will often move at high speeds, such as most racing games.
  78. .. rst-class:: classref-section-separator
  79. ----
  80. .. rst-class:: classref-descriptions-group
  81. Property Descriptions
  82. ---------------------
  83. .. _class_DirectionalLight_property_directional_shadow_bias_split_scale:
  84. .. rst-class:: classref-property
  85. :ref:`float<class_float>` **directional_shadow_bias_split_scale** = ``0.25``
  86. .. rst-class:: classref-property-setget
  87. - void **set_param** **(** :ref:`float<class_float>` value **)**
  88. - :ref:`float<class_float>` **get_param** **(** **)**
  89. Amount of extra bias for shadow splits that are far away. If self-shadowing occurs only on the splits far away, increasing this value can fix them. This is ignored when :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` is :ref:`SHADOW_ORTHOGONAL<class_DirectionalLight_constant_SHADOW_ORTHOGONAL>`.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_DirectionalLight_property_directional_shadow_blend_splits:
  93. .. rst-class:: classref-property
  94. :ref:`bool<class_bool>` **directional_shadow_blend_splits** = ``false``
  95. .. rst-class:: classref-property-setget
  96. - void **set_blend_splits** **(** :ref:`bool<class_bool>` value **)**
  97. - :ref:`bool<class_bool>` **is_blend_splits_enabled** **(** **)**
  98. If ``true``, shadow detail is sacrificed in exchange for smoother transitions between splits. Enabling shadow blend splitting also has a moderate performance cost. This is ignored when :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` is :ref:`SHADOW_ORTHOGONAL<class_DirectionalLight_constant_SHADOW_ORTHOGONAL>`.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_DirectionalLight_property_directional_shadow_depth_range:
  102. .. rst-class:: classref-property
  103. :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` **directional_shadow_depth_range** = ``0``
  104. .. rst-class:: classref-property-setget
  105. - void **set_shadow_depth_range** **(** :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` value **)**
  106. - :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` **get_shadow_depth_range** **(** **)**
  107. Optimizes shadow rendering for detail versus movement. See :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>`.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_DirectionalLight_property_directional_shadow_max_distance:
  111. .. rst-class:: classref-property
  112. :ref:`float<class_float>` **directional_shadow_max_distance** = ``100.0``
  113. .. rst-class:: classref-property-setget
  114. - void **set_param** **(** :ref:`float<class_float>` value **)**
  115. - :ref:`float<class_float>` **get_param** **(** **)**
  116. The maximum distance for shadow splits. Increasing this value will make directional shadows visible from further away, at the cost of lower overall shadow detail and performance (since more objects need to be included in the directional shadow rendering).
  117. .. rst-class:: classref-item-separator
  118. ----
  119. .. _class_DirectionalLight_property_directional_shadow_mode:
  120. .. rst-class:: classref-property
  121. :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` **directional_shadow_mode** = ``2``
  122. .. rst-class:: classref-property-setget
  123. - void **set_shadow_mode** **(** :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` value **)**
  124. - :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` **get_shadow_mode** **(** **)**
  125. The light's shadow rendering algorithm. See :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>`.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_DirectionalLight_property_directional_shadow_normal_bias:
  129. .. rst-class:: classref-property
  130. :ref:`float<class_float>` **directional_shadow_normal_bias** = ``0.8``
  131. .. rst-class:: classref-property-setget
  132. - void **set_param** **(** :ref:`float<class_float>` value **)**
  133. - :ref:`float<class_float>` **get_param** **(** **)**
  134. Can be used to fix special cases of self shadowing when objects are perpendicular to the light.
  135. .. rst-class:: classref-item-separator
  136. ----
  137. .. _class_DirectionalLight_property_directional_shadow_split_1:
  138. .. rst-class:: classref-property
  139. :ref:`float<class_float>` **directional_shadow_split_1** = ``0.1``
  140. .. rst-class:: classref-property-setget
  141. - void **set_param** **(** :ref:`float<class_float>` value **)**
  142. - :ref:`float<class_float>` **get_param** **(** **)**
  143. The distance from camera to shadow split 1. Relative to :ref:`directional_shadow_max_distance<class_DirectionalLight_property_directional_shadow_max_distance>`. Only used when :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` is :ref:`SHADOW_PARALLEL_2_SPLITS<class_DirectionalLight_constant_SHADOW_PARALLEL_2_SPLITS>` or :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight_constant_SHADOW_PARALLEL_4_SPLITS>`.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_DirectionalLight_property_directional_shadow_split_2:
  147. .. rst-class:: classref-property
  148. :ref:`float<class_float>` **directional_shadow_split_2** = ``0.2``
  149. .. rst-class:: classref-property-setget
  150. - void **set_param** **(** :ref:`float<class_float>` value **)**
  151. - :ref:`float<class_float>` **get_param** **(** **)**
  152. The distance from shadow split 1 to split 2. Relative to :ref:`directional_shadow_max_distance<class_DirectionalLight_property_directional_shadow_max_distance>`. Only used when :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` is :ref:`SHADOW_PARALLEL_2_SPLITS<class_DirectionalLight_constant_SHADOW_PARALLEL_2_SPLITS>` or :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight_constant_SHADOW_PARALLEL_4_SPLITS>`.
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_DirectionalLight_property_directional_shadow_split_3:
  156. .. rst-class:: classref-property
  157. :ref:`float<class_float>` **directional_shadow_split_3** = ``0.5``
  158. .. rst-class:: classref-property-setget
  159. - void **set_param** **(** :ref:`float<class_float>` value **)**
  160. - :ref:`float<class_float>` **get_param** **(** **)**
  161. The distance from shadow split 2 to split 3. Relative to :ref:`directional_shadow_max_distance<class_DirectionalLight_property_directional_shadow_max_distance>`. Only used when :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` is :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight_constant_SHADOW_PARALLEL_4_SPLITS>`.
  162. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  163. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  164. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  165. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`