[Bf-blender-cvs] [8afa93d82d7] master: Fix: Clamping in Map Range node works incorrectly.

OmarSquircleArt noreply at git.blender.org
Fri Oct 4 15:20:30 CEST 2019


Commit: 8afa93d82d7dd2519af667d85e1d87b19bf6f2c5
Author: OmarSquircleArt
Date:   Fri Oct 4 15:18:08 2019 +0200
Branches: master
https://developer.blender.org/rB8afa93d82d7dd2519af667d85e1d87b19bf6f2c5

Fix: Clamping in Map Range node works incorrectly.

The clamp option in the Map Range node doesn't work correctly when the
inputs are linked. The code didn't put that into considration.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5987

===================================================================

M	intern/cycles/render/nodes.cpp

===================================================================

diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 71f1863ea49..b58e10a7b52 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -5567,11 +5567,21 @@ void MapRangeNode::expand(ShaderGraph *graph)
     ShaderOutput *result_out = output("Result");
     if (!result_out->links.empty()) {
       ClampNode *clamp_node = new ClampNode();
-      clamp_node->min = to_min;
-      clamp_node->max = to_max;
       graph->add(clamp_node);
       graph->relink(result_out, clamp_node->output("Result"));
       graph->connect(result_out, clamp_node->input("Value"));
+      if (input("To Min")->link) {
+        graph->connect(input("To Min")->link, clamp_node->input("Min"));
+      }
+      else {
+        clamp_node->min = to_min;
+      }
+      if (input("To Max")->link) {
+        graph->connect(input("To Max")->link, clamp_node->input("Max"));
+      }
+      else {
+        clamp_node->max = to_max;
+      }
     }
   }
 }



More information about the Bf-blender-cvs mailing list