Fix #35327: compositing Z combine node was not giving the same result as previous
versions when the Z values were the same, Also was inconsistent between full sample on/off.
This commit is contained in:
@@ -71,9 +71,18 @@ void ZCombineNode::convertToOperations(ExecutionSystem *system, CompositorContex
|
|||||||
else {
|
else {
|
||||||
// not full anti alias, use masking for Z combine. be aware it uses anti aliasing.
|
// not full anti alias, use masking for Z combine. be aware it uses anti aliasing.
|
||||||
// step 1 create mask
|
// step 1 create mask
|
||||||
MathGreaterThanOperation *maskoperation = new MathGreaterThanOperation();
|
NodeOperation *maskoperation;
|
||||||
this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 1, system);
|
|
||||||
this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 3, system);
|
if (this->getbNode()->custom1) {
|
||||||
|
maskoperation = new MathGreaterThanOperation();
|
||||||
|
this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 3, system);
|
||||||
|
this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 1, system);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
maskoperation = new MathLessThanOperation();
|
||||||
|
this->getInputSocket(1)->relinkConnections(maskoperation->getInputSocket(0), 1, system);
|
||||||
|
this->getInputSocket(3)->relinkConnections(maskoperation->getInputSocket(1), 3, system);
|
||||||
|
}
|
||||||
|
|
||||||
// step 2 anti alias mask bit of an expensive operation, but does the trick
|
// step 2 anti alias mask bit of an expensive operation, but does the trick
|
||||||
AntiAliasOperation *antialiasoperation = new AntiAliasOperation();
|
AntiAliasOperation *antialiasoperation = new AntiAliasOperation();
|
||||||
|
@@ -123,13 +123,7 @@ void ZCombineMaskOperation::executePixel(float output[4], float x, float y, Pixe
|
|||||||
this->m_image1Reader->read(color1, x, y, sampler);
|
this->m_image1Reader->read(color1, x, y, sampler);
|
||||||
this->m_image2Reader->read(color2, x, y, sampler);
|
this->m_image2Reader->read(color2, x, y, sampler);
|
||||||
|
|
||||||
float fac = mask[0];
|
interp_v4_v4v4(output, color1, color2, 1.0f - mask[0]);
|
||||||
// multiply mask with alpha, if mask == 0 color1, else color2 make sure
|
|
||||||
float mfac = 1.0f - fac;
|
|
||||||
output[0] = color1[0] * mfac + color2[0] * fac;
|
|
||||||
output[1] = color1[1] * mfac + color2[1] * fac;
|
|
||||||
output[2] = color1[2] * mfac + color2[2] * fac;
|
|
||||||
output[3] = max(color1[3], color2[3]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZCombineMaskAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
|
void ZCombineMaskAlphaOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
|
||||||
@@ -142,15 +136,12 @@ void ZCombineMaskAlphaOperation::executePixel(float output[4], float x, float y,
|
|||||||
this->m_image1Reader->read(color1, x, y, sampler);
|
this->m_image1Reader->read(color1, x, y, sampler);
|
||||||
this->m_image2Reader->read(color2, x, y, sampler);
|
this->m_image2Reader->read(color2, x, y, sampler);
|
||||||
|
|
||||||
float fac = mask[0];
|
float fac = (1.0f - mask[0])*(1.0f - color1[3]) + mask[0]*color2[3];
|
||||||
// multiply mask with alpha, if mask == 0 color1, else color2 make sure
|
|
||||||
float mfac = 1.0f - fac;
|
float mfac = 1.0f - fac;
|
||||||
float alpha = color1[3] * mfac + color2[3] * fac;
|
|
||||||
float facalpha = fac * alpha;
|
output[0] = color1[0] * mfac + color2[0] * fac;
|
||||||
mfac = 1.0f - facalpha;
|
output[1] = color1[1] * mfac + color2[1] * fac;
|
||||||
output[0] = color1[0] * mfac + color2[0] * facalpha;
|
output[2] = color1[2] * mfac + color2[2] * fac;
|
||||||
output[1] = color1[1] * mfac + color2[1] * facalpha;
|
|
||||||
output[2] = color1[2] * mfac + color2[2] * facalpha;
|
|
||||||
output[3] = max(color1[3], color2[3]);
|
output[3] = max(color1[3], color2[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user