Compositor: Fallback to a black color for invalid outputs #118340

Merged
Omar Emara merged 3 commits from OmarEmaraDev/blender:fix-empty-buffer-case into main 2024-02-16 15:33:10 +01:00

3 Commits

Author SHA1 Message Date
Omar Emara 4799ef57cd Fix typo 2024-02-16 16:31:26 +02:00
Omar Emara a54010bbed Merge branch 'main' into fix-empty-buffer-case 2024-02-16 14:46:38 +02:00
Omar Emara 53c8003b2a Compositor: Fallback to a black color for invalid outputs
Currently, some compositor operations produce en empty output buffer by
specifying a COM_AREA_NONE canvas to indicate an invalid output, for
instance, when the Mask operation references an invalid mask. The
intention is that this buffer would signal that a fallback value should
fill the canvas of consumer operations.

The aforementioned behavior is currently implemented in a rather hacky
way, where it is implemented using the Translate operation as part of
canvas conversion in COM_convert_canvas, where the operation would clear
the entire buffer with zeros since out of bounds checking would always
take the out of bound case due to the empty buffer.

This behavior is problematic because we can't control the fallback
value, which would ideally be an opaque black color. Moreover, since
implicit type conversion happen before canvas conversion by design,
value typed buffers would eventually become transparent, which is rather
unexpected to the end user since float/value outputs can't have
transparency.

This is not a good design or implementation, but a redesign will be too
complex for now. So to fix this, we workaround it by handling the empty
buffer case explicitly in the Translate operation and fill the output
using a fallback black color, which works for both value and color typed
buffers, since this would also be the output of the value to color
implicit conversion.
2024-02-15 19:45:01 +02:00