From 0ca19574456febe8c189e77fe0a6450bc738f059 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 27 Sep 2023 02:19:59 +0200 Subject: [PATCH] Clamp ReflectionProbe Max Distance to 262,144 to fix rendering issues (cherry picked from commit ce421da908faf3ced3bcf81a527b13ebc0dfbe7b) --- scene/3d/reflection_probe.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index e533f08861b..2e34f6aad02 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -68,8 +68,9 @@ Color ReflectionProbe::get_ambient_color() const { } void ReflectionProbe::set_max_distance(float p_distance) { - max_distance = p_distance; - RS::get_singleton()->reflection_probe_set_max_distance(probe, p_distance); + max_distance = CLAMP(p_distance, 0.0, 262'144.0); + // Reflection rendering breaks if distance exceeds 262,144 units (due to floating-point precision with the near plane being 0.01). + RS::get_singleton()->reflection_probe_set_max_distance(probe, max_distance); } float ReflectionProbe::get_max_distance() const {