29 float in,
const float lift,
const float gain,
const float gamma,
const float mul)
31 float x = (((
in - 1.0f) * lift) + 1.0f) * gain;
34 x = std::max(
x, 0.0f);
43 float in,
const float slope,
const float offset,
const float power,
float mul)
45 float x =
in * slope + offset;
48 x = std::max(
x, 0.0f);
63 float lift,
float gain,
float gamma,
float mul,
float r_table[
CB_TABLE_SIZE])
88 template<
typename MaskSampler>
91 image += y_range.
first() * image_x * 4;
101 result.x = this->lut[0][p0];
102 result.y = this->lut[1][p1];
103 result.z = this->lut[2][p2];
114 template<
typename MaskSampler>
117 image += y_range.
first() * image_x * 4;
127 input.x, this->lift.x, this->gain.x, this->gamma.x, this->multiplier);
129 input.y, this->lift.y, this->gain.y, this->gamma.y, this->multiplier);
131 input.z, this->lift.z, this->gain.z, this->gamma.z, this->multiplier);
146 input.x, this->slope.x, this->offset.x, this->power.x, this->multiplier);
148 input.y, this->slope.y, this->offset.y, this->power.y, this->multiplier);
150 input.z, this->slope.z, this->offset.z, this->power.z, this->multiplier);
170 for (
int c = 0; c < 3; c++) {
173 if (this->lift[c] > 1.0f) {
174 this->lift[c] =
powf(this->lift[c] - 1.0f, 2.0f) + 1.0f;
176 this->lift[c] = 2.0f - this->lift[c];
202 this->offset = -this->offset;
213 this->multiplier =
data.color_multiply;
214 this->method =
data.color_balance.method;
219 for (
int c = 0; c < 3; c++) {
221 this->lift[c], this->gain[c], this->gamma[c], this->multiplier, this->lut[c]);
228 for (
int c = 0; c < 3; c++) {
230 this->slope[c], this->offset[c], this->power[c], this->multiplier, this->lut[c]);
247 for (
int c = 0; c < 3; c++) {
262 op.
init(*cbmd, context.image->byte_buffer.data !=
nullptr);
272 const int correction_method =
RNA_enum_get(&color_balance,
"correction_method");
277 layout->
prop(&color_balance,
"correction_method",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
303 &color_balance,
"invert_gamma",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
328 &color_balance,
"invert_offset",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
340 &color_balance,
"invert_power",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
352 &color_balance,
"invert_slope",
UI_ITEM_NONE,
IFACE_(
"Invert"), ICON_ARROW_LEFTRIGHT);
361 C,
ptr,
"open_mask_input_panel",
IFACE_(
"Mask Input")))
375 "ColorBalanceModifierData",
#define BLI_assert_unreachable()
#define CTX_N_(context, msgid)
#define BLT_I18NCONTEXT_ID_SEQUENCE
@ SEQ_COLOR_BALANCE_INVERSE_GAIN
@ SEQ_COLOR_BALANCE_INVERSE_LIFT
@ SEQ_COLOR_BALANCE_INVERSE_SLOPE
@ SEQ_COLOR_BALANCE_INVERSE_POWER
@ SEQ_COLOR_BALANCE_INVERSE_OFFSET
@ SEQ_COLOR_BALANCE_INVERSE_GAMMA
@ eSeqModifierType_ColorBalance
@ SEQ_COLOR_BALANCE_METHOD_LIFTGAMMAGAIN
@ SEQ_COLOR_BALANCE_METHOD_SLOPEOFFSETPOWER
static void split(const char *text, const char *seps, char ***str, int *count)
void uiTemplateColorPicker(uiLayout *layout, PointerRNA *ptr, blender::StringRefNull propname, bool value_slider, bool lock, bool lock_luminosity, bool cubic)
PointerRNA * UI_panel_custom_data_get(const Panel *panel)
BMesh const char void * data
static void mul(btAlignedObjectArray< T > &items, const Q &value)
constexpr int64_t first() const
ccl_device_inline float2 power(const float2 v, const float e)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
T max(const T &a, const T &b)
static void colorBalance_init_data(StripModifierData *smd)
static constexpr int CB_TABLE_SIZE
void draw_mask_input_type_settings(const bContext *C, uiLayout *layout, PointerRNA *ptr)
static float color_balance_lgg(float in, const float lift, const float gain, const float gamma, const float mul)
void apply_modifier_op(T &op, ImBuf *ibuf, const ImBuf *mask, const float3x3 &mask_transform)
static float color_balance_sop(float in, const float slope, const float offset, const float power, float mul)
void store_pixel_premul(float4 pix, uchar *ptr)
static void make_cb_table_sop(float slope, float offset, float power, float mul, float r_table[CB_TABLE_SIZE])
static void make_cb_table_lgg(float lift, float gain, float gamma, float mul, float r_table[CB_TABLE_SIZE])
static void colorBalance_panel_draw(const bContext *C, Panel *panel)
StripModifierTypeInfo seqModifierType_ColorBalance
float4 load_pixel_premul(const uchar *ptr)
static void colorBalance_apply(ModifierApplyContext &context, StripModifierData *smd, ImBuf *mask)
static void colorBalance_register(ARegionType *region_type)
PanelType * modifier_panel_register(ARegionType *region_type, const eStripModifierType type, PanelDrawFn draw)
VecBase< float, 4 > float4
VecBase< float, 3 > float3
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
StripColorBalance color_balance
void init_sop(const StripColorBalance &data)
void apply(uchar *image, MaskSampler &mask, int image_x, IndexRange y_range)
void init_lgg(const StripColorBalance &data)
void apply(float *image, MaskSampler &mask, int image_x, IndexRange y_range)
float lut[3][CB_TABLE_SIZE]
void init(const ColorBalanceModifierData &data, bool byte_image)
PanelLayout panel_prop(const bContext *C, PointerRNA *open_prop_owner, blender::StringRefNull open_prop_name)
uiLayout & column(bool align)
uiLayout & grid_flow(bool row_major, int columns_len, bool even_columns, bool even_rows, bool align)
uiLayout & split(float percentage, bool align)
void use_property_split_set(bool value)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)