Compositor: Full frame curve nodes
Adds full frame implementation to "RGB Curves", "Vector Curves" and "Hue Correct" nodes. No functional changes. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D12093
This commit is contained in:
@@ -98,6 +98,36 @@ void ColorCurveOperation::deinitExecution()
|
||||
this->m_inputWhiteProgram = nullptr;
|
||||
}
|
||||
|
||||
void ColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *cumap = this->m_curveMapping;
|
||||
float bwmul[3];
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
/* Local versions of `cumap->black` and `cumap->white`. */
|
||||
const float *black = it.in(2);
|
||||
const float *white = it.in(3);
|
||||
/* Get a local `bwmul` value, it's not threadsafe using `cumap->bwmul` and others. */
|
||||
BKE_curvemapping_set_black_white_ex(black, white, bwmul);
|
||||
|
||||
const float fac = *it.in(0);
|
||||
const float *image = it.in(1);
|
||||
if (fac >= 1.0f) {
|
||||
BKE_curvemapping_evaluate_premulRGBF_ex(cumap, it.out, image, black, bwmul);
|
||||
}
|
||||
else if (fac <= 0.0f) {
|
||||
copy_v3_v3(it.out, image);
|
||||
}
|
||||
else {
|
||||
float col[4];
|
||||
BKE_curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul);
|
||||
interp_v3_v3v3(it.out, image, col, fac);
|
||||
}
|
||||
it.out[3] = image[3];
|
||||
}
|
||||
}
|
||||
|
||||
// Constant level curve mapping
|
||||
|
||||
ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation()
|
||||
@@ -154,4 +184,27 @@ void ConstantLevelColorCurveOperation::deinitExecution()
|
||||
this->m_inputImageProgram = nullptr;
|
||||
}
|
||||
|
||||
void ConstantLevelColorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *cumap = this->m_curveMapping;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
const float fac = *it.in(0);
|
||||
const float *image = it.in(1);
|
||||
if (fac >= 1.0f) {
|
||||
BKE_curvemapping_evaluate_premulRGBF(cumap, it.out, image);
|
||||
}
|
||||
else if (fac <= 0.0f) {
|
||||
copy_v3_v3(it.out, image);
|
||||
}
|
||||
else {
|
||||
float col[4];
|
||||
BKE_curvemapping_evaluate_premulRGBF(cumap, col, image);
|
||||
interp_v3_v3v3(it.out, image, col, fac);
|
||||
}
|
||||
it.out[3] = image[3];
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -51,6 +51,10 @@ class ColorCurveOperation : public CurveBaseOperation {
|
||||
* Deinitialize the execution
|
||||
*/
|
||||
void deinitExecution() override;
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs) override;
|
||||
};
|
||||
|
||||
class ConstantLevelColorCurveOperation : public CurveBaseOperation {
|
||||
@@ -89,6 +93,10 @@ class ConstantLevelColorCurveOperation : public CurveBaseOperation {
|
||||
{
|
||||
copy_v3_v3(this->m_white, white);
|
||||
}
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs) override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace blender::compositor {
|
||||
CurveBaseOperation::CurveBaseOperation()
|
||||
{
|
||||
this->m_curveMapping = nullptr;
|
||||
this->flags.can_be_constant = true;
|
||||
}
|
||||
|
||||
CurveBaseOperation::~CurveBaseOperation()
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_MultiThreadedOperation.h"
|
||||
#include "DNA_color_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class CurveBaseOperation : public NodeOperation {
|
||||
class CurveBaseOperation : public MultiThreadedOperation {
|
||||
protected:
|
||||
/**
|
||||
* Cached reference to the inputProgram
|
||||
|
||||
@@ -73,4 +73,31 @@ void HueSaturationValueCorrectOperation::deinitExecution()
|
||||
this->m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void HueSaturationValueCorrectOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
float hsv[4];
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
copy_v4_v4(hsv, it.in(0));
|
||||
|
||||
/* Adjust hue, scaling returned default 0.5 up to 1. */
|
||||
float f = BKE_curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
|
||||
hsv[0] += f - 0.5f;
|
||||
|
||||
/* Adjust saturation, scaling returned default 0.5 up to 1. */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
|
||||
hsv[1] *= (f * 2.0f);
|
||||
|
||||
/* Adjust value, scaling returned default 0.5 up to 1. */
|
||||
f = BKE_curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
|
||||
hsv[2] *= (f * 2.0f);
|
||||
|
||||
hsv[0] = hsv[0] - floorf(hsv[0]); /* Mod 1.0. */
|
||||
CLAMP(hsv[1], 0.0f, 1.0f);
|
||||
|
||||
copy_v4_v4(it.out, hsv);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -47,6 +47,10 @@ class HueSaturationValueCorrectOperation : public CurveBaseOperation {
|
||||
* Deinitialize the execution
|
||||
*/
|
||||
void deinitExecution() override;
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs) override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -53,4 +53,14 @@ void VectorCurveOperation::deinitExecution()
|
||||
this->m_inputProgram = nullptr;
|
||||
}
|
||||
|
||||
void VectorCurveOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
CurveMapping *curve_map = this->m_curveMapping;
|
||||
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
|
||||
BKE_curvemapping_evaluate_premulRGBF(curve_map, it.out, it.in(0));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
@@ -47,6 +47,10 @@ class VectorCurveOperation : public CurveBaseOperation {
|
||||
* Deinitialize the execution
|
||||
*/
|
||||
void deinitExecution() override;
|
||||
|
||||
void update_memory_buffer_partial(MemoryBuffer *output,
|
||||
const rcti &area,
|
||||
Span<MemoryBuffer *> inputs) override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
||||
Reference in New Issue
Block a user