diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-11-30 17:17:19 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-11-30 17:17:19 +0400 |
commit | 7fa7ce297edee80258938c5c82837dcd8ab8377a (patch) | |
tree | 3ee3791c14c755cda6013eac853550ef458a8cb4 /source/blender/compositor/operations/COM_MapRangeOperation.cpp | |
parent | 4f8f5746a8f3a72d54dab44a2b30d2d144891b77 (diff) |
Map Range: added the same infinity clamping for Z buffer as normalize node.
Think should be pretty much harmless since if this node was used for buffers
with infinities it already showed artifacts. Now it should be more useful for
mapping Z buffers.
Diffstat (limited to 'source/blender/compositor/operations/COM_MapRangeOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_MapRangeOperation.cpp | 15 |
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) { |