From c10e97b604961700bba0f5c3b379e39a1f07acdf Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Mon, 14 Feb 2022 17:12:15 +0100 Subject: Clamp environment light sky contribution to the [0.0; 1.0] range The value is already clamped in the editor, but it wasn't being clamped when the value was set via code. Values outside the [0.0; 1.0] range can result in broken rendering. --- scene/resources/environment.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scene') diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index bf17a6ea97..82d8ad4444 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -155,7 +155,9 @@ float Environment::get_ambient_light_energy() const { } void Environment::set_ambient_light_sky_contribution(float p_ratio) { - ambient_sky_contribution = p_ratio; + // Sky contribution values outside the [0.0; 1.0] range don't make sense and + // can result in negative colors. + ambient_sky_contribution = CLAMP(p_ratio, 0.0, 1.0); _update_ambient_light(); } -- cgit v1.2.3