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:
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index a18f418e48e..1fe74ade0fc 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -43,6 +43,9 @@ void MapRangeOperation::initExecution()
this->m_destMaxOperation = this->getInputSocketReader(4);
}
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+#define BLENDER_ZMAX 10000.0f
+
void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputs[8]; /* includes the 5 inputs + 3 pads */
@@ -61,9 +64,15 @@ void MapRangeOperation::executePixel(float output[4], float x, float y, PixelSam
source_max = inputs[2];
dest_min = inputs[3];
dest_max = inputs[4];
-
- value = (value - source_min) / (source_max - source_min);
- value = dest_min + value * (dest_max - dest_min);
+
+ if (value >= -BLENDER_ZMAX && value <= BLENDER_ZMAX) {
+ value = (value - source_min) / (source_max - source_min);
+ value = dest_min + value * (dest_max - dest_min);
+ }
+ else if (value > BLENDER_ZMAX)
+ value = dest_max;
+ else
+ value = dest_min;
if (this->m_useClamp) {
if (dest_max > dest_min) {