From 0269d8e871e9df663af7ee90cb4156fb3a6288f8 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 7 Oct 2021 17:57:49 +0200 Subject: Clamp Environment's SSR fade-in and fade-out to positive values Negative values result in rendering glitches. --- doc/classes/Environment.xml | 4 ++-- scene/resources/environment.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index 2c4e5ea886..8231a90438 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -204,10 +204,10 @@ If [code]true[/code], screen-space reflections are enabled. Screen-space reflections are more accurate than reflections from [VoxelGI]s or [ReflectionProbe]s, but are slower and can't reflect surfaces occluded by others. - The fade-in distance for screen-space reflections. Affects the area from the reflected material to the screen-space reflection). + The fade-in distance for screen-space reflections. Affects the area from the reflected material to the screen-space reflection). Only positive values are valid (negative values will be clamped to [code]0.0[/code]). - The fade-out distance for screen-space reflections. Affects the area from the screen-space reflection to the "global" reflection. + The fade-out distance for screen-space reflections. Affects the area from the screen-space reflection to the "global" reflection. Only positive values are valid (negative values will be clamped to [code]0.0[/code]). The maximum number of steps for screen-space reflections. Higher values are slower. diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index cab6c0378a..6980b9e996 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -302,7 +302,7 @@ int Environment::get_ssr_max_steps() const { } void Environment::set_ssr_fade_in(float p_fade_in) { - ssr_fade_in = p_fade_in; + ssr_fade_in = MAX(p_fade_in, 0.0f); _update_ssr(); } @@ -311,7 +311,7 @@ float Environment::get_ssr_fade_in() const { } void Environment::set_ssr_fade_out(float p_fade_out) { - ssr_fade_out = p_fade_out; + ssr_fade_out = MAX(p_fade_out, 0.0f); _update_ssr(); } -- cgit v1.2.3