Files
godot-docs/classes/class_spotlight3d.rst
2025-06-14 03:32:40 +00:00

157 lines
9.9 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/SpotLight3D.xml.
.. _class_SpotLight3D:
SpotLight3D
===========
**Inherits:** :ref:`Light3D<class_Light3D>` **<** :ref:`VisualInstance3D<class_VisualInstance3D>` **<** :ref:`Node3D<class_Node3D>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
A spotlight, such as a reflector spotlight or a lantern.
.. rst-class:: classref-introduction-group
Description
-----------
A Spotlight is a type of :ref:`Light3D<class_Light3D>` node that emits lights in a specific direction, in the shape of a cone. The light is attenuated through the distance. This attenuation can be configured by changing the energy, radius and attenuation parameters of :ref:`Light3D<class_Light3D>`.
Light is emitted in the -Z direction of the node's global basis. For an unrotated light, this means that the light is emitted forwards, illuminating the front side of a 3D model (see :ref:`Vector3.FORWARD<class_Vector3_constant_FORWARD>` and :ref:`Vector3.MODEL_FRONT<class_Vector3_constant_MODEL_FRONT>`).
\ **Note:** When using the Mobile rendering method, only 8 spot lights can be displayed on each mesh resource. Attempting to display more than 8 spot lights on a single mesh resource will result in spot lights flickering in and out as the camera moves. When using the Compatibility rendering method, only 8 spot lights can be displayed on each mesh resource by default, but this can be increased by adjusting :ref:`ProjectSettings.rendering/limits/opengl/max_lights_per_object<class_ProjectSettings_property_rendering/limits/opengl/max_lights_per_object>`.
\ **Note:** When using the Mobile or Compatibility rendering methods, spot lights will only correctly affect meshes whose visibility AABB intersects with the light's AABB. If using a shader to deform the mesh in a way that makes it go outside its AABB, :ref:`GeometryInstance3D.extra_cull_margin<class_GeometryInstance3D_property_extra_cull_margin>` must be increased on the mesh. Otherwise, the light may not be visible on the mesh.
.. rst-class:: classref-introduction-group
Tutorials
---------
- :doc:`3D lights and shadows <../tutorials/3d/lights_and_shadows>`
- :doc:`Faking global illumination <../tutorials/3d/global_illumination/faking_global_illumination>`
- `Third Person Shooter (TPS) Demo <https://godotengine.org/asset-library/asset/2710>`__
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | light_specular | ``0.5`` (overrides :ref:`Light3D<class_Light3D_property_light_specular>`) |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | shadow_bias | ``0.03`` (overrides :ref:`Light3D<class_Light3D_property_shadow_bias>`) |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | shadow_normal_bias | ``1.0`` (overrides :ref:`Light3D<class_Light3D_property_shadow_normal_bias>`) |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`spot_angle<class_SpotLight3D_property_spot_angle>` | ``45.0`` |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`spot_angle_attenuation<class_SpotLight3D_property_spot_angle_attenuation>` | ``1.0`` |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`spot_attenuation<class_SpotLight3D_property_spot_attenuation>` | ``1.0`` |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`spot_range<class_SpotLight3D_property_spot_range>` | ``5.0`` |
+---------------------------+----------------------------------------------------------------------------------+-------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_SpotLight3D_property_spot_angle:
.. rst-class:: classref-property
:ref:`float<class_float>` **spot_angle** = ``45.0`` :ref:`🔗<class_SpotLight3D_property_spot_angle>`
.. rst-class:: classref-property-setget
- |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_param**\ (\ )
The spotlight's angle in degrees. This is the angular radius, meaning the angle from the -Z axis, the cone's center, to the edge of the cone. The default angular radius of 45 degrees corresponds to a cone with an angular diameter of 90 degrees.
\ **Note:** :ref:`spot_angle<class_SpotLight3D_property_spot_angle>` is not affected by :ref:`Node3D.scale<class_Node3D_property_scale>` (the light's scale or its parent's scale).
.. rst-class:: classref-item-separator
----
.. _class_SpotLight3D_property_spot_angle_attenuation:
.. rst-class:: classref-property
:ref:`float<class_float>` **spot_angle_attenuation** = ``1.0`` :ref:`🔗<class_SpotLight3D_property_spot_angle_attenuation>`
.. rst-class:: classref-property-setget
- |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_param**\ (\ )
The spotlight's *angular* attenuation curve. See also :ref:`spot_attenuation<class_SpotLight3D_property_spot_attenuation>`.
.. rst-class:: classref-item-separator
----
.. _class_SpotLight3D_property_spot_attenuation:
.. rst-class:: classref-property
:ref:`float<class_float>` **spot_attenuation** = ``1.0`` :ref:`🔗<class_SpotLight3D_property_spot_attenuation>`
.. rst-class:: classref-property-setget
- |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_param**\ (\ )
Controls the distance attenuation function for spotlights.
A value of ``0.0`` will maintain a constant brightness through most of the range, but smoothly attenuate the light at the edge of the range. Use a value of ``2.0`` for physically accurate lights as it results in the proper inverse square attenutation.
\ **Note:** Setting attenuation to ``2.0`` or higher may result in distant objects receiving minimal light, even within range. For example, with a range of ``4096``, an object at ``100`` units is attenuated by a factor of ``0.0001``. With a default brightness of ``1``, the light would not be visible at that distance.
\ **Note:** Using negative or values higher than ``10.0`` may lead to unexpected results.
.. rst-class:: classref-item-separator
----
.. _class_SpotLight3D_property_spot_range:
.. rst-class:: classref-property
:ref:`float<class_float>` **spot_range** = ``5.0`` :ref:`🔗<class_SpotLight3D_property_spot_range>`
.. rst-class:: classref-property-setget
- |void| **set_param**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_param**\ (\ )
The maximal range that can be reached by the spotlight. Note that the effectively lit area may appear to be smaller depending on the :ref:`spot_attenuation<class_SpotLight3D_property_spot_attenuation>` in use. No matter the :ref:`spot_attenuation<class_SpotLight3D_property_spot_attenuation>` in use, the light will never reach anything outside this range.
\ **Note:** :ref:`spot_range<class_SpotLight3D_property_spot_range>` is not affected by :ref:`Node3D.scale<class_Node3D_property_scale>` (the light's scale or its parent's scale).
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
.. |void| replace:: :abbr:`void (No return value.)`