Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2020-12-18 12:26:02 +0300
committerJeroen Bakker <jeroen@blender.org>2020-12-18 12:26:02 +0300
commitfe5d2448c6e1348be1f82f10a65d65b992f2477b (patch)
treeb43ce935e4992e2401f8bc60ed3edecf573cb51f /source/blender/gpu
parentffb6648a970e72a749c7de3c5645450ba7d8d858 (diff)
Fix T83494: Eevee clamp node incorrect when min > max.
In glsl the clamp function has undefined behavior when min > max. For the clamp node this resulted in differences between cycles and eevee. This patch adds the expected implementation for minmax. The old clamp function is still used in cases where we know for certain that the input values are correct (math node clamp option). GPU uses optimized code and silicon in these cases.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_clamp.glsl5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_clamp.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_clamp.glsl
index b196aed690f..f89608feff1 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_clamp.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_clamp.glsl
@@ -3,6 +3,11 @@ void clamp_value(float value, float min, float max, out float result)
result = clamp(value, min, max);
}
+void clamp_minmax(float value, float min_allowed, float max_allowed, out float result)
+{
+ result = min(max(value, min_allowed), max_allowed);
+}
+
void clamp_range(float value, float min, float max, out float result)
{
result = (max > min) ? clamp(value, min, max) : clamp(value, max, min);