diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-08 20:14:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-08 20:14:56 +0400 |
commit | a1693168f24c818e3902bd95352aa0c5fb3b7d1c (patch) | |
tree | 53fa5f8eaaca9205e3fbd61551f28e7138354065 | |
parent | c953ca11ac20fd90fea5a6235fc38d2aa9ec631c (diff) |
DOF node: clamp blurring the zdepth radius buffer by the blur max. This could doo easily blur very high depths and cause artifacts.
-rw-r--r-- | source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp | 8 | ||||
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_defocus.c | 16 |
2 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index e3f95eac3b4..e005232ec00 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -53,9 +53,11 @@ float ConvertDepthToRadiusOperation::determineFocalDistance() normalize_m4(obmat); invert_m4_m4(imat, obmat); mult_m4_m4m4(mat, imat, camera->dof_ob->obmat); - return (float)fabs(mat[3][2]); + return fabsf(mat[3][2]); + } + else { + return camera->YF_dofdist; } - return camera->YF_dofdist; } } @@ -71,7 +73,7 @@ void ConvertDepthToRadiusOperation::initExecution() this->m_dof_sp = (float)minsz / (16.f / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); if (this->m_blurPostOperation) { - m_blurPostOperation->setSigma(m_aperture * 128.0f); + m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius)); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index d9ee067efe3..45d070ba8d2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -166,17 +166,17 @@ static void IIR_gauss_single(CompBuf *buf, float sigma) // see "Recursive Gabor Filtering" by Young/VanVliet // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200 if (sigma >= 3.556f) - q = 0.9804f*(sigma - 3.556f) + 2.5091f; + q = 0.9804f * (sigma - 3.556f) + 2.5091f; else // sigma >= 0.5 - q = (0.0561f*sigma + 0.5784f)*sigma - 0.2568f; - q2 = q*q; - sc = (1.1668 + q)*(3.203729649 + (2.21566 + q)*q); + q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f; + q2 = q * q; + sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q); // no gabor filtering here, so no complex multiplies, just the regular coefs. // all negated here, so as not to have to recalc Triggs/Sdika matrix - cf[1] = q*(5.788961737 + (6.76492 + 3.0*q)*q)/ sc; - cf[2] = -q2*(3.38246 + 3.0*q)/sc; + cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc; + cf[2] = -q2 * (3.38246 + 3.0 * q) / sc; // 0 & 3 unchanged - cf[3] = q2*q/sc; + cf[3] = q2 * q / sc; cf[0] = 1.0 - cf[1] - cf[2] - cf[3]; // Triggs/Sdika border corrections, @@ -336,7 +336,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, // fast blur... // bug #6656 part 1, probably when previous node_composite.c was split into separate files, it was not properly updated // to include recent cvs commits (well, at least not defocus node), so this part was missing... - wt = aperture*128.f; + wt = minf(nqd->maxblur, aperture * 128.0f); IIR_gauss_single(crad, wt); IIR_gauss_single(wts, wt); |