Skip to content

Commit 0d4a295

Browse files
committed
Add documentation for area lights in 3D lights and shadows
1 parent f62bd3c commit 0d4a295

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

122 KB
Loading
201 KB
Loading

tutorials/3d/lights_and_shadows.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,68 @@ With the projector texture below, the following result is obtained:
373373
working entirely. If you need shadows for wider lights, use an omni light
374374
instead.
375375

376+
Area light
377+
----------
378+
379+
Sometimes, you want lighting to come from a large area instead of a single
380+
point. Area lights are useful for simulating soft, diffuse lighting, such as
381+
light coming from a window or a lit billboard. This type of light is expensive
382+
to render in real-time, so it should be used sparingly, especially when shadows
383+
are enabled.
384+
385+
Godot provides the :ref:`class_AreaLight3D` node for this purpose, which is a
386+
type of light that emits light from a rectangular area. This node only emits
387+
light and has no other visual representation in the scene. The screenshots below
388+
use a :ref:`class_Sprite3D` node as a child of the area light for visualization
389+
purposes.
390+
391+
Area lights can also cast shadows, with variable penumbra simulated using
392+
:ref:`PCSS <doc_lights_and_shadows_pcss_recommendations>` by default. This
393+
effect can be quite demanding, so it can be turned off by setting the light's
394+
**Size** to ``0.0``.
395+
396+
.. image:: img/lights_and_shadows_area_example.webp
397+
398+
.. note::
399+
400+
Shadows in area lights are an approximation, and may appear to be distorted
401+
at the edges. To get a better result, make sure the meshes in the light's
402+
range are sufficiently subdivided.
403+
404+
Area lights emit light in a rectangular area defined by the **Area > Size**
405+
property (not to be confused with the generic Light3D **Size** property). To get
406+
a physically accurate result, you should resize this area to match the size of
407+
the real-life light source you are trying to simulate. For example, if you are
408+
simulating a 1-meter neon tube that is 10 centimeters wide, set the area
409+
size to ``(1, 0.1)`` and adjust the energy accordingly.
410+
411+
By default, the light's energy is normalized: the larger the area, the weaker
412+
the light. This allows you to change the area size without needing to adjust the
413+
energy to compensate, which is useful for animation. You can disable this
414+
behavior by unchecking **Area > Normalize Energy** if you want the energy to be
415+
independent of the area size.
416+
417+
The rectangular area can optionally be textured. This can be effectively used to
418+
change the light's shape into any 2D shape, or tint it in different colors. The
419+
texture's alpha channel is treated as black (no light coming through). The area
420+
light's texture will be visible in reflections according to the surface's
421+
roughness. This behavior is different from omni/spot projectors, as it does not
422+
project the texture directly onto all diffuse lighting.
423+
424+
.. image:: img/lights_and_shadows_area_texture.webp
425+
426+
.. note::
427+
428+
Changing the area light's texture at runtime can be expensive, especially if
429+
the texture is large.
430+
431+
To reduce the performance impact of switching textures at runtime, make sure
432+
each dimension of an area texture is either a multiple of 128 pixels, or a
433+
power of two. This removes the need for a scaling pass, which slows down
434+
texture changes. The textures don't necessarily have to be square to be
435+
optimal. Examples of optimal texture sizes include 32×64, 128×128, and
436+
256×384.
437+
376438
.. _doc_lights_and_shadows_shadow_atlas:
377439

378440
Shadow atlas

0 commit comments

Comments
 (0)