diff options
Diffstat (limited to 'source/blender/compositor')
3 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp index 307590b977b..23e9a9d623d 100644 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -80,6 +80,9 @@ void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co case 16: /* Greater Than */ operation = new MathGreaterThanOperation(); break; + case 17: /* Modulo */ + operation = new MathModuloOperation(); + break; } if (operation != NULL) { diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp index 7039689aa5f..3749bcf42d8 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp @@ -317,4 +317,19 @@ void MathGreaterThanOperation::executePixel(float output[4], float x, float y, P clampIfNeeded(output); } +void MathModuloOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float inputValue1[4]; + float inputValue2[4]; + + this->m_inputValue1Operation->read(&inputValue1[0], x, y, sampler); + this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler); + + if (inputValue2[0] == 0) + output[0] = 0.0; + else + output[0] = fmod(inputValue1[0], inputValue2[0]); + + clampIfNeeded(output); +} diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index febfa9662c6..649a9688037 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -157,4 +157,10 @@ public: void executePixel(float output[4], float x, float y, PixelSampler sampler); }; +class MathModuloOperation : public MathBaseOperation { +public: + MathModuloOperation() : MathBaseOperation() {} + void executePixel(float output[4], float x, float y, PixelSampler sampler); +}; + #endif |