Fix: Zero division in Corner Pin node

Points at infinity in the Corner Pin node causes zero division, so
early exit with a zero.
This commit is contained in:
Omar Emara
2024-11-12 16:25:04 +02:00
parent df07e91dff
commit aff8a8878f
2 changed files with 10 additions and 0 deletions

View File

@@ -12,6 +12,11 @@ void main()
vec2 coordinates = (vec2(texel) + vec2(0.5)) / output_size;
vec3 transformed_coordinates = to_float3x3(homography_matrix) * vec3(coordinates, 1.0);
/* Point is at infinity and will be zero when sampled, so early exit. */
if (transformed_coordinates.z == 0.0) {
imageStore(output_img, texel, vec4(0.0));
return;
}
vec2 projected_coordinates = transformed_coordinates.xy / transformed_coordinates.z;
/* The derivatives of the projected coordinates with respect to x and y are the first and

View File

@@ -9,6 +9,11 @@ void main()
vec2 coordinates = (vec2(texel) + vec2(0.5)) / vec2(imageSize(mask_img));
vec3 transformed_coordinates = to_float3x3(homography_matrix) * vec3(coordinates, 1.0);
/* Point is at infinity and will be zero when sampled, so early exit. */
if (transformed_coordinates.z == 0.0) {
imageStore(mask_img, texel, vec4(0.0));
return;
}
vec2 projected_coordinates = transformed_coordinates.xy / transformed_coordinates.z;
bool is_inside_plane = all(greaterThanEqual(projected_coordinates, vec2(0.0))) &&