class_directionallight3d.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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 DirectionalLight3D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_DirectionalLight3D:
  6. DirectionalLight3D
  7. ==================
  8. **Inherits:** :ref:`Light3D<class_Light3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :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:`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.
  13. Tutorials
  14. ---------
  15. - :doc:`Lights and shadows <../tutorials/3d/lights_and_shadows>`
  16. Properties
  17. ----------
  18. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  19. | :ref:`bool<class_bool>` | :ref:`directional_shadow_blend_splits<class_DirectionalLight3D_property_directional_shadow_blend_splits>` | ``false`` |
  20. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  21. | :ref:`float<class_float>` | :ref:`directional_shadow_fade_start<class_DirectionalLight3D_property_directional_shadow_fade_start>` | ``0.8`` |
  22. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  23. | :ref:`float<class_float>` | :ref:`directional_shadow_max_distance<class_DirectionalLight3D_property_directional_shadow_max_distance>` | ``100.0`` |
  24. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  25. | :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` | :ref:`directional_shadow_mode<class_DirectionalLight3D_property_directional_shadow_mode>` | ``2`` |
  26. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  27. | :ref:`float<class_float>` | :ref:`directional_shadow_pancake_size<class_DirectionalLight3D_property_directional_shadow_pancake_size>` | ``20.0`` |
  28. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`directional_shadow_split_1<class_DirectionalLight3D_property_directional_shadow_split_1>` | ``0.1`` |
  30. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`directional_shadow_split_2<class_DirectionalLight3D_property_directional_shadow_split_2>` | ``0.2`` |
  32. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`directional_shadow_split_3<class_DirectionalLight3D_property_directional_shadow_split_3>` | ``0.5`` |
  34. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | shadow_bias | ``0.1`` (overrides :ref:`Light3D<class_Light3D_property_shadow_bias>`) |
  36. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`use_in_sky_only<class_DirectionalLight3D_property_use_in_sky_only>` | ``false`` |
  38. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------+
  39. Enumerations
  40. ------------
  41. .. _enum_DirectionalLight3D_ShadowMode:
  42. .. _class_DirectionalLight3D_constant_SHADOW_ORTHOGONAL:
  43. .. _class_DirectionalLight3D_constant_SHADOW_PARALLEL_2_SPLITS:
  44. .. _class_DirectionalLight3D_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_DirectionalLight3D_constant_SHADOW_ORTHOGONAL>` and :ref:`SHADOW_PARALLEL_4_SPLITS<class_DirectionalLight3D_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. Property Descriptions
  50. ---------------------
  51. .. _class_DirectionalLight3D_property_directional_shadow_blend_splits:
  52. - :ref:`bool<class_bool>` **directional_shadow_blend_splits**
  53. +-----------+---------------------------+
  54. | *Default* | ``false`` |
  55. +-----------+---------------------------+
  56. | *Setter* | set_blend_splits(value) |
  57. +-----------+---------------------------+
  58. | *Getter* | is_blend_splits_enabled() |
  59. +-----------+---------------------------+
  60. 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>`.
  61. ----
  62. .. _class_DirectionalLight3D_property_directional_shadow_fade_start:
  63. - :ref:`float<class_float>` **directional_shadow_fade_start**
  64. +-----------+------------------+
  65. | *Default* | ``0.8`` |
  66. +-----------+------------------+
  67. | *Setter* | set_param(value) |
  68. +-----------+------------------+
  69. | *Getter* | get_param() |
  70. +-----------+------------------+
  71. 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).
  72. ----
  73. .. _class_DirectionalLight3D_property_directional_shadow_max_distance:
  74. - :ref:`float<class_float>` **directional_shadow_max_distance**
  75. +-----------+------------------+
  76. | *Default* | ``100.0`` |
  77. +-----------+------------------+
  78. | *Setter* | set_param(value) |
  79. +-----------+------------------+
  80. | *Getter* | get_param() |
  81. +-----------+------------------+
  82. 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).
  83. ----
  84. .. _class_DirectionalLight3D_property_directional_shadow_mode:
  85. - :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>` **directional_shadow_mode**
  86. +-----------+------------------------+
  87. | *Default* | ``2`` |
  88. +-----------+------------------------+
  89. | *Setter* | set_shadow_mode(value) |
  90. +-----------+------------------------+
  91. | *Getter* | get_shadow_mode() |
  92. +-----------+------------------------+
  93. The light's shadow rendering algorithm. See :ref:`ShadowMode<enum_DirectionalLight3D_ShadowMode>`.
  94. ----
  95. .. _class_DirectionalLight3D_property_directional_shadow_pancake_size:
  96. - :ref:`float<class_float>` **directional_shadow_pancake_size**
  97. +-----------+------------------+
  98. | *Default* | ``20.0`` |
  99. +-----------+------------------+
  100. | *Setter* | set_param(value) |
  101. +-----------+------------------+
  102. | *Getter* | get_param() |
  103. +-----------+------------------+
  104. 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.
  105. ----
  106. .. _class_DirectionalLight3D_property_directional_shadow_split_1:
  107. - :ref:`float<class_float>` **directional_shadow_split_1**
  108. +-----------+------------------+
  109. | *Default* | ``0.1`` |
  110. +-----------+------------------+
  111. | *Setter* | set_param(value) |
  112. +-----------+------------------+
  113. | *Getter* | get_param() |
  114. +-----------+------------------+
  115. 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>`.
  116. ----
  117. .. _class_DirectionalLight3D_property_directional_shadow_split_2:
  118. - :ref:`float<class_float>` **directional_shadow_split_2**
  119. +-----------+------------------+
  120. | *Default* | ``0.2`` |
  121. +-----------+------------------+
  122. | *Setter* | set_param(value) |
  123. +-----------+------------------+
  124. | *Getter* | get_param() |
  125. +-----------+------------------+
  126. 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>`.
  127. ----
  128. .. _class_DirectionalLight3D_property_directional_shadow_split_3:
  129. - :ref:`float<class_float>` **directional_shadow_split_3**
  130. +-----------+------------------+
  131. | *Default* | ``0.5`` |
  132. +-----------+------------------+
  133. | *Setter* | set_param(value) |
  134. +-----------+------------------+
  135. | *Getter* | get_param() |
  136. +-----------+------------------+
  137. 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>`.
  138. ----
  139. .. _class_DirectionalLight3D_property_use_in_sky_only:
  140. - :ref:`bool<class_bool>` **use_in_sky_only**
  141. +-----------+---------------------+
  142. | *Default* | ``false`` |
  143. +-----------+---------------------+
  144. | *Setter* | set_sky_only(value) |
  145. +-----------+---------------------+
  146. | *Getter* | is_sky_only() |
  147. +-----------+---------------------+
  148. If ``true``, this ``DirectionalLight3D`` will not be used for anything except sky shaders. Use this for lights that impact your sky shader that you may want to hide from affecting the rest of the scene. For example, you may want to enable this when the sun in your sky shader falls below the horizon.
  149. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  150. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  151. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  152. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  153. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  154. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`