From b030ee3c6eb4c3a02a9b7560c47275b3e84e0a05 Mon Sep 17 00:00:00 2001
From: ghostsoft <63552156+ghostsoft@users.noreply.github.com>
Date: Mon, 27 Oct 2025 18:41:53 +0100
Subject: [PATCH 1/4] Add extra cull margin to Light3D
Exposes parameters similar to GeometryInstance3D to allow modifying the cull margin.
---
doc/classes/Light3D.xml | 3 +++
scene/3d/light_3d.cpp | 14 ++++++++++++++
scene/3d/light_3d.h | 4 ++++
3 files changed, 21 insertions(+)
diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml
index 648bb9c215f2..737087e95ca2 100644
--- a/doc/classes/Light3D.xml
+++ b/doc/classes/Light3D.xml
@@ -133,6 +133,9 @@
+
+ The extra distance added to the Light3D's bounding box ([AABB]) to increase its cull box.
+
diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp
index 9c30ddbd8731..a385ce5ea5e8 100644
--- a/scene/3d/light_3d.cpp
+++ b/scene/3d/light_3d.cpp
@@ -221,6 +221,16 @@ Ref Light3D::get_projector() const {
return projector;
}
+void Light3D::set_extra_cull_margin(float p_margin) {
+ ERR_FAIL_COND(p_margin < 0);
+ extra_cull_margin = p_margin;
+ RS::get_singleton()->instance_set_extra_visibility_margin(get_instance(), extra_cull_margin);
+}
+
+float Light3D::get_extra_cull_margin() const {
+ return extra_cull_margin;
+}
+
void Light3D::owner_changed_notify() {
// For cases where owner changes _after_ entering tree (as example, editor editing).
_update_visibility();
@@ -381,6 +391,9 @@ void Light3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_temperature"), &Light3D::get_temperature);
ClassDB::bind_method(D_METHOD("get_correlated_color"), &Light3D::get_correlated_color);
+ ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &Light3D::set_extra_cull_margin);
+ ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &Light3D::get_extra_cull_margin);
+
ADD_GROUP("Light", "light_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "light_intensity_lumens", PROPERTY_HINT_RANGE, "0,100000.0,0.01,or_greater,suffix:lm"), "set_param", "get_param", PARAM_INTENSITY);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "light_intensity_lux", PROPERTY_HINT_RANGE, "0,150000.0,0.01,or_greater,suffix:lx"), "set_param", "get_param", PARAM_INTENSITY);
@@ -397,6 +410,7 @@ void Light3D::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "light_specular", PROPERTY_HINT_RANGE, "0,16,0.001,or_greater"), "set_param", "get_param", PARAM_SPECULAR);
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_bake_mode", PROPERTY_HINT_ENUM, "Disabled,Static,Dynamic"), "set_bake_mode", "get_bake_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "light_extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0.01,suffix:m"), "set_extra_cull_margin", "get_extra_cull_margin");
ADD_GROUP("Shadow", "shadow_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled", PROPERTY_HINT_GROUP_ENABLE), "set_shadow", "has_shadow");
diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h
index d412350c47df..cde83226fe82 100644
--- a/scene/3d/light_3d.h
+++ b/scene/3d/light_3d.h
@@ -86,6 +86,7 @@ class Light3D : public VisualInstance3D {
Ref projector;
Color correlated_color = Color(1.0, 1.0, 1.0);
float temperature = 6500.0;
+ float extra_cull_margin = 0.0;
// bind helpers
@@ -151,6 +152,9 @@ class Light3D : public VisualInstance3D {
virtual AABB get_aabb() const override;
virtual PackedStringArray get_configuration_warnings() const override;
+
+ void set_extra_cull_margin(float p_margin);
+ float get_extra_cull_margin() const;
Light3D();
~Light3D();
From 2e9d46289c1e71577f41fb4449f04cacf3ab955f Mon Sep 17 00:00:00 2001
From: ghostsoft <63552156+ghostsoft@users.noreply.github.com>
Date: Mon, 27 Oct 2025 22:07:12 +0100
Subject: [PATCH 2/4] Fixed extra whitespace
---
scene/3d/light_3d.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h
index cde83226fe82..350945c8e629 100644
--- a/scene/3d/light_3d.h
+++ b/scene/3d/light_3d.h
@@ -152,7 +152,7 @@ class Light3D : public VisualInstance3D {
virtual AABB get_aabb() const override;
virtual PackedStringArray get_configuration_warnings() const override;
-
+
void set_extra_cull_margin(float p_margin);
float get_extra_cull_margin() const;
From 325fd5e714237d8897546d43dd862ff40989c236 Mon Sep 17 00:00:00 2001
From: ghostsoft <63552156+ghostsoft@users.noreply.github.com>
Date: Mon, 27 Oct 2025 22:55:30 +0100
Subject: [PATCH 3/4] moved around doc to maybe be in the right spot?
---
doc/classes/Light3D.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml
index 737087e95ca2..0e631a780939 100644
--- a/doc/classes/Light3D.xml
+++ b/doc/classes/Light3D.xml
@@ -73,6 +73,9 @@
The light's strength multiplier (this is not a physical unit). For [OmniLight3D] and [SpotLight3D], changing this value will only change the light color's intensity, not the light's radius.
+
+ The extra distance added to the Light3D's bounding box ([AABB]) to increase its cull box.
+
Secondary multiplier used with indirect light (light bounces). Used with [VoxelGI] and SDFGI (see [member Environment.sdfgi_enabled]).
[b]Note:[/b] This property is ignored if [member light_energy] is equal to [code]0.0[/code], as the light won't be present at all in the GI shader.
@@ -133,9 +136,6 @@
-
- The extra distance added to the Light3D's bounding box ([AABB]) to increase its cull box.
-
From 30e88cbfc62a7a91dcbd69756836a987b172a0c1 Mon Sep 17 00:00:00 2001
From: ghostsoft <63552156+ghostsoft@users.noreply.github.com>
Date: Tue, 28 Oct 2025 02:02:11 +0100
Subject: [PATCH 4/4] mysterious spaces are now tabs as they should be
---
doc/classes/Light3D.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml
index 0e631a780939..b939d072d3c6 100644
--- a/doc/classes/Light3D.xml
+++ b/doc/classes/Light3D.xml
@@ -73,7 +73,7 @@
The light's strength multiplier (this is not a physical unit). For [OmniLight3D] and [SpotLight3D], changing this value will only change the light color's intensity, not the light's radius.
-
+
The extra distance added to the Light3D's bounding box ([AABB]) to increase its cull box.