Fix: Plane Deform mask retains original alpha
The Plane Deform mask output retains the original alpha of the input image, while it should be a binary mask. This patch ignores the alpha of the image and uses a binary mask instead.
This commit is contained in:
@@ -12,6 +12,7 @@ void main()
|
||||
ivec2 output_size = max(imageSize(output_img), imageSize(mask_img));
|
||||
vec2 coordinates = (vec2(texel) + vec2(0.5)) / vec2(output_size);
|
||||
|
||||
float accumulated_mask = 0.0;
|
||||
vec4 accumulated_color = vec4(0.0);
|
||||
for (int i = 0; i < number_of_motion_blur_samples; i++) {
|
||||
mat3 homography_matrix = mat3(homography_matrices[i]);
|
||||
@@ -25,11 +26,21 @@ void main()
|
||||
vec2 x_gradient = homography_matrix[0].xy / transformed_coordinates.z;
|
||||
vec2 y_gradient = homography_matrix[1].xy / transformed_coordinates.z;
|
||||
|
||||
accumulated_color += textureGrad(input_tx, projected_coordinates, x_gradient, y_gradient);
|
||||
vec4 sampled_color = textureGrad(input_tx, projected_coordinates, x_gradient, y_gradient);
|
||||
accumulated_color += sampled_color;
|
||||
|
||||
/* The plane mask is 1 if it is inside the plane and 0 otherwise. However, we use the alpha
|
||||
* value of the sampled color for pixels outside of the plane to utilize the anti-aliasing
|
||||
* effect of the anisotropic filtering. Therefore, the input_tx sampler should use anisotropic
|
||||
* filtering and be clamped to zero border color. */
|
||||
bool is_inside_plane = all(greaterThanEqual(projected_coordinates, vec2(0.0))) &&
|
||||
all(lessThanEqual(projected_coordinates, vec2(1.0)));
|
||||
accumulated_mask += is_inside_plane ? 1.0 : sampled_color.a;
|
||||
}
|
||||
|
||||
accumulated_mask /= number_of_motion_blur_samples;
|
||||
accumulated_color /= number_of_motion_blur_samples;
|
||||
|
||||
imageStore(output_img, texel, accumulated_color);
|
||||
imageStore(mask_img, texel, accumulated_color.aaaa);
|
||||
imageStore(mask_img, texel, vec4(accumulated_mask));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user