Fixed division by zero bug in alpha compositing

This commit is contained in:
Sridhar Ramesh
2018-02-20 12:33:58 -08:00
parent 652dab7f23
commit c2b9417c6a
2 changed files with 19 additions and 3 deletions

View File

@ -430,10 +430,15 @@ class Camera(object):
]
out_a = src_a + dst_a*(1.0-src_a)
# When the output alpha is 0 for full transparency,
# we have a choice over what RGB value to use in our
# output representation. We choose 0.0 here.
out_rgb = fdiv(
src_rgb*src_a[..., None] + \
dst_rgb*dst_a[..., None]*(1.0-src_a[..., None]),
out_a[..., None]
out_a[..., None],
zero_over_zero_value = 0.0
)
self.pixel_array[..., :3] = out_rgb*self.rgb_max_val