mirror of
https://github.com/godotengine/godot.git
synced 2025-01-05 17:50:55 +00:00
Merge pull request #57535 from Calinou/visibility-range-fade-use-easing
This commit is contained in:
commit
e4e6813baf
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user