fix bokeh fx artifacts

This commit is contained in:
shun-iwasawa 2022-09-01 02:41:28 +09:00 committed by manongjohn
parent 2123ba0241
commit a46faab818
3 changed files with 17 additions and 14 deletions

View file

@ -163,9 +163,9 @@ void BokehUtils::MyThread::setLayerRaster(const RASTER srcRas,
PIXEL* pix = srcRas->pixels(j); PIXEL* pix = srcRas->pixels(j);
for (int i = 0; i < dim.lx; i++, pix++) { for (int i = 0; i < dim.lx; i++, pix++) {
if (pix->m != 0) { if (pix->m != 0) {
double val = (m_channel == Red) ? (double)pix->r double val = (m_channel == Red) ? (double)pix->r
: (m_channel == Green) ? (double)pix->g : (m_channel == Green) ? (double)pix->g
: (double)pix->b; : (double)pix->b;
// multiply the exposure by alpha channel value // multiply the exposure by alpha channel value
dstMem[j * dim.lx + i].r = dstMem[j * dim.lx + i].r =
valueToExposure(val / (double)PIXEL::maxChannelValue, valueToExposure(val / (double)PIXEL::maxChannelValue,
@ -264,9 +264,9 @@ void BokehUtils::MyThread::run() {
std::pow(exposure / (*alp_p), m_layerHardness / m_masterHardness) * std::pow(exposure / (*alp_p), m_layerHardness / m_masterHardness) *
(*alp_p); (*alp_p);
double* res = (m_channel == Red) ? (&((*res_p).x)) double* res = (m_channel == Red) ? (&((*res_p).x))
: (m_channel == Green) ? (&((*res_p).y)) : (m_channel == Green) ? (&((*res_p).y))
: (&((*res_p).z)); : (&((*res_p).z));
// composite exposure // composite exposure
if ((*alp_p) >= 1.0 || (*res) == 0.0) if ((*alp_p) >= 1.0 || (*res) == 0.0)
@ -1280,22 +1280,26 @@ void BokehUtils::setOutputRaster(double4* src, const RASTER dstRas,
outPix->r = outPix->r =
(typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue) (typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue)
? (double)PIXEL::maxChannelValue ? (double)PIXEL::maxChannelValue
: val); : (val < 0.) ? 0.
: val);
val = (*src_p).y * (double)PIXEL::maxChannelValue + 0.5; val = (*src_p).y * (double)PIXEL::maxChannelValue + 0.5;
outPix->g = outPix->g =
(typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue) (typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue)
? (double)PIXEL::maxChannelValue ? (double)PIXEL::maxChannelValue
: val); : (val < 0.) ? 0.
: val);
val = (*src_p).z * (double)PIXEL::maxChannelValue + 0.5; val = (*src_p).z * (double)PIXEL::maxChannelValue + 0.5;
outPix->b = outPix->b =
(typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue) (typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue)
? (double)PIXEL::maxChannelValue ? (double)PIXEL::maxChannelValue
: val); : (val < 0.) ? 0.
: val);
val = (*src_p).w * (double)PIXEL::maxChannelValue + 0.5; val = (*src_p).w * (double)PIXEL::maxChannelValue + 0.5;
outPix->m = outPix->m =
(typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue) (typename PIXEL::Channel)((val > (double)PIXEL::maxChannelValue)
? (double)PIXEL::maxChannelValue ? (double)PIXEL::maxChannelValue
: val); : (val < 0.) ? 0.
: val);
} }
src_p += margin.x; src_p += margin.x;
} }

View file

@ -163,9 +163,8 @@ void Iwa_BokehFx::doCompute(TTile& tile, double frame,
QList<LayerValue> layerValues; QList<LayerValue> layerValues;
for (auto index : sourceIndices) { for (auto index : sourceIndices) {
LayerValue layerValue; LayerValue layerValue;
layerValue.sourceTile = sourceTiles[index]; layerValue.sourceTile = sourceTiles[index];
layerValue.premultiply = layerValue.premultiply = m_layerParams[index].m_premultiply->getValue();
m_layerParams[index].m_premultiply->getValue() ? 1 : 0;
layerValue.layerHardness = masterHardness; layerValue.layerHardness = masterHardness;
layerValue.depth_ref = 0; layerValue.depth_ref = 0;
layerValue.irisSize = irisSizes.value(index); layerValue.irisSize = irisSizes.value(index);

View file

@ -212,7 +212,7 @@ void Iwa_BokehRefFx::doCompute(TTile& tile, double frame,
} }
ctrls[1] = depth_buff; ctrls[1] = depth_buff;
layerValue.premultiply = 2; // auto layerValue.premultiply = false;
layerValue.layerHardness = m_hardness->getValue(frame); layerValue.layerHardness = m_hardness->getValue(frame);
layerValue.depth_ref = 1; layerValue.depth_ref = 1;
layerValue.distance = 0.5; layerValue.distance = 0.5;