1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

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.
This commit is contained in:
Hugo Locurcio
2022-02-14 17:12:15 +01:00
parent f810f76890
commit c10e97b604
2 changed files with 5 additions and 2 deletions

View File

@@ -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();
}