void MixHueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; float colH, colS, colV; rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV); if (colS != 0.0f) { float rH, rS, rV; float tmpr, tmpg, tmpb; rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV); hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb); output[0] = valuem * (inputColor1[0]) + value * tmpr; output[1] = valuem * (inputColor1[1]) + value * tmpg; output[2] = valuem * (inputColor1[2]) + value * tmpb; } else { copy_v3_v3(output, inputColor1); } output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixGlareOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float value; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); value = inputValue[0]; float mf = 2.0f - 2.0f * fabsf(value - 0.5f); if (inputColor1[0] < 0.0f) { inputColor1[0] = 0.0f; } if (inputColor1[1] < 0.0f) { inputColor1[1] = 0.0f; } if (inputColor1[2] < 0.0f) { inputColor1[2] = 0.0f; } output[0] = mf * max(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f); output[1] = mf * max(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f); output[2] = mf * max(inputColor1[2] + value * (inputColor2[2] - inputColor1[2]), 0.0f); output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixScreenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; output[0] = 1.0f - (valuem + value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]); output[1] = 1.0f - (valuem + value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]); output[2] = 1.0f - (valuem + value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]); output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; float rH, rS, rV; float colH, colS, colV; rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV); rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV); hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &output[0], &output[1], &output[2]); output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixLinearLightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->read(inputValue, x, y, sampler); this->m_inputColor1Operation->read(inputColor1, x, y, sampler); this->m_inputColor2Operation->read(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } if (inputColor2[0] > 0.5f) output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0] - 0.5f)); else output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0]) - 1.0f); if (inputColor2[1] > 0.5f) output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1] - 0.5f)); else output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1]) - 1.0f); if (inputColor2[2] > 0.5f) output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2] - 0.5f)); else output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f); output[3] = inputColor1[3]; clampIfNeeded(output); }
void MathAbsoluteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); output[0] = fabs(inputValue1[0]); clampIfNeeded(output); }
void MathGreaterThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f; clampIfNeeded(output); }
void MathMaximumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = max(inputValue1[0], inputValue2[0]); clampIfNeeded(output); }
void MathRoundOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->read(inputValue1, x, y, sampler); this->m_inputValue2Operation->read(inputValue2, x, y, sampler); output[0] = round(inputValue1[0]); clampIfNeeded(output); }
void MathSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); output[0] = inputValue1[0] - inputValue2[0]; clampIfNeeded(output); }
void MathSqrtOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); if (inputValue1[0] > 0) output[0] = sqrt(inputValue1[0]); else output[0] = 0.0f; clampIfNeeded(output); }
void MathDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue2[0] == 0) /* We don't want to divide by zero. */ output[0] = 0.0; else output[0] = inputValue1[0] / inputValue2[0]; clampIfNeeded(output); }
void MathArcCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] <= 1 && inputValue1[0] >= -1) output[0] = acos(inputValue1[0]); else output[0] = 0.0; clampIfNeeded(output); }
void MathLogarithmOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] > 0 && inputValue2[0] > 0) output[0] = log(inputValue1[0]) / log(inputValue2[0]); else output[0] = 0.0; clampIfNeeded(output); }
void MathModuloOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue2[0] == 0) output[0] = 0.0; else output[0] = fmod(inputValue1[0], inputValue2[0]); clampIfNeeded(output); }
void MixLightenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float tmp; tmp = value * inputColor2[0]; if (tmp > inputColor1[0]) { output[0] = tmp; } else { output[0] = inputColor1[0]; } tmp = value * inputColor2[1]; if (tmp > inputColor1[1]) { output[1] = tmp; } else { output[1] = inputColor1[1]; } tmp = value * inputColor2[2]; if (tmp > inputColor1[2]) { output[2] = tmp; } else { output[2] = inputColor1[2]; } output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; if (inputColor2[0] != 0.0f) { output[0] = valuem * (inputColor1[0]) + value * (inputColor1[0]) / inputColor2[0]; } else { output[0] = 0.0f; } if (inputColor2[1] != 0.0f) { output[1] = valuem * (inputColor1[1]) + value * (inputColor1[1]) / inputColor2[1]; } else { output[1] = 0.0f; } if (inputColor2[2] != 0.0f) { output[2] = valuem * (inputColor1[2]) + value * (inputColor1[2]) / inputColor2[2]; } else { output[2] = 0.0f; } output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixDifferenceOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; this->m_inputValueOperation->read(&value, x, y, sampler); this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; output[0] = valuem * inputColor1[0] + value *fabsf(inputColor1[0] - inputColor2[0]); output[1] = valuem * inputColor1[1] + value *fabsf(inputColor1[1] - inputColor2[1]); output[2] = valuem * inputColor1[2] + value *fabsf(inputColor1[2] - inputColor2[2]); output[3] = inputColor1[3]; clampIfNeeded(output); }
void MixOverlayOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float value; this->m_inputValueOperation->read(&value, x, y, sampler); this->m_inputColor1Operation->read(&inputColor1[0], x, y, sampler); this->m_inputColor2Operation->read(&inputColor2[0], x, y, sampler); if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; if (inputColor1[0] < 0.5f) { outputValue[0] = inputColor1[0] * (valuem + 2.0f * value * inputColor2[0]); } else { outputValue[0] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]); } if (inputColor1[1] < 0.5f) { outputValue[1] = inputColor1[1] * (valuem + 2.0f * value * inputColor2[1]); } else { outputValue[1] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]); } if (inputColor1[2] < 0.5f) { outputValue[2] = inputColor1[2] * (valuem + 2.0f * value * inputColor2[2]); } else { outputValue[2] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]); } outputValue[3] = inputColor1[3]; clampIfNeeded(outputValue); }
void MixSoftLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } float valuem = 1.0f - value; float scr, scg, scb; /* first calculate non-fac based Screen mix */ scr = 1.0f - (1.0f - inputColor2[0]) * (1.0f - inputColor1[0]); scg = 1.0f - (1.0f - inputColor2[1]) * (1.0f - inputColor1[1]); scb = 1.0f - (1.0f - inputColor2[2]) * (1.0f - inputColor1[2]); output[0] = valuem * (inputColor1[0]) + value * (((1.0f - inputColor1[0]) * inputColor2[0] * (inputColor1[0])) + (inputColor1[0] * scr)); output[1] = valuem * (inputColor1[1]) + value * (((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) + (inputColor1[1] * scg)); output[2] = valuem * (inputColor1[2]) + value * (((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) + (inputColor1[2] * scb)); output[3] = inputColor1[3]; clampIfNeeded(output); }
void MathPowerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputValue1[4]; float inputValue2[4]; this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler); this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler); if (inputValue1[0] >= 0) { output[0] = pow(inputValue1[0], inputValue2[0]); } else { float y_mod_1 = fmod(inputValue2[0], 1); /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { output[0] = pow(inputValue1[0], floorf(inputValue2[0] + 0.5f)); } else { output[0] = 0.0; } } clampIfNeeded(output); }
void MixDodgeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) { float inputColor1[4]; float inputColor2[4]; float inputValue[4]; float tmp; this->m_inputValueOperation->readSampled(inputValue, x, y, sampler); this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler); this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler); float value = inputValue[0]; if (this->useValueAlphaMultiply()) { value *= inputColor2[3]; } if (inputColor1[0] != 0.0f) { tmp = 1.0f - value * inputColor2[0]; if (tmp <= 0.0f) { output[0] = 1.0f; } else { tmp = inputColor1[0] / tmp; if (tmp > 1.0f) { output[0] = 1.0f; } else { output[0] = tmp; } } } else { output[0] = 0.0f; } if (inputColor1[1] != 0.0f) { tmp = 1.0f - value * inputColor2[1]; if (tmp <= 0.0f) { output[1] = 1.0f; } else { tmp = inputColor1[1] / tmp; if (tmp > 1.0f) { output[1] = 1.0f; } else { output[1] = tmp; } } } else { output[1] = 0.0f; } if (inputColor1[2] != 0.0f) { tmp = 1.0f - value * inputColor2[2]; if (tmp <= 0.0f) { output[2] = 1.0f; } else { tmp = inputColor1[2] / tmp; if (tmp > 1.0f) { output[2] = 1.0f; } else { output[2] = tmp; } } } else { output[2] = 0.0f; } output[3] = inputColor1[3]; clampIfNeeded(output); }