From 292ba9112d22f2871584c899be64f292fef80656 Mon Sep 17 00:00:00 2001 From: Jorian Rutten Date: Fri, 24 Jul 2026 22:34:11 +0200 Subject: [PATCH] Specify-`light()`-only-runs-for-pixels-affected-by-light.rst - Added a small section to specify that the `light()` function is only ran when the pixel is actually affected by at least one light. --- tutorials/shaders/shader_reference/spatial_shader.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tutorials/shaders/shader_reference/spatial_shader.rst b/tutorials/shaders/shader_reference/spatial_shader.rst index 9fd90579de1..64873e3a8f4 100644 --- a/tutorials/shaders/shader_reference/spatial_shader.rst +++ b/tutorials/shaders/shader_reference/spatial_shader.rst @@ -547,6 +547,9 @@ the ``unshaded`` render mode. If no light function is written, Godot will use th written to in the ``fragment()`` function to calculate the lighting for you (subject to the render mode). The ``light()`` function is called for every light in every pixel. It is called within a loop for each light type. +Keep in mind the ``light()`` function only runs for pixels that are affected by at least one light source, and is +completely skipped for pixels that are not hit by any light and shadow. You can use this to create different behavior for +lit and unlit pixels in your shader. Below is an example of a custom ``light()`` function using a Lambertian lighting model: