class_directionallight.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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 DirectionalLight.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_DirectionalLight:
  6. DirectionalLight
  7. ================
  8. **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>`
  9. Directional light from a distance, as from the Sun.
  10. Description
  11. -----------
  12. 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.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/3d/lights_and_shadows`
  16. Properties
  17. ----------
  18. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  19. | :ref:`float<class_float>` | :ref:`directional_shadow_bias_split_scale<class_DirectionalLight_property_directional_shadow_bias_split_scale>` | ``0.25`` |
  20. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  21. | :ref:`bool<class_bool>` | :ref:`directional_shadow_blend_splits<class_DirectionalLight_property_directional_shadow_blend_splits>` | ``false`` |
  22. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  23. | :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` | :ref:`directional_shadow_depth_range<class_DirectionalLight_property_directional_shadow_depth_range>` | ``0`` |
  24. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  25. | :ref:`float<class_float>` | :ref:`directional_shadow_max_distance<class_DirectionalLight_property_directional_shadow_max_distance>` | ``100.0`` |
  26. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  27. | :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` | :ref:`directional_shadow_mode<class_DirectionalLight_property_directional_shadow_mode>` | ``2`` |
  28. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  29. | :ref:`float<class_float>` | :ref:`directional_shadow_normal_bias<class_DirectionalLight_property_directional_shadow_normal_bias>` | ``0.8`` |
  30. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  31. | :ref:`float<class_float>` | :ref:`directional_shadow_split_1<class_DirectionalLight_property_directional_shadow_split_1>` | ``0.1`` |
  32. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  33. | :ref:`float<class_float>` | :ref:`directional_shadow_split_2<class_DirectionalLight_property_directional_shadow_split_2>` | ``0.2`` |
  34. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  35. | :ref:`float<class_float>` | :ref:`directional_shadow_split_3<class_DirectionalLight_property_directional_shadow_split_3>` | ``0.5`` |
  36. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  37. | :ref:`float<class_float>` | shadow_bias | ``0.1`` *(parent override)* |
  38. +-----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+-----------------------------+
  39. Enumerations
  40. ------------
  41. .. _enum_DirectionalLight_ShadowMode:
  42. .. _class_DirectionalLight_constant_SHADOW_ORTHOGONAL:
  43. .. _class_DirectionalLight_constant_SHADOW_PARALLEL_2_SPLITS:
  44. .. _class_DirectionalLight_constant_SHADOW_PARALLEL_4_SPLITS:
  45. enum **ShadowMode**:
  46. - **SHADOW_ORTHOGONAL** = **0** --- 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.
  47. - **SHADOW_PARALLEL_2_SPLITS** = **1** --- 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.
  48. - **SHADOW_PARALLEL_4_SPLITS** = **2** --- Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode.
  49. ----
  50. .. _enum_DirectionalLight_ShadowDepthRange:
  51. .. _class_DirectionalLight_constant_SHADOW_DEPTH_RANGE_STABLE:
  52. .. _class_DirectionalLight_constant_SHADOW_DEPTH_RANGE_OPTIMIZED:
  53. enum **ShadowDepthRange**:
  54. - **SHADOW_DEPTH_RANGE_STABLE** = **0** --- Keeps the shadow stable when the camera moves, at the cost of lower effective shadow resolution.
  55. - **SHADOW_DEPTH_RANGE_OPTIMIZED** = **1** --- 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.
  56. Property Descriptions
  57. ---------------------
  58. .. _class_DirectionalLight_property_directional_shadow_bias_split_scale:
  59. - :ref:`float<class_float>` **directional_shadow_bias_split_scale**
  60. +-----------+------------------+
  61. | *Default* | ``0.25`` |
  62. +-----------+------------------+
  63. | *Setter* | set_param(value) |
  64. +-----------+------------------+
  65. | *Getter* | get_param() |
  66. +-----------+------------------+
  67. 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.
  68. ----
  69. .. _class_DirectionalLight_property_directional_shadow_blend_splits:
  70. - :ref:`bool<class_bool>` **directional_shadow_blend_splits**
  71. +-----------+---------------------------+
  72. | *Default* | ``false`` |
  73. +-----------+---------------------------+
  74. | *Setter* | set_blend_splits(value) |
  75. +-----------+---------------------------+
  76. | *Getter* | is_blend_splits_enabled() |
  77. +-----------+---------------------------+
  78. If ``true``, shadow detail is sacrificed in exchange for smoother transitions between splits.
  79. ----
  80. .. _class_DirectionalLight_property_directional_shadow_depth_range:
  81. - :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>` **directional_shadow_depth_range**
  82. +-----------+-------------------------------+
  83. | *Default* | ``0`` |
  84. +-----------+-------------------------------+
  85. | *Setter* | set_shadow_depth_range(value) |
  86. +-----------+-------------------------------+
  87. | *Getter* | get_shadow_depth_range() |
  88. +-----------+-------------------------------+
  89. Optimizes shadow rendering for detail versus movement. See :ref:`ShadowDepthRange<enum_DirectionalLight_ShadowDepthRange>`.
  90. ----
  91. .. _class_DirectionalLight_property_directional_shadow_max_distance:
  92. - :ref:`float<class_float>` **directional_shadow_max_distance**
  93. +-----------+------------------+
  94. | *Default* | ``100.0`` |
  95. +-----------+------------------+
  96. | *Setter* | set_param(value) |
  97. +-----------+------------------+
  98. | *Getter* | get_param() |
  99. +-----------+------------------+
  100. The maximum distance for shadow splits.
  101. ----
  102. .. _class_DirectionalLight_property_directional_shadow_mode:
  103. - :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>` **directional_shadow_mode**
  104. +-----------+------------------------+
  105. | *Default* | ``2`` |
  106. +-----------+------------------------+
  107. | *Setter* | set_shadow_mode(value) |
  108. +-----------+------------------------+
  109. | *Getter* | get_shadow_mode() |
  110. +-----------+------------------------+
  111. The light's shadow rendering algorithm. See :ref:`ShadowMode<enum_DirectionalLight_ShadowMode>`.
  112. ----
  113. .. _class_DirectionalLight_property_directional_shadow_normal_bias:
  114. - :ref:`float<class_float>` **directional_shadow_normal_bias**
  115. +-----------+------------------+
  116. | *Default* | ``0.8`` |
  117. +-----------+------------------+
  118. | *Setter* | set_param(value) |
  119. +-----------+------------------+
  120. | *Getter* | get_param() |
  121. +-----------+------------------+
  122. Can be used to fix special cases of self shadowing when objects are perpendicular to the light.
  123. ----
  124. .. _class_DirectionalLight_property_directional_shadow_split_1:
  125. - :ref:`float<class_float>` **directional_shadow_split_1**
  126. +-----------+------------------+
  127. | *Default* | ``0.1`` |
  128. +-----------+------------------+
  129. | *Setter* | set_param(value) |
  130. +-----------+------------------+
  131. | *Getter* | get_param() |
  132. +-----------+------------------+
  133. 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 ``SHADOW_PARALLEL_2_SPLITS`` or ``SHADOW_PARALLEL_4_SPLITS``.
  134. ----
  135. .. _class_DirectionalLight_property_directional_shadow_split_2:
  136. - :ref:`float<class_float>` **directional_shadow_split_2**
  137. +-----------+------------------+
  138. | *Default* | ``0.2`` |
  139. +-----------+------------------+
  140. | *Setter* | set_param(value) |
  141. +-----------+------------------+
  142. | *Getter* | get_param() |
  143. +-----------+------------------+
  144. 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 ``SHADOW_PARALLEL_2_SPLITS`` or ``SHADOW_PARALLEL_4_SPLITS``.
  145. ----
  146. .. _class_DirectionalLight_property_directional_shadow_split_3:
  147. - :ref:`float<class_float>` **directional_shadow_split_3**
  148. +-----------+------------------+
  149. | *Default* | ``0.5`` |
  150. +-----------+------------------+
  151. | *Setter* | set_param(value) |
  152. +-----------+------------------+
  153. | *Getter* | get_param() |
  154. +-----------+------------------+
  155. 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 ``SHADOW_PARALLEL_4_SPLITS``.
  156. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  157. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  158. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`