Fix: Compositor lighten mix mode is wrong for factors < 1
The Lighten mix mode in the Mix RGB node is wrong for factors less than one. The lighten blend mode is a simple component-wise maximum in EEVEE, Cycles, and other implementations. While the compositor seems to define it as a weighted maximum using the factor as the weight. It should be noted that its Darken counterpart is correctly implemented for the same node, so Lighten should follow, which this patch do. GPU compositor shares the EEVEE code, so it is already correct. Pull Request: https://projects.blender.org/blender/blender/pulls/117630
This commit is contained in:
@@ -927,28 +927,10 @@ void MixLightenOperation::execute_pixel_sampled(float output[4],
|
||||
if (this->use_value_alpha_multiply()) {
|
||||
value *= input_color2[3];
|
||||
}
|
||||
float tmp;
|
||||
tmp = value * input_color2[0];
|
||||
if (tmp > input_color1[0]) {
|
||||
output[0] = tmp;
|
||||
}
|
||||
else {
|
||||
output[0] = input_color1[0];
|
||||
}
|
||||
tmp = value * input_color2[1];
|
||||
if (tmp > input_color1[1]) {
|
||||
output[1] = tmp;
|
||||
}
|
||||
else {
|
||||
output[1] = input_color1[1];
|
||||
}
|
||||
tmp = value * input_color2[2];
|
||||
if (tmp > input_color1[2]) {
|
||||
output[2] = tmp;
|
||||
}
|
||||
else {
|
||||
output[2] = input_color1[2];
|
||||
}
|
||||
float valuem = 1.0f - value;
|
||||
output[0] = max_ff(input_color1[0], input_color2[0]) * value + input_color1[0] * valuem;
|
||||
output[1] = max_ff(input_color1[1], input_color2[1]) * value + input_color1[1] * valuem;
|
||||
output[2] = max_ff(input_color1[2], input_color2[2]) * value + input_color1[2] * valuem;
|
||||
output[3] = input_color1[3];
|
||||
|
||||
clamp_if_needed(output);
|
||||
@@ -961,16 +943,10 @@ void MixLightenOperation::update_memory_buffer_row(PixelCursor &p)
|
||||
if (this->use_value_alpha_multiply()) {
|
||||
value *= p.color2[3];
|
||||
}
|
||||
|
||||
float tmp = value * p.color2[0];
|
||||
p.out[0] = std::max(tmp, p.color1[0]);
|
||||
|
||||
tmp = value * p.color2[1];
|
||||
p.out[1] = std::max(tmp, p.color1[1]);
|
||||
|
||||
tmp = value * p.color2[2];
|
||||
p.out[2] = std::max(tmp, p.color1[2]);
|
||||
|
||||
float value_m = 1.0f - value;
|
||||
p.out[0] = max_ff(p.color1[0], p.color2[0]) * value + p.color1[0] * value_m;
|
||||
p.out[1] = max_ff(p.color1[1], p.color2[1]) * value + p.color1[1] * value_m;
|
||||
p.out[2] = max_ff(p.color1[2], p.color2[2]) * value + p.color1[2] * value_m;
|
||||
p.out[3] = p.color1[3];
|
||||
|
||||
clamp_if_needed(p.out);
|
||||
|
||||
Reference in New Issue
Block a user