Fix #115779: Compositor Split node factor 0 still shows the other image #115844

Merged
Habib Gahbiche merged 1 commits from zazizizou/blender:fix-split-node-0-percent into main 2023-12-07 18:10:56 +01:00
2 changed files with 4 additions and 4 deletions

View File

@ -37,7 +37,7 @@ void SplitOperation::execute_pixel_sampled(float output[4],
{
int perc = x_split_ ? split_percentage_ * this->get_width() / 100.0f :
split_percentage_ * this->get_height() / 100.0f;
bool image1 = x_split_ ? x > perc : y > perc;
bool image1 = x_split_ ? x >= perc : y >= perc;
if (image1) {
image1Input_->read_sampled(output, x, y, PixelSampler::Nearest);
}
@ -64,7 +64,7 @@ void SplitOperation::update_memory_buffer_partial(MemoryBuffer *output,
split_percentage_ * this->get_height() / 100.0f;
const size_t elem_bytes = COM_data_type_bytes_len(get_output_socket()->get_data_type());
for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) {
const bool is_image1 = x_split_ ? it.x > percent : it.y > percent;
const bool is_image1 = x_split_ ? it.x >= percent : it.y >= percent;
memcpy(it.out, it.in(is_image1 ? 0 : 1), elem_bytes);
}
}

View File

@ -9,9 +9,9 @@ void main()
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
ivec2 output_size = imageSize(output_img);
#if defined(SPLIT_HORIZONTAL)
bool condition = (output_size.x * split_ratio) < texel.x;
bool condition = (output_size.x * split_ratio) <= texel.x;
#elif defined(SPLIT_VERTICAL)
bool condition = (output_size.y * split_ratio) < texel.y;
bool condition = (output_size.y * split_ratio) <= texel.y;
#endif
vec4 color = condition ? texture_load(first_image_tx, texel) :
texture_load(second_image_tx, texel);