diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-10 14:21:56 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-04-10 14:21:56 +0200 |
commit | c59f493620d7670412dd70f9f6b1fa6a46c03a05 (patch) | |
tree | 066fa26c088b937aadd3459c1216bad7432ddbe9 /drivers | |
parent | 22299f83f169a65891f0909cad695eb2640ab613 (diff) | |
parent | a0969a0931a71e76945bf59d16561904e800d89a (diff) | |
download | redot-engine-c59f493620d7670412dd70f9f6b1fa6a46c03a05.tar.gz |
Merge pull request #89729 from jitspoe/master.shadow_distance_fade_optimization
Shadow fade for omni lights actually stops the shadow from updating while faded out to improve performance.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles3/storage/light_storage.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gles3/storage/light_storage.h b/drivers/gles3/storage/light_storage.h index 8107a3ad4d..b6e64c9492 100644 --- a/drivers/gles3/storage/light_storage.h +++ b/drivers/gles3/storage/light_storage.h @@ -441,6 +441,29 @@ public: virtual void light_instance_set_shadow_transform(RID p_light_instance, const Projection &p_projection, const Transform3D &p_transform, float p_far, float p_split, int p_pass, float p_shadow_texel_size, float p_bias_scale = 1.0, float p_range_begin = 0, const Vector2 &p_uv_scale = Vector2()) override; virtual void light_instance_mark_visible(RID p_light_instance) override; + virtual bool light_instance_is_shadow_visible_at_position(RID p_light_instance, const Vector3 &p_position) const override { + const LightInstance *light_instance = light_instance_owner.get_or_null(p_light_instance); + ERR_FAIL_NULL_V(light_instance, false); + const Light *light = light_owner.get_or_null(light_instance->light); + ERR_FAIL_NULL_V(light, false); + + if (!light->shadow) { + return false; + } + + if (!light->distance_fade) { + return true; + } + + real_t distance = p_position.distance_to(light_instance->transform.origin); + + if (distance > light->distance_fade_shadow + light->distance_fade_length) { + return false; + } + + return true; + } + _FORCE_INLINE_ RID light_instance_get_base_light(RID p_light_instance) { LightInstance *li = light_instance_owner.get_or_null(p_light_instance); return li->light; |