summaryrefslogtreecommitdiffstats
path: root/scene/3d/light_3d.h
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2022-02-24 22:55:14 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2022-02-25 15:17:35 +0100
commitb1a295b739eb056557e9f2fe47ac80be6cc6d79d (patch)
treebc99029840febd9b84addbf366f8cfd66af314ba /scene/3d/light_3d.h
parent4dc8214831d1617e7f5f06e8294fb37ea23dae59 (diff)
downloadredot-engine-b1a295b739eb056557e9f2fe47ac80be6cc6d79d.tar.gz
Implement distance fade properties in OmniLight3D and SpotLight3D
This can be used to fade lights and their shadows in the distance, similar to Decal nodes. This can bring significant performance improvements, especially for lights with shadows enabled and when using higher-than-default shadow quality settings. While lights can be smoothly faded out over distance, shadows are currently "all or nothing" since per-light shadow color is no longer customizable in the Vulkan renderer. This may result in noticeable pop-in when leaving the shadow cutoff distance, but depending on the scene, it may not always be that noticeable.
Diffstat (limited to 'scene/3d/light_3d.h')
-rw-r--r--scene/3d/light_3d.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h
index d5d2aee43d..21d785e2f7 100644
--- a/scene/3d/light_3d.h
+++ b/scene/3d/light_3d.h
@@ -75,6 +75,10 @@ private:
bool negative = false;
bool reverse_cull = false;
uint32_t cull_mask = 0;
+ bool distance_fade_enabled = false;
+ real_t distance_fade_begin = 40.0;
+ real_t distance_fade_shadow = 50.0;
+ real_t distance_fade_length = 10.0;
RS::LightType type = RenderingServer::LIGHT_DIRECTIONAL;
bool editor_only = false;
void _update_visibility();
@@ -107,6 +111,18 @@ public:
void set_negative(bool p_enable);
bool is_negative() const;
+ void set_enable_distance_fade(bool p_enable);
+ bool is_distance_fade_enabled() const;
+
+ void set_distance_fade_begin(real_t p_distance);
+ real_t get_distance_fade_begin() const;
+
+ void set_distance_fade_shadow(real_t p_distance);
+ real_t get_distance_fade_shadow() const;
+
+ void set_distance_fade_length(real_t p_length);
+ real_t get_distance_fade_length() const;
+
void set_cull_mask(uint32_t p_cull_mask);
uint32_t get_cull_mask() const;