diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-13 19:05:42 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-13 19:05:42 +0400 |
commit | 1dec23d33a86c0412852ef510fc5b5b619284697 (patch) | |
tree | 22250958b09cf33ac1e6ea764709194da4307b13 /source/blender/compositor/operations | |
parent | e22aa7bc38c5d38a0714bed8a2a1869383cd5e5a (diff) |
add rgb_to_luma_y(), was being done inline in many places.
Diffstat (limited to 'source/blender/compositor/operations')
3 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp index 82a71f6a7a8..8ff58be7980 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp @@ -89,12 +89,13 @@ void ColorCorrectionOperation::executePixel(float *output, float x, float y, Pix gain *= (levelShadows*this->data->shadows.gain)+(levelMidtones*this->data->midtones.gain)+(levelHighlights*this->data->highlights.gain); lift += (levelShadows*this->data->shadows.lift)+(levelMidtones*this->data->midtones.lift)+(levelHighlights*this->data->highlights.lift); + float invgamma = 1.0f / gamma; + float luma = rgb_to_luma_y(inputImageColor); + r = inputImageColor[0]; g = inputImageColor[1]; b = inputImageColor[2]; - - float invgamma = 1.0f / gamma; - float luma = 0.2126f * r + 0.7152f * g + 0.0722f * b; + r = (luma + saturation * (r - luma)); g = (luma + saturation * (g - luma)); b = (luma + saturation * (b - luma)); diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp index 4ca5f575cfe..ea76e7551ad 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp @@ -37,7 +37,7 @@ void GlareThresholdOperation::initExecution() void GlareThresholdOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { this->inputProgram->read(color, x, y, sampler, inputBuffers); - if ((0.212671f * color[0] + 0.71516f * color[1] + 0.072169f * color[2]) >= threshold) { + if (rgb_to_luma_y(color) >= threshold) { color[0] -= threshold, color[1] -= threshold, color[2] -= threshold; color[0] = MAX2(color[0], 0.0f); color[1] = MAX2(color[1], 0.0f); diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp index 9a02d6a58ca..b281fb938fd 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.cpp +++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp @@ -75,7 +75,7 @@ void PhotoreceptorTonemapOperation::executePixel(float *color, int x, int y, Mem float output[4]; this->imageReader->read(output, x, y, inputBuffers, NULL); - const float L = 0.212671f * output[0] + 0.71516f * output[1] + 0.072169f * output[2]; + const float L = rgb_to_luma_y(output); float I_l = output[0] + ic * (L - output[0]); float I_g = avg->cav[0] + ic * (avg->lav - avg->cav[0]); float I_a = I_l + ia * (I_g - I_l); @@ -133,7 +133,7 @@ void *TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuff float Lav = 0.f; float cav[4] = {0.0f,0.0f,0.0f,0.0f}; while (p--) { - float L = 0.212671f * bc[0] + 0.71516f * bc[1] + 0.072169f * bc[2]; + float L = rgb_to_luma_y(bc); Lav += L; add_v3_v3(cav, bc); lsum += logf(MAX2(L, 0.0f) + 1e-5f); |