diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-27 14:20:36 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-27 14:20:36 +0400 |
commit | b8d96bc011d255fa06c1327999c199c417c89225 (patch) | |
tree | 6332b4a3aacc719b0243b2386baba1450f787df6 /source/blender/compositor | |
parent | 52aa7a4a4c07f915b634a56162c9093ef1fecb09 (diff) |
mask motion blur shutter option
Diffstat (limited to 'source/blender/compositor')
-rw-r--r-- | source/blender/compositor/nodes/COM_MaskNode.cpp | 21 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_MaskOperation.cpp | 10 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_MaskOperation.h | 8 |
3 files changed, 24 insertions, 15 deletions
diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp index 71a7191a35e..8d549d09362 100644 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ b/source/blender/compositor/nodes/COM_MaskNode.cpp @@ -36,11 +36,12 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { - const RenderData *data = context->getRenderData(); + const RenderData *rd = context->getRenderData(); OutputSocket *outputMask = this->getOutputSocket(0); bNode *editorNode = this->getbNode(); + NodeMask *data = (NodeMask *)editorNode->storage; Mask *mask = (Mask *)editorNode->id; // always connect the output image @@ -48,16 +49,16 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setbNode(editorNode); if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) { - operation->setMaskWidth(editorNode->custom3); - operation->setMaskHeight(editorNode->custom4); + operation->setMaskWidth(data->size_x); + operation->setMaskHeight(data->size_y); } else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) { - operation->setMaskWidth(editorNode->custom3 * (data->size / 100.0f)); - operation->setMaskHeight(editorNode->custom4 * (data->size / 100.0f)); + operation->setMaskWidth(data->size_x * (rd->size / 100.0f)); + operation->setMaskHeight(data->size_y * (rd->size / 100.0f)); } else { - operation->setMaskWidth(data->xsch * data->size / 100.0f); - operation->setMaskHeight(data->ysch * data->size / 100.0f); + operation->setMaskWidth(rd->xsch * rd->size / 100.0f); + operation->setMaskHeight(rd->ysch * rd->size / 100.0f); } if (outputMask->isConnected()) { @@ -69,8 +70,12 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0); operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); - if (editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) { + if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && + (editorNode->custom2 > 1) && + (editorNode->custom3 > FLT_EPSILON)) + { operation->setMotionBlurSamples(editorNode->custom2); + operation->setMotionBlurShutter(editorNode->custom3); } graph->addOperation(operation); diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index a4e548d47ac..a3326de0a30 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -139,7 +139,8 @@ MaskOperation::MaskOperation() : NodeOperation() this->m_maskHeight = 0; this->m_maskWidthInv = 0.0f; this->m_maskHeightInv = 0.0f; - this->m_framenumber = 0; + this->m_frame_shutter = 0.0f; + this->m_frame_number = 0; this->m_rasterMaskHandleTot = 1; memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles)); } @@ -156,9 +157,8 @@ void MaskOperation::initExecution() } else { /* make a throw away copy of the mask */ - const float frame_range = 1.0f; /* should be 1 max, could be configurable */ - const float frame = (float)this->m_framenumber - frame_range; - const float frame_step = (frame_range * 2.0f) / this->m_rasterMaskHandleTot; + const float frame = (float)this->m_frame_number - this->m_frame_shutter; + const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot; float frame_iter = frame; Mask *mask_temp; @@ -174,7 +174,7 @@ void MaskOperation::initExecution() masklay; masklay = (MaskLayer *)masklay->next) { - masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_framenumber); + masklay_shape = BKE_mask_layer_shape_varify_frame(masklay, this->m_frame_number); BKE_mask_layer_shape_from_mask(masklay, masklay_shape); } } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index a8c23b3bca1..77d8e1148c2 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -54,7 +54,9 @@ protected: float m_maskWidthInv; /* 1 / m_maskWidth */ float m_maskHeightInv; /* 1 / m_maskHeight */ - int m_framenumber; + float m_frame_shutter; + int m_frame_number; + bool m_do_smooth; bool m_do_feather; @@ -91,10 +93,12 @@ public: this->m_maskHeight = height; this->m_maskHeightInv = 1.0f / (float)height; } - void setFramenumber(int framenumber) { this->m_framenumber = framenumber; } + void setFramenumber(int frame_number) { this->m_frame_number = frame_number; } void setSmooth(bool smooth) { this->m_do_smooth = smooth; } void setFeather(bool feather) { this->m_do_feather = feather; } + void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = max(1, samples); } + void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; } #ifdef USE_RASKTER void *initializeTileData(rcti *rect); |