class_directionallight3d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. :github_url: hide
  2. .. meta::
  3. :keywords: sun
  4. .. DO NOT EDIT THIS FILE!!!
  5. .. Generated automatically from Godot engine sources.
  6. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  7. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/DirectionalLight3D.xml.
  8. .. _class_DirectionalLight3D:
  9. DirectionalLight3D
  10. ==================
  11. **Inherits:** :ref:`Light3D<class_Light3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  12. Directional light from a distance, as from the Sun.
  13. .. rst-class:: classref-introduction-group
  14. Description
  15. -----------
  16. A directional light is a type of :ref:`Light3D<class_Light3D>` 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 DirectionalLight3D transform (origin) is ignored. Only the basis is used to determine light direction.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`3D lights and shadows <../tutorials/3d/lights_and_shadows>`
  21. - :doc:`Faking global illumination <../tutorials/3d/global_illumination/faking_global_illumination>`
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`bool<class_bool>` | :ref:`directional_shadow_blend_splits<class_DirectionalLight3D_property_directional_shadow_blend_splits>` | ``false`` |
  29. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  30. | :ref:`float<class_float>` | :ref:`directional_shadow_fade_start<class_DirectionalLight3D_property_directional_shadow_fade_start>` | ``0.8`` |
  31. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  32. | :ref:`float<class_float>` | :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>` | ``100.0`` |
  33. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  34. | :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` | :ref:`directional_shadow_mode<class_DirectionalLight3D_property_directional_shadow_mode>` | ``2`` |
  35. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  36. | :ref:`float<class_float>` | :ref:`directional_shadow_pancake_size<class_DirectionalLight3D_property_directional_shadow_pancake_size>` | ``20.0`` |
  37. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  38. | :ref:`float<class_float>` | :ref:`directional_shadow_split_1<class_DirectionalLight3D_property_directional_shadow_split_1>` | ``0.1`` |
  39. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  40. | :ref:`float<class_float>` | :ref:`directional_shadow_split_2<class_DirectionalLight3D_property_directional_shadow_split_2>` | ``0.2`` |
  41. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  42. | :ref:`float<class_float>` | :ref:`directional_shadow_split_3<class_DirectionalLight3D_property_directional_shadow_split_3>` | ``0.5`` |
  43. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  44. | :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` | :ref:`sky_mode<class_DirectionalLight3D_property_sky_mode>` | ``0`` |
  45. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+-----------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Enumerations
  50. ------------
  51. .. _enum_DirectionalLight3D_ShadowMode:
  52. .. rst-class:: classref-enumeration
  53. enum **ShadowMode**: :ref:`🔗<enum_DirectionalLight3D_ShadowMode>`
  54. .. _class_DirectionalLight3D_constant_SHADOW_ORTHOGONAL:
  55. .. rst-class:: classref-enumeration-constant
  56. :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` **SHADOW_ORTHOGONAL** = ``0``
  57. 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.
  58. .. _class_DirectionalLight3D_constant_SHADOW_PARALLEL_2_SPLITS:
  59. .. rst-class:: classref-enumeration-constant
  60. :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` **SHADOW_PARALLEL_2_SPLITS** = ``1``
  61. Splits the view frustum in 2 areas, each with its own shadow map. This shadow mode is a compromise between :ref:`SHADOW_ORTHOGONAL<class_DirectionalLight3D_constant_SHADOW_ORTHOGONAL>` and :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight3D_constant_SHADOW_PARALLEL_4_SPLITS>` in terms of performance.
  62. .. _class_DirectionalLight3D_constant_SHADOW_PARALLEL_4_SPLITS:
  63. .. rst-class:: classref-enumeration-constant
  64. :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` **SHADOW_PARALLEL_4_SPLITS** = ``2``
  65. Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode.
  66. .. rst-class:: classref-item-separator
  67. ----
  68. .. _enum_DirectionalLight3D_SkyMode:
  69. .. rst-class:: classref-enumeration
  70. enum **SkyMode**: :ref:`🔗<enum_DirectionalLight3D_SkyMode>`
  71. .. _class_DirectionalLight3D_constant_SKY_MODE_LIGHT_AND_SKY:
  72. .. rst-class:: classref-enumeration-constant
  73. :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` **SKY_MODE_LIGHT_AND_SKY** = ``0``
  74. Makes the light visible in both scene lighting and sky rendering.
  75. .. _class_DirectionalLight3D_constant_SKY_MODE_LIGHT_ONLY:
  76. .. rst-class:: classref-enumeration-constant
  77. :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` **SKY_MODE_LIGHT_ONLY** = ``1``
  78. Makes the light visible in scene lighting only (including direct lighting and global illumination). When using this mode, the light will not be visible from sky shaders.
  79. .. _class_DirectionalLight3D_constant_SKY_MODE_SKY_ONLY:
  80. .. rst-class:: classref-enumeration-constant
  81. :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` **SKY_MODE_SKY_ONLY** = ``2``
  82. Makes the light visible to sky shaders only. When using this mode the light will not cast light into the scene (either through direct lighting or through global illumination), but can be accessed through sky shaders. This can be useful, for example, when you want to control sky effects without illuminating the scene (during a night cycle, for example).
  83. .. rst-class:: classref-section-separator
  84. ----
  85. .. rst-class:: classref-descriptions-group
  86. Property Descriptions
  87. ---------------------
  88. .. _class_DirectionalLight3D_property_directional_shadow_blend_splits:
  89. .. rst-class:: classref-property
  90. :ref:`bool<class_bool>` **directional_shadow_blend_splits** = ``false`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_blend_splits>`
  91. .. rst-class:: classref-property-setget
  92. - |void| **set_blend_splits**\ (\ value\: :ref:`bool<class_bool>`\ )
  93. - :ref:`bool<class_bool>` **is_blend_splits_enabled**\ (\ )
  94. 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_DirectionalLight3D_property_directional_shadow_mode>` is :ref:`SHADOW_ORTHOGONAL<class_DirectionalLight3D_constant_SHADOW_ORTHOGONAL>`.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_DirectionalLight3D_property_directional_shadow_fade_start:
  98. .. rst-class:: classref-property
  99. :ref:`float<class_float>` **directional_shadow_fade_start** = ``0.8`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_fade_start>`
  100. .. rst-class:: classref-property-setget
  101. - |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
  102. - :ref:`float<class_float>` **get_param**\ (\ )
  103. Proportion of :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>` at which point the shadow starts to fade. At :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>`, the shadow will disappear. The default value is a balance between smooth fading and distant shadow visibility. If the camera moves fast and the :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>` is low, consider lowering :ref:`directional_shadow_fade_start<class_DirectionalLight3D_property_directional_shadow_fade_start>` below ``0.8`` to make shadow transitions less noticeable. On the other hand, if you tuned :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>` to cover the entire scene, you can set :ref:`directional_shadow_fade_start<class_DirectionalLight3D_property_directional_shadow_fade_start>` to ``1.0`` to prevent the shadow from fading in the distance (it will suddenly cut off instead).
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_DirectionalLight3D_property_directional_shadow_max_distance:
  107. .. rst-class:: classref-property
  108. :ref:`float<class_float>` **directional_shadow_max_distance** = ``100.0`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_max_distance>`
  109. .. rst-class:: classref-property-setget
  110. - |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
  111. - :ref:`float<class_float>` **get_param**\ (\ )
  112. 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).
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_DirectionalLight3D_property_directional_shadow_mode:
  116. .. rst-class:: classref-property
  117. :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` **directional_shadow_mode** = ``2`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_mode>`
  118. .. rst-class:: classref-property-setget
  119. - |void| **set_shadow_mode**\ (\ value\: :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>`\ )
  120. - :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` **get_shadow_mode**\ (\ )
  121. The light's shadow rendering algorithm. See :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>`.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_DirectionalLight3D_property_directional_shadow_pancake_size:
  125. .. rst-class:: classref-property
  126. :ref:`float<class_float>` **directional_shadow_pancake_size** = ``20.0`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_pancake_size>`
  127. .. rst-class:: classref-property-setget
  128. - |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
  129. - :ref:`float<class_float>` **get_param**\ (\ )
  130. Sets the size of the directional shadow pancake. The pancake offsets the start of the shadow's camera frustum to provide a higher effective depth resolution for the shadow. However, a high pancake size can cause artifacts in the shadows of large objects that are close to the edge of the frustum. Reducing the pancake size can help. Setting the size to ``0`` turns off the pancaking effect.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. _class_DirectionalLight3D_property_directional_shadow_split_1:
  134. .. rst-class:: classref-property
  135. :ref:`float<class_float>` **directional_shadow_split_1** = ``0.1`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_split_1>`
  136. .. rst-class:: classref-property-setget
  137. - |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
  138. - :ref:`float<class_float>` **get_param**\ (\ )
  139. The distance from camera to shadow split 1. Relative to :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>`. Only used when :ref:`directional_shadow_mode<class_DirectionalLight3D_property_directional_shadow_mode>` is :ref:`SHADOW_PARALLEL_2_SPLITS<class_DirectionalLight3D_constant_SHADOW_PARALLEL_2_SPLITS>` or :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight3D_constant_SHADOW_PARALLEL_4_SPLITS>`.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_DirectionalLight3D_property_directional_shadow_split_2:
  143. .. rst-class:: classref-property
  144. :ref:`float<class_float>` **directional_shadow_split_2** = ``0.2`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_split_2>`
  145. .. rst-class:: classref-property-setget
  146. - |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
  147. - :ref:`float<class_float>` **get_param**\ (\ )
  148. The distance from shadow split 1 to split 2. Relative to :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>`. Only used when :ref:`directional_shadow_mode<class_DirectionalLight3D_property_directional_shadow_mode>` is :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight3D_constant_SHADOW_PARALLEL_4_SPLITS>`.
  149. .. rst-class:: classref-item-separator
  150. ----
  151. .. _class_DirectionalLight3D_property_directional_shadow_split_3:
  152. .. rst-class:: classref-property
  153. :ref:`float<class_float>` **directional_shadow_split_3** = ``0.5`` :ref:`🔗<class_DirectionalLight3D_property_directional_shadow_split_3>`
  154. .. rst-class:: classref-property-setget
  155. - |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
  156. - :ref:`float<class_float>` **get_param**\ (\ )
  157. The distance from shadow split 2 to split 3. Relative to :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>`. Only used when :ref:`directional_shadow_mode<class_DirectionalLight3D_property_directional_shadow_mode>` is :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight3D_constant_SHADOW_PARALLEL_4_SPLITS>`.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_DirectionalLight3D_property_sky_mode:
  161. .. rst-class:: classref-property
  162. :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` **sky_mode** = ``0`` :ref:`🔗<class_DirectionalLight3D_property_sky_mode>`
  163. .. rst-class:: classref-property-setget
  164. - |void| **set_sky_mode**\ (\ value\: :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>`\ )
  165. - :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` **get_sky_mode**\ (\ )
  166. Set whether this **DirectionalLight3D** is visible in the sky, in the scene, or both in the sky and in the scene. See :ref:`SkyMode<enum_DirectionalLight3D_SkyMode>` for options.
  167. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  168. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  169. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  170. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  171. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  172. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  173. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  174. .. |void| replace:: :abbr:`void (No return value.)`