summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-02-10 18:18:53 +0100
committerGitHub <noreply@github.com>2022-02-10 18:18:53 +0100
commite4e6813baf7090c701b8ea796b9d0f4f174c8d45 (patch)
tree41deee2c0ddb2e5a674764bc8ba75777a4afa0f4 /servers
parent11cefc2b28faad9ac05f0ffccbe3b77f618bc2a1 (diff)
parent20464fd10374a99eacb67743013ef822cf67284b (diff)
Merge pull request #57535 from Calinou/visibility-range-fade-use-easing
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index 5d84edfc67..d113fcd4f0 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -969,10 +969,11 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
if (inst->fade_near || inst->fade_far) {
float fade_dist = inst->transform.origin.distance_to(p_render_data->cam_transform.origin);
+ // Use `smoothstep()` to make opacity changes more gradual and less noticeable to the player.
if (inst->fade_far && fade_dist > inst->fade_far_begin) {
- fade_alpha = MAX(0.0, 1.0 - (fade_dist - inst->fade_far_begin) / (inst->fade_far_end - inst->fade_far_begin));
+ fade_alpha = Math::smoothstep(0.0f, 1.0f, 1.0f - (fade_dist - inst->fade_far_begin) / (inst->fade_far_end - inst->fade_far_begin));
} else if (inst->fade_near && fade_dist < inst->fade_near_end) {
- fade_alpha = MAX(0.0, (fade_dist - inst->fade_near_begin) / (inst->fade_near_end - inst->fade_near_begin));
+ fade_alpha = Math::smoothstep(0.0f, 1.0f, (fade_dist - inst->fade_near_begin) / (inst->fade_near_end - inst->fade_near_begin));
}
}